From: Marek Olšák <[email protected]>

---
 src/compiler/glsl/opt_dead_code_local.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/opt_dead_code_local.cpp 
b/src/compiler/glsl/opt_dead_code_local.cpp
index fc979af..a403879 100644
--- a/src/compiler/glsl/opt_dead_code_local.cpp
+++ b/src/compiler/glsl/opt_dead_code_local.cpp
@@ -99,23 +99,26 @@ public:
    }
 
    virtual ir_visitor_status visit(ir_swizzle *ir)
    {
       ir_dereference_variable *deref = ir->val->as_dereference_variable();
       if (!deref)
         return visit_continue;
 
       int used = 0;
       used |= 1 << ir->mask.x;
-      used |= 1 << ir->mask.y;
-      used |= 1 << ir->mask.z;
-      used |= 1 << ir->mask.w;
+      if (ir->mask.num_components > 1)
+         used |= 1 << ir->mask.y;
+      if (ir->mask.num_components > 2)
+         used |= 1 << ir->mask.z;
+      if (ir->mask.num_components > 3)
+         used |= 1 << ir->mask.w;
 
       use_channels(deref->var, used);
 
       return visit_continue_with_parent;
    }
 
    virtual ir_visitor_status visit_leave(ir_emit_vertex *)
    {
       /* For the purpose of dead code elimination, emitting a vertex counts as
        * "reading" all of the currently assigned output variables.
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to