glsl: fix block index in NIR uniform linker
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 10 Mar 2020 01:55:53 +0000 (12:55 +1100)
committerMarge Bot <eric+marge@anholt.net>
Sat, 18 Apr 2020 11:50:44 +0000 (11:50 +0000)
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@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4623>

src/compiler/glsl/gl_nir_link_uniforms.c

index de168eb1a3a0fa5c4fe4703a5ca7a3a4951f3f1f..aa390ddf1cb19a6aad7829e04a4bfde1bbd1ffa0 100644 (file)
@@ -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;
                   }