summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-24 15:12:21 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-24 15:12:21 -0700
commit2f4240fb0276bd18b86adadd41664ca0c9f10da6 (patch)
tree26d2b3126e4ccb32599674608ea9ec3b28ac6652
parent44bb1a62f9fa55a2f4febc87abcfb78386283c0e (diff)
Add method to set the swizzle of an ir_dereference
-rw-r--r--ir.cpp26
-rw-r--r--ir.h7
2 files changed, 33 insertions, 0 deletions
diff --git a/ir.cpp b/ir.cpp
index 26e7394305..49df75425e 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -87,6 +87,32 @@ ir_dereference::ir_dereference(ir_instruction *var)
}
+void
+ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w,
+ unsigned count)
+{
+ assert((count >= 1) && (count <= 4));
+
+ const unsigned dup_mask = 0
+ | ((count > 1) ? ((1U << y) & ((1U << x) )) : 0)
+ | ((count > 2) ? ((1U << z) & ((1U << x) | (1U << y) )) : 0)
+ | ((count > 3) ? ((1U << w) & ((1U << x) | (1U << y) | (1U << z))) : 0);
+
+ assert(x <= 3);
+ assert(y <= 3);
+ assert(z <= 3);
+ assert(w <= 3);
+
+ selector.swizzle.x = x;
+ selector.swizzle.y = y;
+ selector.swizzle.z = z;
+ selector.swizzle.w = w;
+ selector.swizzle.num_components = count;
+ selector.swizzle.has_duplicates = dup_mask != 0;
+}
+
+
+
ir_variable::ir_variable(const struct glsl_type *type, const char *name)
: ir_instruction(ir_op_var_decl), read_only(false), centroid(false),
invariant(false), mode(ir_var_auto), interpolation(ir_var_smooth)
diff --git a/ir.h b/ir.h
index 7db617d65b..bbf53540db 100644
--- a/ir.h
+++ b/ir.h
@@ -398,6 +398,13 @@ public:
v->visit(this);
}
+ /**
+ * Setting the swizzle of a derefernce
+ */
+ void set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w,
+ unsigned count);
+
+
enum {
ir_reference_variable,
ir_reference_array,