[Mesa-dev] [PATCH 06/14] glsl: fix error checking against MAX_UNIFORM_LOCATIONS

Marek Olšák maraeo at gmail.com
Wed Aug 8 23:55:15 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/compiler/glsl/link_uniforms.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 8d3f95fe114..434ecefb289 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1202,22 +1202,26 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
       /* how many new entries for this uniform? */
       const unsigned entries =
          MAX2(1, prog->data->UniformStorage[i].array_elements);
 
       /* Find UniformRemapTable for empty blocks where we can fit this uniform. */
       int chosen_location = -1;
 
       if (empty_locs)
          chosen_location = link_util_find_empty_block(prog, &prog->data->UniformStorage[i]);
 
-      /* Add new entries to the total amount of entries. */
-      total_entries += entries;
+      /* Add new entries to the total amount for checking against MAX_UNIFORM-
+       * _LOCATIONS. This only applies to the default uniform block (-1),
+       * because locations of uniform block entries are not assignable.
+       */
+      if (prog->data->UniformStorage[i].block_index == -1)
+         total_entries += entries;
 
       if (chosen_location != -1) {
          empty_locs -= entries;
       } else {
          chosen_location = prog->NumUniformRemapTable;
 
          /* resize remap table to fit new entries */
          prog->UniformRemapTable =
             reralloc(prog,
                      prog->UniformRemapTable,
-- 
2.17.1



More information about the mesa-dev mailing list