Mesa (glsl-to-tgsi): glsl_to_tgsi: make assignment hack safer

Bryan Cain bryanc at kemper.freedesktop.org
Thu Jul 21 21:32:00 UTC 2011


Module: Mesa
Branch: glsl-to-tgsi
Commit: 4d3dc452eb2f23f85da17f2908af244f62ba9c24
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d3dc452eb2f23f85da17f2908af244f62ba9c24

Author: Bryan Cain <bryancain3 at gmail.com>
Date:   Thu Jul 21 16:29:56 2011 -0500

glsl_to_tgsi: make assignment hack safer

Fixes an assertion failure in piglit test glsl-texcoord-array.

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 389e5d8..6e01a44 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -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);




More information about the mesa-commit mailing list