From 3d9a5ee95da3f893029ed1d522bc153bb147c977 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 1 Sep 2025 11:12:50 +1000 Subject: [PATCH] st/glsl: set driver locations in nir_lower_drawpixels() 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 Part-of: --- src/mesa/state_tracker/st_nir.h | 4 ++- .../state_tracker/st_nir_lower_drawpixels.c | 27 +++++++++++++------ src/mesa/state_tracker/st_program.c | 4 ++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h index 548eb5ffba0..a6e6eff3f33 100644 --- a/src/mesa/state_tracker/st_nir.h +++ b/src/mesa/state_tracker/st_nir.h @@ -46,7 +46,9 @@ typedef struct nir_lower_drawpixels_options { } nir_lower_drawpixels_options; bool st_nir_lower_drawpixels(struct nir_shader *shader, - const nir_lower_drawpixels_options *options); + const nir_lower_drawpixels_options *options, + struct gl_program_parameter_list *paramList, + bool packed_driver_uniform_storage); bool st_nir_lower_builtin(struct nir_shader *shader); bool st_nir_lower_tex_src_plane(struct nir_shader *shader, unsigned free_slots, diff --git a/src/mesa/state_tracker/st_nir_lower_drawpixels.c b/src/mesa/state_tracker/st_nir_lower_drawpixels.c index fafcaca2c36..5c45f8e55c2 100644 --- a/src/mesa/state_tracker/st_nir_lower_drawpixels.c +++ b/src/mesa/state_tracker/st_nir_lower_drawpixels.c @@ -33,6 +33,8 @@ typedef struct { const nir_lower_drawpixels_options *options; nir_shader *shader; nir_variable *texcoord_const, *scale, *bias, *tex, *pixelmap; + struct gl_program_parameter_list *paramList; + bool packed_driver_uniform_storage; } lower_drawpixels_state; static nir_def * @@ -48,8 +50,10 @@ static nir_def * get_scale(nir_builder *b, lower_drawpixels_state *state) { if (state->scale == NULL) { - state->scale = nir_state_variable_create(state->shader, glsl_vec4_type(), "gl_PTscale", - state->options->scale_state_tokens); + state->scale = + st_nir_state_variable_create(state->shader, glsl_vec4_type(), state->paramList, + state->options->scale_state_tokens, + "gl_PTscale", state->packed_driver_uniform_storage); } return nir_load_var(b, state->scale); } @@ -58,8 +62,10 @@ static nir_def * get_bias(nir_builder *b, lower_drawpixels_state *state) { if (state->bias == NULL) { - state->bias = nir_state_variable_create(state->shader, glsl_vec4_type(), "gl_PTbias", - state->options->bias_state_tokens); + state->bias = + st_nir_state_variable_create(state->shader, glsl_vec4_type(), state->paramList, + state->options->bias_state_tokens, + "gl_PTbias", state->packed_driver_uniform_storage); } return nir_load_var(b, state->bias); } @@ -68,9 +74,10 @@ static nir_def * get_texcoord_const(nir_builder *b, lower_drawpixels_state *state) { if (state->texcoord_const == NULL) { - state->texcoord_const = nir_state_variable_create(state->shader, glsl_vec4_type(), - "gl_MultiTexCoord0", - state->options->texcoord_state_tokens); + state->texcoord_const = + st_nir_state_variable_create(state->shader, glsl_vec4_type(), state->paramList, + state->options->texcoord_state_tokens, + "gl_MultiTexCoord0", state->packed_driver_uniform_storage); } return nir_load_var(b, state->texcoord_const); } @@ -212,13 +219,17 @@ lower_drawpixels_instr(nir_builder *b, nir_instr *instr, void *cb_data) bool st_nir_lower_drawpixels(nir_shader *shader, - const nir_lower_drawpixels_options *options) + const nir_lower_drawpixels_options *options, + struct gl_program_parameter_list *paramList, + bool packed_driver_uniform_storage) { assert(shader->info.io_lowered); lower_drawpixels_state state = { .options = options, .shader = shader, + .paramList = paramList, + .packed_driver_uniform_storage = packed_driver_uniform_storage, }; assert(shader->info.stage == MESA_SHADER_FRAGMENT); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 610c2610f1f..3ebd5c7d262 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1155,7 +1155,9 @@ st_create_fp_variant(struct st_context *st, memcpy(options.texcoord_state_tokens, texcoord_state, sizeof(options.texcoord_state_tokens)); - NIR_PASS(_, state.ir.nir, st_nir_lower_drawpixels, &options); + NIR_PASS(_, state.ir.nir, st_nir_lower_drawpixels, &options, + st->allow_st_finalize_nir_twice ? fp->Parameters : NULL, + st->ctx->Const.PackedDriverUniformStorage); finalize = true; }