[Mesa-dev] [PATCH] glsl/linker: properly fix output variable overlap check

Nicolai Hähnle nhaehnle at gmail.com
Wed Sep 20 19:58:36 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102904
Fixes: 15cae12804e ("glsl/linker: fix output variable overlap check")
---
 src/compiler/glsl/linker.cpp | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index ddd8301a739..71312b6a40d 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2880,39 +2880,45 @@ assign_attribute_or_color_locations(void *mem_ctx,
                         if (assigned_component_mask & component_mask) {
                            linker_error(prog, "overlapping component is "
                                         "assigned to %ss %s and %s "
                                         "(component=%d)\n",
                                         string, assigned[i]->name, var->name,
                                         var->data.location_frac);
                            return false;
                         }
                      }
                   }
-
-                  /* At most one variable per fragment output component should
-                   * reach this. */
-                  assert(assigned_attr < ARRAY_SIZE(assigned));
-                  assigned[assigned_attr] = var;
-                  assigned_attr++;
                } else if (target_index == MESA_SHADER_FRAGMENT ||
                           (prog->IsES && prog->data->Version >= 300)) {
                   linker_error(prog, "overlapping location is assigned "
                                "to %s `%s' %d %d %d\n", string, var->name,
                                used_locations, use_mask, attr);
                   return false;
                } else {
                   linker_warning(prog, "overlapping location is assigned "
                                  "to %s `%s' %d %d %d\n", string, var->name,
                                  used_locations, use_mask, attr);
                }
             }
 
+            if (target_index == MESA_SHADER_FRAGMENT && !prog->IsES) {
+               /* Only track assigned variables for non-ES fragment shaders
+                * to avoid overflowing the array.
+                *
+                * At most one variable per fragment output component should
+                * reach this.
+                */
+               assert(assigned_attr < ARRAY_SIZE(assigned));
+               assigned[assigned_attr] = var;
+               assigned_attr++;
+            }
+
             used_locations |= (use_mask << attr);
 
             /* From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes):
              *
              * "A program with more than the value of MAX_VERTEX_ATTRIBS
              *  active attribute variables may fail to link, unless
              *  device-dependent optimizations are able to make the program
              *  fit within available hardware resources. For the purposes
              *  of this test, attribute variables of the type dvec3, dvec4,
              *  dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may
-- 
2.11.0



More information about the mesa-dev mailing list