aco/isel: Fix stack_ptr synthesis

info.stack_ptr.is_reg is always true. We have a stack pointer to use
if and only if the program is a callee.

Also, apply_scratch_offset needs to be true in a few more places.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40008>
This commit is contained in:
Natalie Vock 2026-02-20 13:42:42 +01:00 committed by Marge Bot
parent 31e08322d7
commit 378c9536de
2 changed files with 6 additions and 5 deletions

View file

@ -780,7 +780,7 @@ visit_call(isel_context* ctx, nir_call_instr* instr)
*/
Temp stack_ptr, param_stack_ptr;
if (info.stack_ptr.is_reg && ctx->program->gfx_level >= GFX9) {
if (ctx->program->is_callee && ctx->program->gfx_level >= GFX9) {
param_stack_ptr = bld.pseudo(aco_opcode::p_callee_stack_ptr, bld.def(s1), bld.def(s1, scc),
Operand::c32(info.scratch_param_size),
Operand(ctx->callee_info.stack_ptr.def.getTemp()));
@ -814,7 +814,7 @@ visit_call(isel_context* ctx, nir_call_instr* instr)
if (ctx->program->gfx_level >= GFX9) {
call_instr->operands[0] = Operand(stack_ptr, info.stack_ptr.def.physReg());
} else {
call_instr->operands[0] = Operand(load_scratch_resource(ctx->program, bld, -1u, false));
call_instr->operands[0] = Operand(load_scratch_resource(ctx->program, bld, ctx->program->private_segment_buffers.size() - 1, true));
call_instr->operands[0].setPrecolored(info.stack_ptr.def.physReg());
}

View file

@ -3894,8 +3894,8 @@ load_scratch_param(isel_context* ctx, Builder& bld, const parameter_info& param,
params.max_const_offset = ctx->program->dev.scratch_global_offset_max;
emit_load(ctx, bld, info, params);
} else {
info.resource = load_scratch_resource(
ctx->program, bld, ctx->program->private_segment_buffers.size() - 1, false);
info.resource = load_scratch_resource(ctx->program, bld,
ctx->program->private_segment_buffers.size() - 1, true);
if (stack_ptr.id()) {
info.soffset = bld.sop2(aco_opcode::s_add_u32, bld.def(s1), bld.def(s1, scc), stack_ptr,
Operand::c32(-const_offset * ctx->program->wave_size));
@ -3922,7 +3922,8 @@ store_scratch_param(isel_context* ctx, Builder& bld, const parameter_info& param
write_datas, offsets);
if (ctx->program->gfx_level < GFX9) {
Temp scratch_rsrc = load_scratch_resource(ctx->program, bld, -1u, false);
Temp scratch_rsrc = load_scratch_resource(
ctx->program, bld, ctx->program->private_segment_buffers.size() - 1, true);
for (unsigned i = 0; i < write_count; i++) {
Temp soffset;
if (stack_ptr.id()) {