summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ir_builder.cpp18
-rw-r--r--src/glsl/ir_builder.h24
2 files changed, 42 insertions, 0 deletions
diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 98ac3c100a1..0c8a15bc86e 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -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)
{
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index 350f9a33a81..af9d1600f68 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -50,6 +50,27 @@ public:
ir_rvalue *val;
};
+/** Automatic generator for ir_dereference_variable on assignment LHS.
+ *
+ * \sa operand
+ */
+class deref {
+public:
+ deref(ir_dereference *val)
+ : val(val)
+ {
+ }
+
+ deref(ir_variable *var)
+ {
+ void *mem_ctx = ralloc_parent(var);
+ val = new(mem_ctx) ir_dereference_variable(var);
+ }
+
+
+ ir_dereference *val;
+};
+
class ir_factory {
public:
void emit(ir_instruction *ir);
@@ -58,6 +79,9 @@ public:
void *mem_ctx;
};
+ir_assignment *assign(deref lhs, operand rhs);
+ir_assignment *assign(deref lhs, operand rhs, int writemask);
+
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);