glsl_to_tgsi: use swizzle_for_size for src reg in conditional moves
authorBryan Cain <bryancain3@gmail.com>
Fri, 24 Jun 2011 00:35:36 +0000 (19:35 -0500)
committerBryan Cain <bryancain3@gmail.com>
Mon, 1 Aug 2011 22:59:08 +0000 (17:59 -0500)
This prevents the copy propagation pass from being confused by undefined
channels and thus missing optimization opportunities.

src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index abeb44a408380a66c891085b1e1802143e65c86a..6d76686ab5db9db70118dae4abd55e65a6be07b5 100644 (file)
@@ -1882,10 +1882,13 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
       st_src_reg condition = this->result;
 
       for (i = 0; i < type_size(ir->lhs->type); i++) {
+         st_src_reg l_src = st_src_reg(l);
+         l_src.swizzle = swizzle_for_size(ir->lhs->type->vector_elements);
+         
          if (switch_order) {
-            emit(ir, TGSI_OPCODE_CMP, l, condition, st_src_reg(l), r);
+            emit(ir, TGSI_OPCODE_CMP, l, condition, l_src, r);
          } else {
-            emit(ir, TGSI_OPCODE_CMP, l, condition, r, st_src_reg(l));
+            emit(ir, TGSI_OPCODE_CMP, l, condition, r, l_src);
          }
 
          l.index++;