r600/sfn: Emit and schedule WaitACK as a separate instruction

This is a step to emitting VTX and TEX block start instructions in the
sfn assembler instead of relying on the old backend asm code.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37096>
This commit is contained in:
Gert Wollny 2025-08-28 13:37:58 +02:00 committed by Marge Bot
parent a6b6ce84f7
commit a6302cf00d
4 changed files with 17 additions and 8 deletions

View file

@ -687,7 +687,6 @@ LoadFromScratch::LoadFromScratch(const RegisterVec4& dst,
nullptr)
{
set_fetch_flag(uncached);
set_fetch_flag(wait_ack);
assert(scratch_size >= 1);
set_array_size(scratch_size - 1);

View file

@ -765,6 +765,10 @@ RatInstr::emit_ssbo_atomic_op(nir_intrinsic_instr *intr, Shader& shader)
atomic->set_instr_flag(ack_rat_return_write);
auto dest = vf.dest_vec4(intr->def, pin_group);
auto wait = new ControlFlowInstr(ControlFlowInstr::cf_wait_ack);
wait->add_required_instr(atomic);
shader.emit_instruction(wait);
auto fetch = new FetchInstr(vc_fetch,
dest,
{0, 1, 2, 3},
@ -780,8 +784,7 @@ RatInstr::emit_ssbo_atomic_op(nir_intrinsic_instr *intr, Shader& shader)
fetch->set_fetch_flag(FetchInstr::srf_mode);
fetch->set_fetch_flag(FetchInstr::use_tc);
fetch->set_fetch_flag(FetchInstr::vpm);
fetch->set_fetch_flag(FetchInstr::wait_ack);
fetch->add_required_instr(atomic);
fetch->add_required_instr(wait);
shader.chain_ssbo_read(fetch);
shader.emit_instruction(fetch);
}
@ -899,12 +902,17 @@ RatInstr::emit_image_load_or_atomic(nir_intrinsic_instr *intrin, Shader& shader)
auto atomic =
new RatInstr(cf_mem_rat, opcode, data_vec4, coord, imageid, image_offset, 1, 0xf, 0);
shader.emit_instruction(atomic);
atomic->set_ack();
if (read_result) {
atomic->set_instr_flag(ack_rat_return_write);
auto dest = vf.dest_vec4(intrin->def, pin_group);
auto wait = new ControlFlowInstr(ControlFlowInstr::cf_wait_ack);
shader.chain_ssbo_read(wait);
shader.emit_instruction(wait);
pipe_format format = nir_intrinsic_format(intrin);
unsigned fmt = fmt_32;
unsigned num_format = 0;
@ -926,12 +934,12 @@ RatInstr::emit_image_load_or_atomic(nir_intrinsic_instr *intrin, Shader& shader)
fetch->set_mfc(3);
fetch->set_fetch_flag(FetchInstr::use_tc);
fetch->set_fetch_flag(FetchInstr::vpm);
fetch->set_fetch_flag(FetchInstr::wait_ack);
fetch->add_required_instr(wait);
if (format_comp)
fetch->set_fetch_flag(FetchInstr::format_comp_signed);
shader.chain_ssbo_read(fetch);
shader.emit_instruction(fetch);
shader.chain_ssbo_read(fetch);
}
return true;

View file

@ -1240,6 +1240,10 @@ Shader::emit_load_scratch(nir_intrinsic_instr *intr)
for (unsigned i = 0; i < intr->num_components; ++i)
dest_swz[i] = i;
auto wait = new ControlFlowInstr(ControlFlowInstr::cf_wait_ack);
emit_instruction(wait);
chain_scratch_read(wait);
auto *ir = new LoadFromScratch(dest, dest_swz, addr, m_scratch_size);
emit_instruction(ir);
chain_scratch_read(ir);

View file

@ -585,7 +585,6 @@ TEST_F(TestInstrFromString, test_load_from_scratch)
expect_fetch.set_print_skip(FetchInstr::EPrintSkip::ftype);
expect_fetch.set_fetch_flag(FetchInstr::EFlags::uncached);
expect_fetch.set_fetch_flag(FetchInstr::EFlags::indexed);
expect_fetch.set_fetch_flag(FetchInstr::EFlags::wait_ack);
expect_fetch.set_array_size(19);
check(init, expect_fetch);
@ -645,7 +644,6 @@ TEST_F(TestInstrFromString, test_load_from_scratch_fixed_offset)
expect_fetch.set_print_skip(FetchInstr::EPrintSkip::fmt);
expect_fetch.set_print_skip(FetchInstr::EPrintSkip::ftype);
expect_fetch.set_fetch_flag(FetchInstr::EFlags::uncached);
expect_fetch.set_fetch_flag(FetchInstr::EFlags::wait_ack);
expect_fetch.set_array_base(10);
expect_fetch.set_array_size(39);