[Mesa-dev] [PATCH 1/3] glsl/link: don't consider unused variable as read variable.

Gregory Hainaut gregory.hainaut at gmail.com
Sun Sep 20 13:15:33 PDT 2015


Current checks rely on the optimization phase to remove deadcode
varying. Therefore remaining varying are used.

Deadcode Optimizations won't be possible anymore with the support of
GL_ARB_separate_shader_objects. So it requires to check the used flag of
the varying.

Signed-off-by: Gregory Hainaut <gregory.hainaut at gmail.com>
---
 src/glsl/link_varyings.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index f7a7b8c..72d6632 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1579,7 +1579,7 @@ assign_varying_locations(struct gl_context *ctx,
 
          if (var && var->data.mode == ir_var_shader_in &&
              var->data.is_unmatched_generic_inout) {
-            if (prog->IsES) {
+            if (var->data.used && prog->IsES) {
                /*
                 * On Page 91 (Page 97 of the PDF) of the GLSL ES 1.0 spec:
                 *
@@ -1594,7 +1594,7 @@ assign_varying_locations(struct gl_context *ctx,
                               _mesa_shader_stage_to_string(consumer->Stage),
                               var->name,
                               _mesa_shader_stage_to_string(producer->Stage));
-            } else if (prog->Version <= 120) {
+            } else if (var->data.used && prog->Version <= 120) {
                /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
                 *
                 *     Only those varying variables used (i.e. read) in
-- 
2.1.4



More information about the mesa-dev mailing list