prog_optimize: Set unused regs to PROGRAM_UNDEFINED after CMP->MOV conversion
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 21 Jul 2011 01:02:17 +0000 (18:02 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 23 Jul 2011 08:24:18 +0000 (01:24 -0700)
Leaving the unused registers with other values caused assertion
failures and other problems in places that blindly iterate over all
sources.

brw_vs_emit.c:1381: get_src_reg: Assertion `c->regs[file][index].nr !=
0' failed.

Fixes i965 piglit:

    vs-uniform-array-mat[234]-col-row-rd
    vs-uniform-array-mat[234]-index-col-row-rd
    vs-uniform-array-mat[234]-index-row-rd
    vs-uniform-mat[234]-col-row-rd

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/program/prog_optimize.c

index 8a40fa69eca6ad5bb1ebf8d42cf494c3b7ef3fa4..f4a7a638d5f71c71fb463669ccd7367272f643a4 100644 (file)
@@ -1319,6 +1319,15 @@ _mesa_simplify_cmp(struct gl_program * program)
 
          inst->Opcode = OPCODE_MOV;
          inst->SrcReg[0] = inst->SrcReg[1];
+
+        /* Unused operands are expected to have the file set to
+         * PROGRAM_UNDEFINED.  This is how _mesa_init_instructions initializes
+         * all of the sources.
+         */
+        inst->SrcReg[1].File = PROGRAM_UNDEFINED;
+        inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
+        inst->SrcReg[2].File = PROGRAM_UNDEFINED;
+        inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;
       }
    }
    if (dbg) {