Mesa (master): glsl: some nir uniform linker fixes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 24 08:48:33 UTC 2020


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

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Thu Apr 23 15:55:14 2020 +1000

glsl: some nir uniform linker fixes

This fixes find_and_update_named_uniform_storage() for subroutines
and also updates num_shader_uniform_components for non opaque
uniforms.

The following patch will ensure this type of bug won't happen again.

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

---

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

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index 175af7c7edb..6e24647d586 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -466,13 +466,13 @@ struct nir_link_uniforms_state {
    unsigned num_hidden_uniforms;
    unsigned num_values;
    unsigned max_uniform_location;
-   unsigned next_subroutine;
 
    /* per-shader stage */
    unsigned next_bindless_image_index;
    unsigned next_bindless_sampler_index;
    unsigned next_image_index;
    unsigned next_sampler_index;
+   unsigned next_subroutine;
    unsigned num_shader_samplers;
    unsigned num_shader_images;
    unsigned num_shader_uniform_components;
@@ -770,6 +770,23 @@ find_and_update_named_uniform_storage(struct gl_context *ctx,
 
             if (!uniform->is_shader_storage)
                state->num_shader_uniform_components += values;
+         } else {
+            if (glsl_get_base_type(type_no_array) == GLSL_TYPE_SUBROUTINE) {
+               struct gl_linked_shader *sh = prog->_LinkedShaders[stage];
+
+               uniform->opaque[stage].index = state->next_subroutine;
+               uniform->opaque[stage].active = true;
+
+               sh->Program->sh.NumSubroutineUniforms++;
+
+               /* Increment the subroutine index by 1 for non-arrays and by the
+                * number of array elements for arrays.
+                */
+               state->next_subroutine += MAX2(1, uniform->array_elements);
+            }
+
+            if (!state->var_is_in_block)
+               state->num_shader_uniform_components += values;
          }
 
          struct hash_entry *entry =



More information about the mesa-commit mailing list