Mesa (main): glsl/nir: skip adding hidden uniforms to the remap tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jun 4 03:57:00 UTC 2022


Module: Mesa
Branch: main
Commit: 4488b577a18e51ccb0dc229499bc2bf50255d044
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4488b577a18e51ccb0dc229499bc2bf50255d044

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Tue Oct 12 13:38:46 2021 +1100

glsl/nir: skip adding hidden uniforms to the remap tables

The remap tables are used with the GL API so there is no need to
add hidden uniforms to them. Also when we switch to lowering some
constant arrays to uniforms in NIR in a following patch there
will no longer be enough room in the tables as we assign their
size in the GLSL IR linker not the NIR linker currently.

Acked-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16770>

---

 src/compiler/glsl/gl_nir_link_uniforms.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index aa77225600b..cc223b9fafb 100644
--- a/src/compiler/glsl/gl_nir_link_uniforms.c
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -211,6 +211,9 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts,
    for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
       struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i];
 
+      if (uniform->hidden)
+         continue;
+
       if (uniform->is_shader_storage ||
           glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE)
          continue;
@@ -240,6 +243,9 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts,
    for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
       struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i];
 
+      if (uniform->hidden)
+         continue;
+
       if (uniform->is_shader_storage ||
           glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE)
          continue;
@@ -383,6 +389,24 @@ nir_setup_uniform_remap_tables(const struct gl_constants *consts,
          p->sh.NumSubroutineUniformRemapTable += entries;
       }
    }
+
+   /* assign storage to hidden uniforms */
+   for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+      struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i];
+
+      if (!uniform->hidden ||
+          glsl_get_base_type(uniform->type) == GLSL_TYPE_SUBROUTINE)
+         continue;
+
+      const unsigned entries =
+         MAX2(1, prog->data->UniformStorage[i].array_elements);
+
+      uniform->storage = &data[data_pos];
+
+      unsigned num_slots = glsl_get_component_slots(uniform->type);
+      for (unsigned k = 0; k < entries; k++)
+         data_pos += num_slots;
+   }
 }
 
 static void



More information about the mesa-commit mailing list