glsl: Add IR builder support for conditional assignments.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 3 Sep 2013 23:41:42 +0000 (16:41 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Sep 2013 18:52:22 +0000 (11:52 -0700)
This adds two new signatures:

   assign(lhs, rhs, condition, writemask);
   assign(lhs, rhs, condition);

All the other existing APIs still exist.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ir_builder.cpp
src/glsl/ir_builder.h

index 87f57901becf220700a9df7d2010389c4c24d1ab..b2b926b610f8716fc34fb54ffd13b925e64e1a86 100644 (file)
@@ -46,13 +46,14 @@ ir_factory::make_temp(const glsl_type *type, const char *name)
 }
 
 ir_assignment *
-assign(deref lhs, operand rhs, int writemask)
+assign(deref lhs, operand rhs, operand condition, int writemask)
 {
    void *mem_ctx = ralloc_parent(lhs.val);
 
    ir_assignment *assign = new(mem_ctx) ir_assignment(lhs.val,
                                                      rhs.val,
-                                                     NULL, writemask);
+                                                      condition.val,
+                                                      writemask);
 
    return assign;
 }
@@ -63,6 +64,18 @@ assign(deref lhs, operand rhs)
    return assign(lhs, rhs, (1 << lhs.val->type->vector_elements) - 1);
 }
 
+ir_assignment *
+assign(deref lhs, operand rhs, int writemask)
+{
+   return assign(lhs, rhs, (ir_rvalue *) NULL, writemask);
+}
+
+ir_assignment *
+assign(deref lhs, operand rhs, operand condition)
+{
+   return assign(lhs, rhs, condition, (1 << lhs.val->type->vector_elements) - 1);
+}
+
 ir_swizzle *
 swizzle(operand a, int swizzle, int components)
 {
index 6c0b5a189bd3edafbfbb0037bf5b5bcbf493c299..c852849720fa18c2d27e76015b164f9ceb50a349 100644 (file)
@@ -122,6 +122,8 @@ public:
 
 ir_assignment *assign(deref lhs, operand rhs);
 ir_assignment *assign(deref lhs, operand rhs, int writemask);
+ir_assignment *assign(deref lhs, operand rhs, operand condition);
+ir_assignment *assign(deref lhs, operand rhs, operand condition, int writemask);
 
 ir_expression *expr(ir_expression_operation op, operand a);
 ir_expression *expr(ir_expression_operation op, operand a, operand b);