From 89285e25b62ad8d61d1ca796052761afa73bd00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 4 Jul 2025 13:13:12 -0400 Subject: [PATCH] nir: remove nir_shader_compiler_options::lower_all_io_to_temps All drivers should report support_indirect_* correctly, so this is redundant. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/broadcom/compiler/nir_to_vir.c | 10 ++-------- src/broadcom/vulkan/v3dv_pipeline.c | 1 - src/compiler/glsl/gl_nir_linker.c | 1 - src/compiler/nir/nir_shader_compiler_options.h | 3 --- src/freedreno/ir3/ir3_nir_move_varying_inputs.c | 3 +-- src/gallium/drivers/etnaviv/etnaviv_compiler.c | 1 - src/gallium/drivers/freedreno/a2xx/ir2_nir.c | 1 - src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 5 +---- .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 1 - src/gallium/drivers/r600/r600_pipe_common.c | 1 - src/gallium/drivers/v3d/v3d_screen.c | 1 - src/gallium/drivers/vc4/vc4_program.c | 1 - 12 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index d4df34edd53..c4d49608a29 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -2769,14 +2769,8 @@ ntq_emit_load_input(struct v3d_compile *c, nir_intrinsic_instr *instr) { /* XXX: Use ldvpmv (uniform offset) or ldvpmd (non-uniform offset). * - * Right now the driver sets support_indirect_inputs even - * if we don't support non-uniform offsets because we also set the - * lower_all_io_to_temps option in the NIR compiler. This ensures that - * any indirect indexing on in/out variables is turned into indirect - * indexing on temporary variables instead, that we handle by lowering - * to scratch. If we implement non-uniform offset here we might be able - * to avoid the temp and scratch lowering, which involves copying from - * the input to the temp variable, possibly making code more optimal. + * Indirect indexing is lowered by the GLSL compiler based on + * support_indirect_inputs. */ unsigned offset = nir_intrinsic_base(instr) + nir_src_as_uint(instr->src[0]); diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index d04a6beab04..28058489f2b 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -162,7 +162,6 @@ v3dv_pipeline_get_nir_options(const struct v3d_device_info *devinfo) .lower_uadd_sat = true, .lower_usub_sat = true, .lower_iadd_sat = true, - .lower_all_io_to_temps = true, .lower_extract_byte = true, .lower_extract_word = true, .lower_insert_byte = true, diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 168bd254d3f..6ecc6ac30e6 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1328,7 +1328,6 @@ preprocess_shader(const struct gl_constants *consts, NIR_PASS(_, nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, - options->lower_all_io_to_temps || nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_GEOMETRY); diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 122012ead7a..fc8b984e078 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -355,9 +355,6 @@ typedef struct nir_shader_compiler_options { bool lower_insert_byte; bool lower_insert_word; - /* TODO: this flag is potentially useless, remove? */ - bool lower_all_io_to_temps; - /* Indicates that the driver only has zero-based vertex id */ bool vertex_id_zero_based; diff --git a/src/freedreno/ir3/ir3_nir_move_varying_inputs.c b/src/freedreno/ir3/ir3_nir_move_varying_inputs.c index 3d2cde591a6..370788e90e9 100644 --- a/src/freedreno/ir3/ir3_nir_move_varying_inputs.c +++ b/src/freedreno/ir3/ir3_nir_move_varying_inputs.c @@ -13,8 +13,7 @@ * We need to set the (ei) "end input" flag on the last varying fetch. * And we want to ensure that all threads execute the instruction that * sets (ei). The easiest way to ensure this is to move all varying - * fetches into the start block. Which is something we used to get for - * free by using lower_all_io_to_temps=true. + * fetches into the start block. * * This may come at the cost of additional register usage. OTOH setting * the (ei) flag earlier probably frees up more VS to run. diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index 61daec95db4..5a5df3fce04 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -50,7 +50,6 @@ etna_compiler_create(const char *renderer, const struct etna_core_info *info) .lower_ldexp = true, .lower_mul_high = true, .lower_bitops = true, - .lower_all_io_to_temps = true, .lower_flrp32 = true, .lower_fmod = true, .lower_vector_cmp = true, diff --git a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c index bca17a3c051..56b92d2c3a3 100644 --- a/src/gallium/drivers/freedreno/a2xx/ir2_nir.c +++ b/src/gallium/drivers/freedreno/a2xx/ir2_nir.c @@ -23,7 +23,6 @@ static const nir_shader_compiler_options options = { .fuse_ffma32 = true, .fuse_ffma64 = true, /* .fdot_replicates = true, it is replicated, but it makes things worse */ - .lower_all_io_to_temps = true, .vertex_id_zero_based = true, /* its not implemented anyway */ .lower_bitops = true, .lower_vector_cmp = true, diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 8d36187a8b5..7f7f8e6d9f4 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -113,8 +113,6 @@ load_glsl(unsigned num_files, char *const *files, gl_shader_stage stage) .lower_precision = true, }; struct gl_shader_program *prog; - const nir_shader_compiler_options *nir_options = - ir3_get_compiler_options(compiler); static struct gl_context local_ctx; prog = standalone_compile_shader(&options, num_files, files, &local_ctx); @@ -124,8 +122,7 @@ load_glsl(unsigned num_files, char *const *files, gl_shader_stage stage) nir_shader *nir = prog->_LinkedShaders[stage]->Program->nir; /* required NIR passes: */ - if (nir_options->lower_all_io_to_temps || - nir->info.stage == MESA_SHADER_VERTEX || + if (nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_GEOMETRY) { NIR_PASS_V(nir, nir_lower_io_vars_to_temporaries, nir_shader_get_entrypoint(nir), true, true); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp index 74226afdd1e..9227ad2c874 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp @@ -3614,7 +3614,6 @@ nvir_nir_shader_compiler_options(int chipset, uint8_t shader_type) op.lower_extract_word = (chipset < NVISA_GM107_CHIPSET); op.lower_insert_byte = true; op.lower_insert_word = true; - op.lower_all_io_to_temps = false; op.vertex_id_zero_based = false; op.lower_base_vertex = false; op.lower_helper_invocation = false; diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c index 23dfc2ca7f5..1ff16d6afa0 100644 --- a/src/gallium/drivers/r600/r600_pipe_common.c +++ b/src/gallium/drivers/r600/r600_pipe_common.c @@ -1219,7 +1219,6 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, } rscreen->nir_options_fs = rscreen->nir_options; - rscreen->nir_options_fs.lower_all_io_to_temps = true; rscreen->nir_options.support_indirect_inputs = BITFIELD_BIT(PIPE_SHADER_TESS_CTRL); rscreen->nir_options.support_indirect_outputs = BITFIELD_BIT(PIPE_SHADER_TESS_CTRL); diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 76883e1c172..dc901e4addc 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -546,7 +546,6 @@ v3d_screen_get_compiler_options(struct pipe_screen *pscreen, .lower_uadd_sat = true, .lower_usub_sat = true, .lower_iadd_sat = true, - .lower_all_io_to_temps = true, .lower_extract_byte = true, .lower_extract_word = true, .lower_insert_byte = true, diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index f4dc50a1b24..c6138fe4d57 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -2156,7 +2156,6 @@ nir_to_qir(struct vc4_compile *c) } static const nir_shader_compiler_options nir_options = { - .lower_all_io_to_temps = true, .lower_extract_byte = true, .lower_extract_word = true, .lower_insert_byte = true,