Mesa (staging/20.0): aco: do not use ds_{read,write}2 on GFX6

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 7 17:36:21 UTC 2020


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

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Fri Feb  7 12:53:31 2020 +0100

aco: do not use ds_{read,write}2 on GFX6

According to LLVM, these instructions have a bounds checking bug.
LLVM only uses them on GFX7+.

This fixes broken geometry in Assassins Creed Origins.

Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2489
Fixes: 4a553212fa1 ("radv: enable ACO support for GFX6")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3746>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3746>
(cherry picked from commit 4b978cd950cef844afce07993ddb697779e5648d)

---

 .pick_status.json                              |  2 +-
 src/amd/compiler/aco_instruction_selection.cpp | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 33b84364ac2..2661862f36f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -49,7 +49,7 @@
         "description": "aco: do not use ds_{read,write}2 on GFX6",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "4a553212fa171ddaf849d4abb2d67208390cd769"
     },
diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp
index d885f79bd63..24be495dbb5 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -2657,6 +2657,7 @@ void load_lds(isel_context *ctx, unsigned elem_size_bytes, Temp dst,
    unsigned total_bytes = num_components * elem_size_bytes;
    std::array<Temp, NIR_MAX_VEC_COMPONENTS> result;
    bool large_ds_read = ctx->options->chip_class >= GFX7;
+   bool usable_read2 = ctx->options->chip_class >= GFX7;
 
    while (bytes_read < total_bytes) {
       unsigned todo = total_bytes - bytes_read;
@@ -2668,7 +2669,7 @@ void load_lds(isel_context *ctx, unsigned elem_size_bytes, Temp dst,
       if (todo >= 16 && aligned16 && large_ds_read) {
          op = aco_opcode::ds_read_b128;
          todo = 16;
-      } else if (todo >= 16 && aligned8) {
+      } else if (todo >= 16 && aligned8 && usable_read2) {
          op = aco_opcode::ds_read2_b64;
          read2 = true;
          todo = 16;
@@ -2678,7 +2679,7 @@ void load_lds(isel_context *ctx, unsigned elem_size_bytes, Temp dst,
       } else if (todo >= 8 && aligned8) {
          op = aco_opcode::ds_read_b64;
          todo = 8;
-      } else if (todo >= 8) {
+      } else if (todo >= 8 && usable_read2) {
          op = aco_opcode::ds_read2_b32;
          read2 = true;
          todo = 8;
@@ -2783,6 +2784,7 @@ void ds_write_helper(isel_context *ctx, Operand m, Temp address, Temp data, unsi
    Builder bld(ctx->program, ctx->block);
    unsigned bytes_written = 0;
    bool large_ds_write = ctx->options->chip_class >= GFX7;
+   bool usable_write2 = ctx->options->chip_class >= GFX7;
 
    while (bytes_written < total_size * 4) {
       unsigned todo = total_size * 4 - bytes_written;
@@ -2795,7 +2797,7 @@ void ds_write_helper(isel_context *ctx, Operand m, Temp address, Temp data, unsi
       if (todo >= 16 && aligned16 && large_ds_write) {
          op = aco_opcode::ds_write_b128;
          size = 4;
-      } else if (todo >= 16 && aligned8) {
+      } else if (todo >= 16 && aligned8 && usable_write2) {
          op = aco_opcode::ds_write2_b64;
          write2 = true;
          size = 4;
@@ -2805,7 +2807,7 @@ void ds_write_helper(isel_context *ctx, Operand m, Temp address, Temp data, unsi
       } else if (todo >= 8 && aligned8) {
          op = aco_opcode::ds_write_b64;
          size = 2;
-      } else if (todo >= 8) {
+      } else if (todo >= 8 && usable_write2) {
          op = aco_opcode::ds_write2_b32;
          write2 = true;
          size = 2;



More information about the mesa-commit mailing list