glsl_to_tgsi: make assignment hack safer
authorBryan Cain <bryancain3@gmail.com>
Thu, 21 Jul 2011 21:29:56 +0000 (16:29 -0500)
committerBryan Cain <bryancain3@gmail.com>
Mon, 1 Aug 2011 22:59:10 +0000 (17:59 -0500)
Fixes an assertion failure in piglit test glsl-texcoord-array.

src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 389e5d8e2ef22778d21c7fc464e84f58b86a91a4..6e01a44a733bd21348bef78c7ca36dfba3768cca 100644 (file)
@@ -1917,12 +1917,13 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
               ir->rhs == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->ir &&
               type_size(ir->lhs->type) == 1) {
       /* To avoid emitting an extra MOV when assigning an expression to a 
-       * variable, change the destination register of the last instruction 
-       * emitted as part of the expression to the assignment variable.
+       * variable, emit the last instruction of the expression again, but
+       * replace the destination register with the target of the assignment.
+       * Dead code elimination will remove the original instruction.
        */
       glsl_to_tgsi_instruction *inst;
       inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
-      inst->dst = l;
+      emit(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
    } else {
       for (i = 0; i < type_size(ir->lhs->type); i++) {
          emit(ir, TGSI_OPCODE_MOV, l, r);