glsl_to_tgsi: use a more specific condition for gl_FragDepth hack in generating assig...
authorBryan Cain <bryancain3@gmail.com>
Sat, 25 Jun 2011 01:37:53 +0000 (20:37 -0500)
committerBryan Cain <bryancain3@gmail.com>
Mon, 1 Aug 2011 22:59:09 +0000 (17:59 -0500)
This reduces the number of instructions in the fragment shader of
glsl-fs-atan-2 from 174 to 146 with EmitNoIfs enabled.

src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index d47364fabb6c3157893ba901504d438619e86fd1..5f22f7091d60c1148dbd1ed9b295de54f50a7497 100644 (file)
@@ -1841,7 +1841,8 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
    if (ir->write_mask == 0) {
       assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
       l.writemask = WRITEMASK_XYZW;
-   } else if (ir->lhs->type->is_scalar()) {
+   } else if (ir->lhs->type->is_scalar() &&
+              ir->lhs->variable_referenced()->mode == ir_var_out) {
       /* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
        * FINISHME: W component of fragment shader output zero, work correctly.
        */
@@ -1851,7 +1852,6 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
       int first_enabled_chan = 0;
       int rhs_chan = 0;
 
-      assert(ir->lhs->type->is_vector());
       l.writemask = ir->write_mask;
 
       for (int i = 0; i < 4; i++) {