From ae5a08de67b53cc4d40c7f2afa96996326a91bc5 Mon Sep 17 00:00:00 2001 From: timmac-qmc Date: Wed, 9 Aug 2023 09:44:02 +0100 Subject: [PATCH] glsl: fix potential crash with DisableUniformArrayResize We still need to gather information on uniform use when skipping uniform array resize. Fixes: ac5af6c0 ("util/driconf: add Dune: Spice Wars workaround") Reviewed-by: Timothy Arceri Part-of: --- src/compiler/glsl/gl_nir_link_uniforms.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 1e47bb1ff7c..b27f38577a2 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -1554,7 +1554,7 @@ gl_nir_link_uniforms(const struct gl_constants *consts, /* Iterate through all linked shaders */ struct nir_link_uniforms_state state = {0,}; - if (!prog->data->spirv && !consts->DisableUniformArrayResize) { + if (!prog->data->spirv) { /* Gather information on uniform use */ for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) { struct gl_linked_shader *sh = prog->_LinkedShaders[stage]; @@ -1569,14 +1569,16 @@ gl_nir_link_uniforms(const struct gl_constants *consts, add_var_use_shader(nir, state.referenced_uniforms[stage]); } - /* Resize uniform arrays based on the maximum array index */ - for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) { - struct gl_linked_shader *sh = prog->_LinkedShaders[stage]; - if (!sh) - continue; + if(!consts->DisableUniformArrayResize) { + /* Resize uniform arrays based on the maximum array index */ + for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) { + struct gl_linked_shader *sh = prog->_LinkedShaders[stage]; + if (!sh) + continue; - nir_foreach_gl_uniform_variable(var, sh->Program->nir) - update_array_sizes(prog, var, state.referenced_uniforms, stage); + nir_foreach_gl_uniform_variable(var, sh->Program->nir) + update_array_sizes(prog, var, state.referenced_uniforms, stage); + } } }