mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 06:30:10 +01:00
glsl/ir_builder: Add a new swizzle_for_size() function.
This swizzles away unwanted components, while preserving the order of the ones that remain. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
0bb3d4ba54
commit
d9da350a83
2 changed files with 20 additions and 0 deletions
|
|
@ -76,6 +76,21 @@ swizzle(operand a, int swizzle, int components)
|
|||
components);
|
||||
}
|
||||
|
||||
ir_swizzle *
|
||||
swizzle_for_size(operand a, int components)
|
||||
{
|
||||
void *mem_ctx = ralloc_parent(a.val);
|
||||
|
||||
if (a.val->type->vector_elements < components)
|
||||
components = a.val->type->vector_elements;
|
||||
|
||||
unsigned s[4] = { 0, 1, 2, 3 };
|
||||
for (int i = components; i < 4; i++)
|
||||
s[i] = components - 1;
|
||||
|
||||
return new(mem_ctx) ir_swizzle(a.val, s, components);
|
||||
}
|
||||
|
||||
ir_swizzle *
|
||||
swizzle_xxxx(operand a)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ ir_expression *mul(operand a, operand b);
|
|||
ir_expression *dot(operand a, operand b);
|
||||
ir_expression *saturate(operand a);
|
||||
|
||||
/**
|
||||
* Swizzle away later components, but preserve the ordering.
|
||||
*/
|
||||
ir_swizzle *swizzle_for_size(operand a, int components);
|
||||
|
||||
ir_swizzle *swizzle_xxxx(operand a);
|
||||
ir_swizzle *swizzle_yyyy(operand a);
|
||||
ir_swizzle *swizzle_zzzz(operand a);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue