nir: Add a nir_foreach_gl_uniform_variable helper for GL linking
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 20 Jul 2020 19:09:50 +0000 (14:09 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:38:58 +0000 (17:38 +0000)
There are a bunch of cases where we really do want to walk the list that
is nir->uniforms because we want all things declared "uniform" in the
GLSL.  Add a helper for this but restrict it to the GL linking code.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>

src/compiler/glsl/gl_nir_link_uniform_initializers.c
src/compiler/glsl/gl_nir_link_uniforms.c
src/compiler/glsl/gl_nir_linker.h

index fe01b5cb26853e6bcc03a8cad019c9893a130c04..6cbc7984eb5b66ddd1ecc869f7377f041d44400f 100644 (file)
@@ -265,7 +265,7 @@ gl_nir_set_uniform_initializers(struct gl_context *ctx,
       nir_shader *nir = sh->Program->nir;
       assert(nir);
 
-      nir_foreach_variable(var, &nir->uniforms) {
+      nir_foreach_gl_uniform_variable(var, nir) {
          if (var->constant_initializer) {
             struct set_uniform_initializer_closure data = {
                .shader_prog = prog,
index 270add9e08e81945d37d47e977037fdd70e8cff3..05b70a965077a25703ae43f3ffb4a76176078d85 100644 (file)
@@ -1515,8 +1515,7 @@ gl_nir_link_uniforms(struct gl_context *ctx,
          if (!sh)
             continue;
 
-         nir_shader *nir = sh->Program->nir;
-         nir_foreach_variable(var, &nir->uniforms)
+         nir_foreach_gl_uniform_variable(var, sh->Program->nir)
             update_array_sizes(prog, var, state.referenced_uniforms, stage);
       }
    }
@@ -1531,7 +1530,7 @@ gl_nir_link_uniforms(struct gl_context *ctx,
          if (!sh)
             continue;
 
-         nir_foreach_variable(var, &sh->Program->nir->uniforms) {
+         nir_foreach_gl_uniform_variable(var, sh->Program->nir) {
             const struct glsl_type *type = var->type;
             const char *name = var->name;
             if (nir_variable_is_in_block(var) &&
@@ -1582,7 +1581,7 @@ gl_nir_link_uniforms(struct gl_context *ctx,
       state.shader_shadow_samplers = 0;
       state.params = fill_parameters ? sh->Program->Parameters : NULL;
 
-      nir_foreach_variable(var, &nir->uniforms) {
+      nir_foreach_gl_uniform_variable(var, nir) {
          state.current_var = var;
          state.current_ifc_type = NULL;
          state.offset = 0;
index 9dae03779b91a699afd500cb892733b6fce2b9ca..8240d5f9162656eed0bb64906e023a9e4cf7ad6a 100644 (file)
@@ -35,6 +35,9 @@ struct gl_nir_linker_options {
    bool fill_parameters;
 };
 
+#define nir_foreach_gl_uniform_variable(var, shader) \
+   nir_foreach_variable(var, &(shader)->uniforms)
+
 bool gl_nir_link_spirv(struct gl_context *ctx,
                        struct gl_shader_program *prog,
                        const struct gl_nir_linker_options *options);