From 7c3f7e10468e335977bc1b0b5ab808a1aef7849c Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Tue, 15 Jul 2025 10:09:08 +0800 Subject: [PATCH] nir: lower io support task and mesh shader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mesh shader does not have input, and we skip task shader IO lowering like compute shader. Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_lower_io.c | 12 +++++++++--- src/mesa/state_tracker/st_program.c | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index e54b805c9be..71265a5c1e3 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -1137,10 +1137,12 @@ type_size_vec4(const struct glsl_type *type, bool bindless) void nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs) { - if (mesa_shader_stage_is_compute(nir->info.stage)) + if (mesa_shader_stage_is_compute(nir->info.stage) || + nir->info.stage == MESA_SHADER_TASK) return; bool lower_indirect_inputs = + nir->info.stage != MESA_SHADER_MESH && !(nir->options->support_indirect_inputs & BITFIELD_BIT(nir->info.stage)); /* Transform feedback requires that indirect outputs are lowered. */ @@ -1169,7 +1171,8 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs) * must sort explicitly here to get what nir_assign_io_var_locations does. */ unsigned varying_var_mask = - (nir->info.stage != MESA_SHADER_VERTEX ? nir_var_shader_in : 0) | + (nir->info.stage != MESA_SHADER_VERTEX && + nir->info.stage != MESA_SHADER_MESH ? nir_var_shader_in : 0) | (nir->info.stage != MESA_SHADER_FRAGMENT ? nir_var_shader_out : 0); nir_sort_variables_by_location(nir, varying_var_mask); @@ -1228,8 +1231,11 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs) * * This must be done after DCE to remove dead load_input intrinsics. */ + bool recompute_inputs = + (nir->info.stage != MESA_SHADER_VERTEX || renumber_vs_inputs) && + nir->info.stage != MESA_SHADER_MESH; NIR_PASS(_, nir, nir_recompute_io_bases, - (nir->info.stage != MESA_SHADER_VERTEX || renumber_vs_inputs ? nir_var_shader_in : 0) | nir_var_shader_out); + (recompute_inputs ? nir_var_shader_in : 0) | nir_var_shader_out); if (nir->xfb_info) NIR_PASS(_, nir, nir_io_add_intrinsic_xfb_info); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index e6d2cdb4fb2..316e68f909f 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -804,6 +804,7 @@ st_create_common_variant(struct st_context *st, } assert(state.ir.nir->info.stage == MESA_SHADER_COMPUTE || + state.ir.nir->info.stage == MESA_SHADER_TASK || state.ir.nir->info.io_lowered); /* This should be after all passes that touch IO. */