mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
glsl/ir_builder: Add more helpers for constructing expressions
Add the following functions, each of which construct the similarly named
ir expression:
div, round_even, clamp
equal, less, greater, lequal, gequal
logic_not, logic_and, logic_or
bit_not, bit_or, bit_and, lshift, rshift
f2i, i2f, f2u, u2f, i2u, u2i
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
This commit is contained in:
parent
fafcbf52b7
commit
5790174e37
2 changed files with 156 additions and 0 deletions
|
|
@ -188,11 +188,27 @@ ir_expression *mul(operand a, operand b)
|
|||
return expr(ir_binop_mul, a, b);
|
||||
}
|
||||
|
||||
ir_expression *div(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_div, a, b);
|
||||
}
|
||||
|
||||
ir_expression *round_even(operand a)
|
||||
{
|
||||
return expr(ir_unop_round_even, a);
|
||||
}
|
||||
|
||||
ir_expression *dot(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_dot, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
clamp(operand a, operand b, operand c)
|
||||
{
|
||||
return expr(ir_binop_min, expr(ir_binop_max, a, b), c);
|
||||
}
|
||||
|
||||
ir_expression *
|
||||
saturate(operand a)
|
||||
{
|
||||
|
|
@ -203,4 +219,118 @@ saturate(operand a)
|
|||
new(mem_ctx) ir_constant(0.0f));
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
equal(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_equal, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
less(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_less, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
greater(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_greater, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
lequal(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_lequal, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
gequal(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_gequal, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
logic_not(operand a)
|
||||
{
|
||||
return expr(ir_unop_logic_not, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
logic_and(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_logic_and, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
logic_or(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_logic_or, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
bit_not(operand a)
|
||||
{
|
||||
return expr(ir_unop_bit_not, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
bit_and(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_bit_and, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
bit_or(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_bit_or, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
lshift(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_lshift, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
rshift(operand a, operand b)
|
||||
{
|
||||
return expr(ir_binop_rshift, a, b);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
f2i(operand a)
|
||||
{
|
||||
return expr(ir_unop_f2i, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
i2f(operand a)
|
||||
{
|
||||
return expr(ir_unop_i2f, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
i2u(operand a)
|
||||
{
|
||||
return expr(ir_unop_i2u, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
u2i(operand a)
|
||||
{
|
||||
return expr(ir_unop_u2i, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
f2u(operand a)
|
||||
{
|
||||
return expr(ir_unop_f2u, a);
|
||||
}
|
||||
|
||||
ir_expression*
|
||||
u2f(operand a)
|
||||
{
|
||||
return expr(ir_unop_u2f, a);
|
||||
}
|
||||
|
||||
} /* namespace ir_builder */
|
||||
|
|
|
|||
|
|
@ -95,9 +95,35 @@ ir_expression *expr(ir_expression_operation op, operand a, operand b);
|
|||
ir_expression *add(operand a, operand b);
|
||||
ir_expression *sub(operand a, operand b);
|
||||
ir_expression *mul(operand a, operand b);
|
||||
ir_expression *div(operand a, operand b);
|
||||
ir_expression *round_even(operand a);
|
||||
ir_expression *dot(operand a, operand b);
|
||||
ir_expression *clamp(operand a, operand b, operand c);
|
||||
ir_expression *saturate(operand a);
|
||||
|
||||
ir_expression *equal(operand a, operand b);
|
||||
ir_expression *less(operand a, operand b);
|
||||
ir_expression *greater(operand a, operand b);
|
||||
ir_expression *lequal(operand a, operand b);
|
||||
ir_expression *gequal(operand a, operand b);
|
||||
|
||||
ir_expression *logic_not(operand a);
|
||||
ir_expression *logic_and(operand a, operand b);
|
||||
ir_expression *logic_or(operand a, operand b);
|
||||
|
||||
ir_expression *bit_not(operand a);
|
||||
ir_expression *bit_or(operand a, operand b);
|
||||
ir_expression *bit_and(operand a, operand b);
|
||||
ir_expression *lshift(operand a, operand b);
|
||||
ir_expression *rshift(operand a, operand b);
|
||||
|
||||
ir_expression *f2i(operand a);
|
||||
ir_expression *i2f(operand a);
|
||||
ir_expression *f2u(operand a);
|
||||
ir_expression *u2f(operand a);
|
||||
ir_expression *i2u(operand a);
|
||||
ir_expression *u2i(operand a);
|
||||
|
||||
/**
|
||||
* Swizzle away later components, but preserve the ordering.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue