glsl: dont try to assign uniform storage for uniform blocks
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 28 Jan 2020 04:18:14 +0000 (15:18 +1100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 6 Mar 2020 23:22:14 +0000 (23:22 +0000)
Fixes a crash in some shaders.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4050>

src/compiler/glsl/gl_nir_link_uniforms.c

index ec0c7afca5526b100093545be594a667d2703ce7..f57d2e9a3dab2d3a0d16e2e45acca9d53bc52680 100644 (file)
@@ -132,14 +132,16 @@ nir_setup_uniform_remap_tables(struct gl_context *ctx,
 
       unsigned num_slots = glsl_get_component_slots(uniform->type);
 
-      uniform->storage = &data[data_pos];
+      if (uniform->block_index == -1)
+         uniform->storage = &data[data_pos];
 
       /* Set remap table entries point to correct gl_uniform_storage. */
       for (unsigned j = 0; j < entries; j++) {
          unsigned element_loc = uniform->remap_location + j;
          prog->UniformRemapTable[element_loc] = uniform;
 
-         data_pos += num_slots;
+         if (uniform->block_index == -1)
+            data_pos += num_slots;
       }
    }
 }