From 57e465a3e4f1d618dc1d209e485f2bba4f3dc7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 25 Apr 2026 14:04:21 -0400 Subject: [PATCH] aco,radeonsi: don't forward LINE_STIPPLE_TEX_ENA VGPR from the PS prolog It's unused. This frees 1 VGPR in the prolog for temps. This only affects radeonsi. --- .../instruction_selection/aco_select_ps_prolog.cpp | 10 +++++++++- src/gallium/drivers/radeonsi/si_shader_llvm_ps.c | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/instruction_selection/aco_select_ps_prolog.cpp b/src/amd/compiler/instruction_selection/aco_select_ps_prolog.cpp index a64a9bc1dc5..0118fa5b3a6 100644 --- a/src/amd/compiler/instruction_selection/aco_select_ps_prolog.cpp +++ b/src/amd/compiler/instruction_selection/aco_select_ps_prolog.cpp @@ -174,8 +174,16 @@ passthrough_all_args(isel_context* ctx, std::vector& regs) struct ac_arg arg; arg.used = true; - for (arg.arg_index = 0; arg.arg_index < ctx->args->arg_count; arg.arg_index++) + for (arg.arg_index = 0; arg.arg_index < ctx->args->arg_count; arg.arg_index++) { + /* Don't pass LINE_STIPPLE_TEX_ENA to the next shader binary because it's unused. + * This saves 1 VGPR in the prolog. + */ + if (ctx->args->line_stipple_tex_ena.used && + arg.arg_index == ctx->args->line_stipple_tex_ena.arg_index) + continue; + regs.emplace_back(Operand(get_arg(ctx, arg), get_arg_reg(ctx->args, arg))); + } } Temp diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c index 461aff2ed02..121e453d7a4 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c @@ -514,11 +514,20 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, union si_shader_part si_llvm_create_func(ctx, "ps_prolog", return_types, num_returns, 0); LLVMValueRef func = ctx->main_fn.value; + /* Disable elimination of unused inputs. */ + ac_llvm_add_target_dep_function_attr(ctx->main_fn.value, "InitialPSInputAddr", 0xffffff); + /* Copy inputs to outputs. This should be no-op, as the registers match, * but it will prevent the compiler from overwriting them unintentionally. */ LLVMValueRef ret = ctx->return_value; for (int i = 0; i < args->ac.arg_count; i++) { + /* Don't pass LINE_STIPPLE_TEX_ENA to the next shader binary because it's unused. + * This saves 1 VGPR in the prolog. + */ + if (args->ac.line_stipple_tex_ena.used && i == args->ac.line_stipple_tex_ena.arg_index) + continue; + LLVMValueRef p = LLVMGetParam(func, i); ret = insert_ret_of_arg(ctx, ret, p, i); }