Mesa (master): glsl: fix resizing of the uniform remap table

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Feb 29 00:30:28 UTC 2020


Module: Mesa
Branch: master
Commit: e0aa0a839f9c168784a1f50013c83877cc876094
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e0aa0a839f9c168784a1f50013c83877cc876094

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Thu Feb  6 12:49:10 2020 +1100

glsl: fix resizing of the uniform remap table

In the NIR linker we were not resizing the remap table correctly
for explicit locations when it was needed.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3992>

---

 src/compiler/glsl/gl_nir_link_uniforms.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index 7196d8b2c1f..7249829c564 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -105,16 +105,20 @@ nir_setup_uniform_remap_tables(struct gl_context *ctx,
       unsigned location =
          link_util_find_empty_block(prog, &prog->data->UniformStorage[i]);
 
-      if (location == -1) {
-         location = prog->NumUniformRemapTable;
+      if (location == -1 || location + entries >= prog->NumUniformRemapTable) {
+         unsigned new_entries = entries;
+         if (location == -1)
+            location = prog->NumUniformRemapTable;
+         else
+            new_entries = location - prog->NumUniformRemapTable + entries;
 
          /* resize remap table to fit new entries */
          prog->UniformRemapTable =
             reralloc(prog,
                      prog->UniformRemapTable,
                      struct gl_uniform_storage *,
-                     prog->NumUniformRemapTable + entries);
-         prog->NumUniformRemapTable += entries;
+                     prog->NumUniformRemapTable + new_entries);
+         prog->NumUniformRemapTable += new_entries;
       }
 
       /* set the base location in remap table for the uniform */



More information about the mesa-commit mailing list