Mesa (staging/20.0): spirv: Expand workaround for OpControlBarrier on old GLSLang

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 23 04:37:49 UTC 2020


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

Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date:   Tue Apr 21 18:20:39 2020 +0300

spirv: Expand workaround for OpControlBarrier on old GLSLang

In SPIRV of compute shader in Aztec Ruins benchmark there is:

OpControlBarrier %uint_1 %uint_1 %uint_0
// ControlBarrier(Device, Device, rdcspv::MemorySemantics(0));

which is an incorrect translation of glsl barrier().

GLSLang, prior to c3f1cdfa, emitted the OpControlBarrier with
Device instead of Workgroup for execution scope.

2365520c covers similar case but isn't applied when execution_scope
is SpvScopeDevice.

Cc: <mesa-stable at lists.freedesktop.org>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2742
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Tested-by: Rafael Antognolli <rafael.antognolli at intel.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4660>
(cherry picked from commit 66229aa16968eb60dd631a8f48f593a4fa8478d5)

---

 .pick_status.json                 | 2 +-
 src/compiler/spirv/spirv_to_nir.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 0eb11a276cb..fde12b08aa3 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -256,7 +256,7 @@
         "description": "spirv: Expand workaround for OpControlBarrier on old GLSLang",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 3c05d2f20fe..0ec5d6e0d17 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3712,11 +3712,15 @@ vtn_handle_barrier(struct vtn_builder *b, SpvOp opcode,
 
       /* GLSLang, prior to commit 8297936dd6eb3, emitted OpControlBarrier with
        * memory semantics of None for GLSL barrier().
+       * And before that, prior to c3f1cdfa, emitted the OpControlBarrier with
+       * Device instead of Workgroup for execution scope.
        */
       if (b->wa_glslang_cs_barrier &&
           b->nb.shader->info.stage == MESA_SHADER_COMPUTE &&
-          execution_scope == SpvScopeWorkgroup &&
+          (execution_scope == SpvScopeWorkgroup ||
+           execution_scope == SpvScopeDevice) &&
           memory_semantics == SpvMemorySemanticsMaskNone) {
+         execution_scope = SpvScopeWorkgroup;
          memory_scope = SpvScopeWorkgroup;
          memory_semantics = SpvMemorySemanticsAcquireReleaseMask |
                             SpvMemorySemanticsWorkgroupMemoryMask;



More information about the mesa-commit mailing list