From be94874276976ea21d72e5f29b2c868721b082f4 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 31 May 2023 17:44:16 +0200 Subject: [PATCH] r600/sfn: add read instruction for unused but required LDS op results DS_XCHG_RET and LDS_CMP_XCHG_RET don't have a version that doesn't return a value in the LDS red queue. so we have to read the value from the queue and discard it. Fixes: 79ca456b (r600/sfn: rewrite NIR backend) Signed-off-by: Gert Wollny Part-of: (cherry picked from commit 976d6de232aec1874b634b7dda3b2c90d607e13b) --- .pick_status.json | 2 +- src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp | 1 + src/gallium/drivers/r600/sfn/sfn_shader.cpp | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 836e5d18118..b87752dd9c0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3496,7 +3496,7 @@ "description": "r600/sfn: add read instruction for unused but required LDS op results", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "79ca456b4837b3bc21cf9ef3c03c505c4b4909f6" }, diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp b/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp index 508b05855f0..4e00af05e12 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp @@ -142,6 +142,7 @@ LDSReadInstr::split(std::vector& out_block, AluInstr *last_lds_instr AluInstr::last_write); instr->add_required_instr(last_lds_instr); instr->set_blockid(block_id(), index()); + instr->set_always_keep(); out_block.push_back(instr); last_lds_instr = instr; } diff --git a/src/gallium/drivers/r600/sfn/sfn_shader.cpp b/src/gallium/drivers/r600/sfn/sfn_shader.cpp index 567af70d7bc..5acb632ee45 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader.cpp @@ -931,6 +931,14 @@ Shader::emit_atomic_local_shared(nir_intrinsic_instr *instr) auto op = lds_op_from_intrinsic(instr->intrinsic, uses_retval); + /* For these two instructions we don't have opcodes that don't read back + * the result, so we have to add a dummy-readback to remove the the return + * value from read queue. */ + if (!uses_retval && + (op == LDS_XCHG_RET || op == LDS_CMP_XCHG_RET)) { + dest_value = vf.dest(instr->dest, 0, pin_free); + } + auto address = vf.src(instr->src[0], 0); AluInstr::SrcValues src;