glsl: Add a helper for ir_builder to make dereferences for assignments.

v2: Fix writemask setup for non-vec4 assignments.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Eric Anholt
2012-03-19 16:27:34 -07:00
parent 7e88f8ce8f
commit d32780d504
3 changed files with 59 additions and 49 deletions
+18
View File
@@ -34,6 +34,24 @@ ir_factory::emit(ir_instruction *ir)
instructions->push_tail(ir);
}
ir_assignment *
assign(deref lhs, operand rhs, int writemask)
{
void *mem_ctx = ralloc_parent(lhs.val);
ir_assignment *assign = new(mem_ctx) ir_assignment(lhs.val,
rhs.val,
NULL, writemask);
return assign;
}
ir_assignment *
assign(deref lhs, operand rhs)
{
return assign(lhs, rhs, (1 << lhs.val->type->vector_elements) - 1);
}
ir_swizzle *
swizzle(operand a, int swizzle, int components)
{