summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/ir.cpp')
-rw-r--r--src/glsl/ir.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 7cc55d40b78..5e2109ecc6e 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -55,6 +55,9 @@ update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to)
void
ir_assignment::set_lhs(ir_rvalue *lhs)
{
+ void *mem_ctx = this;
+ bool swizzled = false;
+
while (lhs != NULL) {
ir_swizzle *swiz = lhs->as_swizzle();
@@ -82,7 +85,21 @@ ir_assignment::set_lhs(ir_rvalue *lhs)
this->write_mask = write_mask;
lhs = swiz->val;
- this->rhs = new(this) ir_swizzle(this->rhs, rhs_swiz);
+ this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz);
+ swizzled = true;
+ }
+
+ if (swizzled) {
+ /* Now, RHS channels line up with the LHS writemask. Collapse it
+ * to just the channels that will be written.
+ */
+ ir_swizzle_mask rhs_swiz = { 0, 0, 0, 0, 0, 0 };
+ int rhs_chan = 0;
+ for (int i = 0; i < 4; i++) {
+ if (write_mask & (1 << i))
+ update_rhs_swizzle(rhs_swiz, i, rhs_chan++);
+ }
+ this->rhs = new(mem_ctx) ir_swizzle(this->rhs, rhs_swiz);
}
assert((lhs == NULL) || lhs->as_dereference());
@@ -122,6 +139,16 @@ ir_assignment::ir_assignment(ir_dereference *lhs, ir_rvalue *rhs,
this->rhs = rhs;
this->lhs = lhs;
this->write_mask = write_mask;
+
+ if (lhs->type->is_scalar() || lhs->type->is_vector()) {
+ int lhs_components = 0;
+ for (int i = 0; i < 4; i++) {
+ if (write_mask & (1 << i))
+ lhs_components++;
+ }
+
+ assert(lhs_components == this->rhs->type->vector_elements);
+ }
}
ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,