r600/sfn: add read instruction for unused but required LDS op results
authorGert Wollny <gert.wollny@collabora.com>
Wed, 31 May 2023 15:44:16 +0000 (17:44 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 8 Jun 2023 08:32:16 +0000 (08:32 +0000)
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 <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23518>

src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp
src/gallium/drivers/r600/sfn/sfn_shader.cpp

index a70fcd1..f201a55 100644 (file)
@@ -142,6 +142,7 @@ LDSReadInstr::split(std::vector<AluInstr *>& 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;
    }
index 9eaed34..49bdf12 100644 (file)
@@ -975,6 +975,14 @@ Shader::emit_atomic_local_shared(nir_intrinsic_instr *instr)
 
    auto op = lds_op_from_intrinsic(nir_intrinsic_atomic_op(instr), 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;