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>
(cherry picked from commit ae5a08de67)
This commit is contained in:
timmac-qmc 2023-08-09 09:44:02 +01:00 committed by Dylan Baker
parent da9cf451f5
commit b69bf84d23
2 changed files with 11 additions and 9 deletions

View file

@ -9034,7 +9034,7 @@
"description": "glsl: fix potential crash with DisableUniformArrayResize",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "ac5af6c06d867507284121f31ddbabf07f7e29f4",
"notes": null

View file

@ -1526,7 +1526,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];
@ -1541,14 +1541,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);
}
}
}