From 9b4fc64324cade85b566a5032cd771f856fec082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 16 Nov 2025 10:22:54 -0500 Subject: [PATCH] nir/lower_io_passes: simplify conditions for when to lower IO to temps Reviewed-by: Alyssa Rosenzweig Reviewed-by: Iago Toral Quiroga Part-of: --- src/compiler/nir/nir_lower_io.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 817f1f169aa..83c5c646ba0 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -1215,22 +1215,6 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_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. */ - bool lower_indirect_outputs = - !(nir->options->support_indirect_outputs & BITFIELD_BIT(nir->info.stage)) || - nir->xfb_info; - - /* TODO: This is a hack until a better solution is available. - * For all shaders except TCS, lower all outputs to temps because: - * - there can be output loads (nobody expects those outside of TCS) - * - drivers don't expect when an output is only written in control flow - * - * "lower_indirect_outputs = true" causes all outputs to be lowered to temps, - * which lowers indirect stores, eliminates output loads, and moves all - * output stores to the end or GS emits. - */ - lower_indirect_outputs = true; - /* If the driver doesn't support indirect TCS output slot access, lower * it to an if-else tree of direct accesses. */ @@ -1255,7 +1239,16 @@ nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs) (nir->info.stage != MESA_SHADER_FRAGMENT ? nir_var_shader_out : 0); nir_sort_variables_by_location(nir, varying_var_mask); - if (lower_indirect_outputs) { + /* For VS, TES, GS, FS: Always lower all outputs to temps, which: + * - lowers output loads (nobody expects those outside of TCS & MS) + * - lowers indirect output slot indexing (also XFB info can't be stored + * in indirect IO intrinsics) + * - moves output stores to the end or GS emits + */ + if (nir->info.stage == MESA_SHADER_VERTEX || + nir->info.stage == MESA_SHADER_TESS_EVAL || + nir->info.stage == MESA_SHADER_GEOMETRY || + nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), nir_var_shader_out);