Mesa (main): r600/sfn: count LDS queue pop reads separately in assembler

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 23 14:23:01 UTC 2022


Module: Mesa
Branch: main
Commit: 8db31e0fe6976a92b3b8c334baca6582dd675682
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8db31e0fe6976a92b3b8c334baca6582dd675682

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Thu Jul 21 17:52:05 2022 +0200

r600/sfn: count LDS queue pop reads separately in assembler

Otherwise the check whether the fetches and reads are balanced
could fail.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17678>

---

 src/gallium/drivers/r600/sfn/sfn_assembler.cpp |  2 +-
 src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp | 18 ++++++++++++------
 src/gallium/drivers/r600/sfn/sfn_instr_alu.h   |  1 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r600/sfn/sfn_assembler.cpp b/src/gallium/drivers/r600/sfn/sfn_assembler.cpp
index dc8a76737d7..75c3e59e4a4 100644
--- a/src/gallium/drivers/r600/sfn/sfn_assembler.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_assembler.cpp
@@ -309,7 +309,7 @@ void AssamblerVisitor::emit_alu_op(const AluInstr& ai)
          alu.src[i].kc_rel = 1;
       }
 
-      if (ai.has_lds_access()) {
+      if (ai.has_lds_queue_read()) {
          assert(m_bc->cf_last->nlds_read > 0);
          m_bc->cf_last->nlds_read--;
       }
diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp b/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp
index 886adf574e4..fa021811cc7 100644
--- a/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp
@@ -788,14 +788,20 @@ bool AluInstr::propagate_death()
 
 bool AluInstr::has_lds_access() const
 {
-   if (has_alu_flag(alu_is_lds))
-      return true;
+   return has_alu_flag(alu_is_lds) || has_lds_queue_read();
+}
 
-   for (auto& s : m_src)
-      if (s->as_inline_const() &&
-          (s->as_inline_const()->sel() == ALU_SRC_LDS_OQ_A_POP))
-         return true;
+bool AluInstr::has_lds_queue_read() const
+{
+   for (auto& s : m_src) {
+      auto ic = s->as_inline_const();
+      if (!ic)
+         continue;
 
+      if (ic->sel() == ALU_SRC_LDS_OQ_A_POP ||
+          ic->sel() == ALU_SRC_LDS_OQ_B_POP)
+         return true;
+   }
    return false;
 }
 
diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_alu.h b/src/gallium/drivers/r600/sfn/sfn_instr_alu.h
index 2d9a24e910d..1d54e30baf8 100644
--- a/src/gallium/drivers/r600/sfn/sfn_instr_alu.h
+++ b/src/gallium/drivers/r600/sfn/sfn_instr_alu.h
@@ -127,6 +127,7 @@ public:
    bool is_equal_to(const AluInstr& lhs) const;
 
    bool has_lds_access() const;
+   bool has_lds_queue_read() const;
 
    static const std::map<ECFAluOpCode, std::string> cf_map;
    static const std::map<AluBankSwizzle, std::string> bank_swizzle_map;



More information about the mesa-commit mailing list