Mesa (mesa_7_4_branch): glsl: fix another swizzle-related bug

Brian Paul brianp at kemper.freedesktop.org
Tue Feb 24 15:32:18 UTC 2009


Module: Mesa
Branch: mesa_7_4_branch
Commit: 9d5aa36239a691474c51f042a678549e2c31e2b7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d5aa36239a691474c51f042a678549e2c31e2b7

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Feb 24 08:31:02 2009 -0700

glsl: fix another swizzle-related bug

This fixes the case of "infinitely" nested swizzles such as EXPR.wzyx.yxwz.xxyz
This doesn't appear in typical shaders but with function inlining and the
compiler's internal use of swizzles it can happen.
New glean glsl1 test case added for this.

(cherry picked from master, commit d9881356a64b848dbae5fffd77fd93d0eb4247a3)

---

 src/mesa/shader/slang/slang_emit.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index feff1b7..db78dbe 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1360,6 +1360,7 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
 
 #if PEEPHOLE_OPTIMIZATIONS
    if (inst &&
+       (n->Children[1]->Opcode != IR_SWIZZLE) &&
        _slang_is_temp(emitInfo->vt, n->Children[1]->Store) &&
        (inst->DstReg.File == n->Children[1]->Store->File) &&
        (inst->DstReg.Index == n->Children[1]->Store->Index) &&
@@ -1376,13 +1377,9 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
        * becomes:
        *   MUL a, x, y;
        */
-      if (n->Children[1]->Opcode != IR_SWIZZLE)
-         _slang_free_temp(emitInfo->vt, n->Children[1]->Store);
-      *n->Children[1]->Store = *n->Children[0]->Store;
 
       /* fixup the previous instruction (which stored the RHS result) */
       assert(n->Children[0]->Store->Index >= 0);
-
       storage_to_dst_reg(&inst->DstReg, n->Children[0]->Store);
       return inst;
    }
@@ -1841,24 +1838,22 @@ emit_swizzle(slang_emit_info *emitInfo, slang_ir_node *n)
 
    inst = emit(emitInfo, n->Children[0]);
 
-   if (n->Children[0]->Opcode == IR_VAR ||
-       n->Children[0]->Opcode == IR_SWIZZLE ||
-       n->Children[0]->Opcode == IR_ELEMENT) {
-      /* We can resolve the swizzle now.  Other swizzles will be resolved
-       * in storage_to_src_reg().
-       */
+   assert(n->Children[0]->Store == n->Store->Parent);
+   assert(n->Store->Parent);
+
+   {
       const GLuint swizzle = n->Store->Swizzle;
-      assert(n->Store->Parent);
       /* new storage is parent storage with updated Swizzle + Size fields */
       _slang_copy_ir_storage(n->Store, n->Store->Parent);
       /* Apply this node's swizzle to parent's storage */
       n->Store->Swizzle = _slang_swizzle_swizzle(n->Store->Swizzle, swizzle);
       /* Update size */
       n->Store->Size = swizzle_size(n->Store->Swizzle);
-      assert(!n->Store->Parent);
-      assert(n->Store->Index >= 0);
    }
 
+   assert(!n->Store->Parent);
+   assert(n->Store->Index >= 0);
+
    return inst;
 }
 




More information about the mesa-commit mailing list