From: Jason Ekstrand Date: Mon, 20 Jul 2020 19:09:50 +0000 (-0500) Subject: nir: Add a nir_foreach_gl_uniform_variable helper for GL linking X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3e1c50067e0a1e219bc4d30333b953c6baa0c08;p=mesa.git nir: Add a nir_foreach_gl_uniform_variable helper for GL linking 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 Reviewed-by: Timothy Arceri Part-of: --- diff --git a/src/compiler/glsl/gl_nir_link_uniform_initializers.c b/src/compiler/glsl/gl_nir_link_uniform_initializers.c index fe01b5cb268..6cbc7984eb5 100644 --- a/src/compiler/glsl/gl_nir_link_uniform_initializers.c +++ b/src/compiler/glsl/gl_nir_link_uniform_initializers.c @@ -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, diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 270add9e08e..05b70a96507 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -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; diff --git a/src/compiler/glsl/gl_nir_linker.h b/src/compiler/glsl/gl_nir_linker.h index 9dae03779b9..8240d5f9162 100644 --- a/src/compiler/glsl/gl_nir_linker.h +++ b/src/compiler/glsl/gl_nir_linker.h @@ -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);