mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-14 06:30:26 +01:00
st/glsl_to_nir: make sure the variant has the correct locations set
For drivers that set allow_st_finalize_nir_twice locations are set
when the variable is created. But for variants here we update the
locations in case parameter opt pass or something else changed the
location.
Fixes: 891d46f517 ("st/glsl_to_nir: dont add duplicate state tokens")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14837
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39867>
This commit is contained in:
parent
c3aae0714c
commit
a6fcc2835e
1 changed files with 15 additions and 5 deletions
|
|
@ -115,7 +115,7 @@ st_nir_lookup_parameter_index(struct gl_program *prog, nir_variable *var)
|
|||
static void
|
||||
st_nir_assign_uniform_locations(struct st_context *st,
|
||||
struct gl_program *prog,
|
||||
nir_shader *nir, bool is_before_variants)
|
||||
nir_shader *nir)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
int shaderidx = 0;
|
||||
|
|
@ -135,10 +135,20 @@ st_nir_assign_uniform_locations(struct st_context *st,
|
|||
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;
|
||||
if (st->allow_st_finalize_nir_twice) {
|
||||
/* Make sure the variant has the correct locations set */
|
||||
loc = _mesa_lookup_state_param_idx(prog->Parameters, stateTokens);
|
||||
if (loc >= 0) {
|
||||
if (ctx->Const.PackedDriverUniformStorage) {
|
||||
uniform->data.driver_location =
|
||||
prog->Parameters->Parameters[loc].ValueOffset;
|
||||
} else
|
||||
uniform->data.driver_location = loc;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned comps;
|
||||
if (glsl_type_is_struct_or_ifc(type)) {
|
||||
|
|
@ -735,7 +745,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, prog, nir, is_before_variants);
|
||||
st_nir_assign_uniform_locations(st, prog, nir);
|
||||
|
||||
/* Set num_uniforms in number of attribute slots (vec4s) */
|
||||
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue