Mesa (master): glsl: small optimisation fix for uniform array resizing

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 17 01:22:38 UTC 2020


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

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Mon Jun 15 14:25:21 2020 +1000

glsl: small optimisation fix for uniform array resizing

The fix in the previous patch removed an erronous attempt to skip
resizing variable types in each stage. Now that has been removed
iterating over each shader stage is no longer required here.

Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5487>

---

 src/compiler/glsl/gl_nir_link_uniforms.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index 78fee5b75b4..270add9e08e 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -97,7 +97,8 @@ uniform_storage_size(const struct glsl_type *type)
  */
 static void
 update_array_sizes(struct gl_shader_program *prog, nir_variable *var,
-                   struct hash_table **referenced_uniforms)
+                   struct hash_table **referenced_uniforms,
+                   unsigned current_var_stage)
 {
    /* For now we only resize 1D arrays.
     * TODO: add support for resizing more complex array types ??
@@ -160,19 +161,13 @@ update_array_sizes(struct gl_shader_program *prog, nir_variable *var,
                                   max_array_size, 0);
 
       /* Update the types of dereferences in case we changed any. */
-      for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
-         struct gl_linked_shader *sh = prog->_LinkedShaders[stage];
-         if (!sh)
-            continue;
-
-         struct hash_entry *entry =
-            _mesa_hash_table_search(referenced_uniforms[stage], var->name);
-         if (entry) {
-            struct uniform_array_info *ainfo =
-               (struct uniform_array_info *) entry->data;
-            util_dynarray_foreach(ainfo->deref_list, nir_deref_instr *, deref) {
-               (*deref)->type = var->type;
-            }
+      struct hash_entry *entry =
+         _mesa_hash_table_search(referenced_uniforms[current_var_stage], var->name);
+      if (entry) {
+         struct uniform_array_info *ainfo =
+            (struct uniform_array_info *) entry->data;
+         util_dynarray_foreach(ainfo->deref_list, nir_deref_instr *, deref) {
+            (*deref)->type = var->type;
          }
       }
    }
@@ -1522,7 +1517,7 @@ gl_nir_link_uniforms(struct gl_context *ctx,
 
          nir_shader *nir = sh->Program->nir;
          nir_foreach_variable(var, &nir->uniforms)
-            update_array_sizes(prog, var, state.referenced_uniforms);
+            update_array_sizes(prog, var, state.referenced_uniforms, stage);
       }
    }
 



More information about the mesa-commit mailing list