Mesa (staging/21.1): aco: fix emitting literal offsets with SMEM on GFX7

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 10 11:32:25 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: a72f9745a7113122d55b82e4517e983dac27a496
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a72f9745a7113122d55b82e4517e983dac27a496

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Tue Jun  8 18:06:46 2021 +0200

aco: fix emitting literal offsets with SMEM on GFX7

When the offset is negative, reg() isn't 255. Fix this by splitting
SGPR and literal emission. While we are at it, adjust a comment
saying that literals are also accepted on GFX6 which is wrong.

Fixes another batch of robustness tests.

Cc: 21.1 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11247>
(cherry picked from commit d169dad3937e2b2692c3992e0ed417849e971ee6)

---

 .pick_status.json                  | 2 +-
 src/amd/compiler/aco_assembler.cpp | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 32224979ca8..3fc144afc27 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -679,7 +679,7 @@
         "description": "aco: fix emitting literal offsets with SMEM on GFX7",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp
index 19b63d12752..991be03359d 100644
--- a/src/amd/compiler/aco_assembler.cpp
+++ b/src/amd/compiler/aco_assembler.cpp
@@ -173,15 +173,17 @@ void emit_instruction(asm_context& ctx, std::vector<uint32_t>& out, Instruction*
          encoding |= instr->definitions.size() ? instr->definitions[0].physReg() << 15 : 0;
          encoding |= instr->operands.size() ? (instr->operands[0].physReg() >> 1) << 9 : 0;
          if (instr->operands.size() >= 2) {
-            if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) {
+            if (!instr->operands[1].isConstant()) {
                encoding |= instr->operands[1].physReg().reg();
+            } else if (instr->operands[1].constantValue() >= 1024) {
+               encoding |= 255; /* SQ_SRC_LITERAL */
             } else {
                encoding |= instr->operands[1].constantValue() >> 2;
                encoding |= 1 << 8;
             }
          }
          out.push_back(encoding);
-         /* SMRD instructions can take a literal on GFX6 & GFX7 */
+         /* SMRD instructions can take a literal on GFX7 */
          if (instr->operands.size() >= 2 && instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024)
             out.push_back(instr->operands[1].constantValue() >> 2);
          return;



More information about the mesa-commit mailing list