st/glsl_to_nir: dont add duplicate state tokens
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

This avoids adding duplicates that also won't be optimised as
the param optimise path is also skipped for variants.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13735
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37037>
This commit is contained in:
Timothy Arceri 2025-08-27 14:23:40 +10:00 committed by Marge Bot
parent 5231bbe32e
commit 891d46f517

View file

@ -113,10 +113,11 @@ st_nir_lookup_parameter_index(struct gl_program *prog, nir_variable *var)
}
static void
st_nir_assign_uniform_locations(struct gl_context *ctx,
st_nir_assign_uniform_locations(struct st_context *st,
struct gl_program *prog,
nir_shader *nir)
nir_shader *nir, bool is_before_variants)
{
struct gl_context *ctx = st->ctx;
int shaderidx = 0;
int imageidx = 0;
@ -134,6 +135,9 @@ st_nir_assign_uniform_locations(struct gl_context *ctx,
imageidx += type_size(uniform->type);
}
} else if (uniform->state_slots) {
if (st->allow_st_finalize_nir_twice && !is_before_variants)
continue;
const gl_state_index16 *const stateTokens = uniform->state_slots[0].tokens;
unsigned comps;
@ -698,7 +702,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
NIR_PASS(_, nir, nir_lower_tex, &opts);
}
st_nir_assign_uniform_locations(st->ctx, prog, nir);
st_nir_assign_uniform_locations(st, prog, nir, is_before_variants);
/* Set num_uniforms in number of attribute slots (vec4s) */
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);