summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-07-02 14:06:34 -0700
committerEric Anholt <eric@anholt.net>2010-07-02 14:08:20 -0700
commitcab95c228b12f0fc568164d57475c561c8d6053e (patch)
treef304394f07a22025b52b6ed4d88f5e96d5c311cc /src
parent28faa12dc2413d93c7f4778327a5e7c4c8f57c85 (diff)
ir_to_mesa: Fix sparse swizzling of src regs when a writemask is present.
Fixes glsl-fs-texture2d-masked.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 11fb7b9f16..59268e6d17 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1175,6 +1175,29 @@ get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v)
return dst_reg;
}
+static GLuint
+reswizzle_for_writemask(GLuint writemask, GLuint swizzle)
+{
+ int new_swizzle[4], pos = 0;
+ int i;
+
+ /* reswizzle the rhs so the components are in place for the
+ * components we'll assign to the lhs.
+ */
+ for (i = 0; i < 4; i++) {
+ if (writemask & (1 << i)) {
+ new_swizzle[i] = GET_SWZ(swizzle, pos++);
+ } else {
+ new_swizzle[i] = GET_SWZ(swizzle, 0);
+ }
+ }
+
+ return MAKE_SWIZZLE4(new_swizzle[0],
+ new_swizzle[1],
+ new_swizzle[2],
+ new_swizzle[3]);
+}
+
void
ir_to_mesa_visitor::visit(ir_assignment *ir)
{
@@ -1189,6 +1212,9 @@ ir_to_mesa_visitor::visit(ir_assignment *ir)
ir->rhs->accept(this);
r = this->result;
+
+ r.swizzle = reswizzle_for_writemask(l.writemask, r.swizzle);
+
assert(l.file != PROGRAM_UNDEFINED);
assert(r.file != PROGRAM_UNDEFINED);