i965: Respect CondSwizzle in OPCODE_IF.
authorEric Anholt <eric@anholt.net>
Wed, 5 Aug 2009 01:02:31 +0000 (18:02 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 5 Aug 2009 01:06:34 +0000 (18:06 -0700)
Fixes piglit glsl-vs-if-bool and progs/glsl/twoside, and will likely be
useful for the looping code.

Bug #18992

src/mesa/drivers/dri/i965/brw_vs_emit.c

index bd584d2189edb76a61dbc6645f8f50fd0a9e06a5..be9bf02aa7fce613837354fb7c26bc630725c174 100644 (file)
@@ -1265,6 +1265,23 @@ post_vs_emit( struct brw_vs_compile *c,
    brw_set_src1(end_inst, brw_imm_d(offset * 16));
 }
 
+static uint32_t
+get_predicate(uint32_t swizzle)
+{
+   switch (swizzle) {
+   case SWIZZLE_XXXX:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_X;
+   case SWIZZLE_YYYY:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_Y;
+   case SWIZZLE_ZZZZ:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_Z;
+   case SWIZZLE_WWWW:
+      return BRW_PREDICATE_ALIGN16_REPLICATE_W;
+   default:
+      _mesa_problem("Unexpected predicate: 0x%08x\n", swizzle);
+      return BRW_PREDICATE_NORMAL;
+   }
+}
 
 /* Emit the vertex program instructions here.
  */
@@ -1470,7 +1487,10 @@ void brw_vs_emit(struct brw_vs_compile *c )
         break;
       case OPCODE_IF:
         assert(if_depth < MAX_IF_DEPTH);
-         if_inst[if_depth++] = brw_IF(p, BRW_EXECUTE_8);
+        if_inst[if_depth] = brw_IF(p, BRW_EXECUTE_8);
+        if_inst[if_depth]->header.predicate_control =
+           get_predicate(inst->DstReg.CondSwizzle);
+        if_depth++;
         break;
       case OPCODE_ELSE:
         if_inst[if_depth-1] = brw_ELSE(p, if_inst[if_depth-1]);