From b713f453c62e9a246e566bd854c722fef3e27398 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Wed, 25 Jun 2025 13:49:15 +0800 Subject: [PATCH] radeonsi: lower mesh shader local id and workgroup id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_shader_nir.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 5401d8dc768..2f56b1c355f 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -369,6 +369,22 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir) } } + if (nir->info.stage == MESA_SHADER_MESH && !sscreen->info.mesh_fast_launch_2) { + nir_lower_compute_system_values_options options = { + /* Mesh shaders run as NGG which can implement local_invocation_index from + * the wave ID in merged_wave_info, but they don't have local_invocation_ids + * in FAST_LAUNCH=1 mode (the default on GFX10.3, deprecated on GFX11). + */ + .lower_cs_local_id_to_index = true, + /* Mesh shaders only have a 1D "vertex index" which we use + * as "workgroup index" to emulate the 3D workgroup ID. + */ + .lower_workgroup_id_to_index = true, + .shortcut_1d_workgroup_id = true, + }; + NIR_PASS(_, nir, nir_lower_compute_system_values, &options); + } + si_nir_opts(sscreen, nir, true); /* Run late optimizations to fuse ffma and eliminate 16-bit conversions. */ si_nir_late_opts(nir);