Mesa (master): glsl: fix block index in NIR uniform linker

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 18 12:15:31 UTC 2020


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

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Tue Mar 10 12:55:53 2020 +1100

glsl: fix block index in NIR uniform linker

We only want to set the index for the first block of an array. Also
add a comment about why we do not break here.

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

---

 src/compiler/glsl/gl_nir_link_uniforms.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index de168eb1a3a..aa390ddf1cb 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -1269,10 +1269,16 @@ gl_nir_link_uniforms(struct gl_context *ctx,
 
             if (is_interface_array) {
                unsigned l = strlen(ifc_name);
+
+               /* Even when a match is found, do not "break" here.  As this is
+                * an array of instances, all elements of the array need to be
+                * marked as referenced.
+                */
                for (unsigned i = 0; i < num_blocks; i++) {
                   if (strncmp(ifc_name, blocks[i].Name, l) == 0 &&
                       blocks[i].Name[l] == '[') {
-                     buffer_block_index = i;
+                     if (buffer_block_index == -1)
+                        buffer_block_index = i;
 
                      blocks[i].stageref |= 1U << shader_type;
                   }



More information about the mesa-commit mailing list