From 27dec4a262332fa52e9f6ae685b3d807af9d6e15 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 10 Feb 2023 13:31:51 -0500 Subject: [PATCH] zink: add an io assignment pass for separate shaders usually this is handled by zink_compiler_assign_io() for full pipelines, where locations are compacted and variables are eliminated, but separate shaders still need to have "correct" locations set, which can be achieved by relying on 'location' instead of the (failed) attempt by the frontend to set 'driver_location' with nir_assign_io_var_locations() Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 8625b832ed1..4b0be67f560 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -4221,6 +4221,19 @@ type_images(nir_shader *nir, unsigned *sampler_mask) return progress; } +/* attempt to assign io for separate shaders */ +static bool +fixup_io_locations(nir_shader *nir) +{ + nir_variable_mode mode = nir->info.stage == MESA_SHADER_FRAGMENT ? nir_var_shader_in : nir_var_shader_out; + nir_foreach_variable_with_modes(var, nir, mode) { + if (nir_slot_is_varying(var->data.location)) + /* these locations should always be consistent between stages...hopefully */ + var->data.driver_location = var->data.location - VARYING_SLOT_VAR0; + } + return true; +} + struct zink_shader * zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, const struct pipe_stream_output_info *so_info) @@ -4254,6 +4267,10 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, if (nir->info.stage < MESA_SHADER_FRAGMENT) have_psiz = check_psiz(nir); + + if (!gl_shader_stage_is_compute(nir->info.stage) && nir->info.separate_shader) + NIR_PASS_V(nir, fixup_io_locations); + NIR_PASS_V(nir, lower_basevertex); NIR_PASS_V(nir, nir_lower_regs_to_ssa); NIR_PASS_V(nir, lower_baseinstance);