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 <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24576>
This commit is contained in:
timmac-qmc 2023-08-09 09:44:02 +01:00 committed by Marge Bot
parent 5c70a55bf3
commit ae5a08de67

View file

@ -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);
}
}
}