glsl: Add a new ir_builder::dotlike() function.
dotlike() uses ir_binop_mul for scalars, and ir_binop_dot for vectors. When generating built-in functions, we often want to use regular multiply for scalar signatures, and dot() for vector signatures. ir_binop_dot only works on vectors, so we have to switch opcodes, even if the code is otherwise identical. dotlike() makes this easy. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
@@ -231,6 +231,17 @@ ir_expression *dot(operand a, operand b)
|
|||||||
return expr(ir_binop_dot, a, b);
|
return expr(ir_binop_dot, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dot for vectors, mul for scalars */
|
||||||
|
ir_expression *dotlike(operand a, operand b)
|
||||||
|
{
|
||||||
|
assert(a.val->type == b.val->type);
|
||||||
|
|
||||||
|
if (a.val->type->vector_elements == 1)
|
||||||
|
return expr(ir_binop_mul, a, b);
|
||||||
|
|
||||||
|
return expr(ir_binop_dot, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
ir_expression*
|
ir_expression*
|
||||||
clamp(operand a, operand b, operand c)
|
clamp(operand a, operand b, operand c)
|
||||||
{
|
{
|
||||||
|
@@ -136,6 +136,7 @@ ir_expression *mul(operand a, operand b);
|
|||||||
ir_expression *div(operand a, operand b);
|
ir_expression *div(operand a, operand b);
|
||||||
ir_expression *round_even(operand a);
|
ir_expression *round_even(operand a);
|
||||||
ir_expression *dot(operand a, operand b);
|
ir_expression *dot(operand a, operand b);
|
||||||
|
ir_expression *dotlike(operand a, operand b);
|
||||||
ir_expression *clamp(operand a, operand b, operand c);
|
ir_expression *clamp(operand a, operand b, operand c);
|
||||||
ir_expression *saturate(operand a);
|
ir_expression *saturate(operand a);
|
||||||
ir_expression *abs(operand a);
|
ir_expression *abs(operand a);
|
||||||
|
Reference in New Issue
Block a user