st/glsl: set driver location in nir_lower_alpha_test()

This previously worked because the driver locations would later
be set when st_nir_assign_uniform_locations() was called for a
second time but we will be skipping the extra call in a later patch.

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-09-01 15:20:37 +10:00 committed by Marge Bot
parent 450419c3f4
commit a73dab0af8
3 changed files with 20 additions and 6 deletions

View file

@ -47,7 +47,9 @@ typedef struct nir_lower_drawpixels_options {
bool st_nir_lower_alpha_test(struct nir_shader *shader, enum compare_func func,
bool alpha_to_one,
const gl_state_index16 *alpha_ref_state_tokens);
const gl_state_index16 *alpha_ref_state_tokens,
struct gl_program_parameter_list *paramList,
bool packed_driver_uniform_storage);
bool st_nir_lower_drawpixels(struct nir_shader *shader,
const nir_lower_drawpixels_options *options,

View file

@ -39,6 +39,8 @@ struct alpha_test_state {
bool alpha_to_one;
enum compare_func func;
const gl_state_index16 *alpha_ref_state_tokens;
struct gl_program_parameter_list *paramList;
bool packed_driver_uniform_storage;
};
static bool
@ -69,9 +71,13 @@ lower(nir_builder *b, nir_intrinsic_instr *intr, void *data)
else
alpha = nir_channel(b, intr->src[0].ssa, 3);
nir_variable *var = nir_state_variable_create(b->shader, glsl_float_type(),
"gl_AlphaRefMESA",
state->alpha_ref_state_tokens);
nir_variable *var =
st_nir_state_variable_create(b->shader, glsl_float_type(),
state->paramList,
state->alpha_ref_state_tokens,
"gl_AlphaRefMESA",
state->packed_driver_uniform_storage);
nir_def *alpha_ref = nir_load_var(b, var);
nir_def *condition = nir_compare_func(b, state->func, alpha, alpha_ref);
@ -83,13 +89,17 @@ lower(nir_builder *b, nir_intrinsic_instr *intr, void *data)
bool
st_nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
bool alpha_to_one,
const gl_state_index16 *alpha_ref_state_tokens)
const gl_state_index16 *alpha_ref_state_tokens,
struct gl_program_parameter_list *paramList,
bool packed_driver_uniform_storage)
{
assert(shader->info.io_lowered);
struct alpha_test_state state = {
.alpha_ref_state_tokens = alpha_ref_state_tokens,
.alpha_to_one = alpha_to_one,
.func = func,
.paramList = paramList,
.packed_driver_uniform_storage = packed_driver_uniform_storage,
};
return nir_shader_intrinsics_pass(shader, lower,

View file

@ -1082,7 +1082,9 @@ st_create_fp_variant(struct st_context *st,
if (key->lower_alpha_func != COMPARE_FUNC_ALWAYS) {
_mesa_add_state_reference(params, alpha_ref_state);
NIR_PASS(_, state.ir.nir, st_nir_lower_alpha_test, key->lower_alpha_func,
false, alpha_ref_state);
false, alpha_ref_state,
st->allow_st_finalize_nir_twice ? fp->Parameters : NULL,
st->ctx->Const.PackedDriverUniformStorage);
finalize = true;
}