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

Author: Timothy Arceri <[email protected]>
Date:   Mon Jan 13 16:09:10 2020 +1100

glsl: count uniform components and storage better in nir linking

This helps avoid incorrect validation error when linking glsl
shaders and avoids assigning uniform storage slots that will
never be used.

Reviewed-by: Alejandro PiƱeiro <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3468>

---

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

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c 
b/src/compiler/glsl/gl_nir_link_uniforms.c
index 97bd57fc2b8..1a6a4fc07a6 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -601,6 +601,7 @@ nir_link_uniform(struct gl_context *ctx,
       uniform->num_compatible_subroutines = 0;
 
       unsigned entries = MAX2(1, uniform->array_elements);
+      unsigned values = glsl_get_component_slots(type);
 
       if (glsl_type_is_sampler(type_no_array)) {
          int sampler_index =
@@ -621,6 +622,8 @@ nir_link_uniform(struct gl_context *ctx,
             state->shader_samplers_used |= 1U << i;
             state->shader_shadow_samplers |= shadow << i;
          }
+
+         state->num_values += values;
       } else if (glsl_type_is_image(type_no_array)) {
          /* @FIXME: image_index should match that of the same image
           * uniform in other shaders. This means we need to match image
@@ -649,11 +652,17 @@ nir_link_uniform(struct gl_context *ctx,
               i++) {
             stage_program->sh.ImageAccess[i] = access;
          }
-      }
 
-      unsigned values = glsl_get_component_slots(type);
-      state->num_shader_uniform_components += values;
-      state->num_values += values;
+         if (!uniform->is_shader_storage) {
+            state->num_shader_uniform_components += values;
+            state->num_values += values;
+         }
+      } else {
+         if (!state->var_is_in_block) {
+            state->num_shader_uniform_components += values;
+            state->num_values += values;
+         }
+      }
 
       if (uniform->remap_location != UNMAPPED_UNIFORM_LOC &&
           state->max_uniform_location < uniform->remap_location + entries)

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to