Mesa (master): glsl_to_tgsi: improve assignment hack

Bryan Cain bryanc at kemper.freedesktop.org
Tue Aug 9 17:35:57 UTC 2011


Module: Mesa
Branch: master
Commit: e6c64800cc8833fb4083a556c839b51e8ac84a8b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6c64800cc8833fb4083a556c839b51e8ac84a8b

Author: Henri Verbeet <hverbeet at gmail.com>
Date:   Tue Aug  9 12:23:47 2011 -0500

glsl_to_tgsi: improve assignment hack

Fixes StarCraft 2 and Fallout 3 in Wine.

---

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    8 +++++---
 1 files changed, 5 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 d7a1ba8..aef23e7 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1994,15 +1994,17 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
    } else if (ir->rhs->as_expression() &&
               this->instructions.get_tail() &&
               ir->rhs == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->ir &&
-              type_size(ir->lhs->type) == 1) {
+              type_size(ir->lhs->type) == 1 &&
+              l.writemask == ((glsl_to_tgsi_instruction *)this->instructions.get_tail())->dst.writemask) {
       /* To avoid emitting an extra MOV when assigning an expression to a 
        * 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;
+      glsl_to_tgsi_instruction *inst, *new_inst;
       inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail();
-      emit(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
+      new_inst = emit(ir, inst->op, l, inst->src[0], inst->src[1], inst->src[2]);
+      new_inst->saturate = inst->saturate;
    } 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