Mesa (master): spirv: Handle MakeTexelAvailable/Visible

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 24 19:31:49 UTC 2019


Module: Mesa
Branch: master
Commit: 129c85c28b8da1801fae9c2b1ecac46b7c74a635
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=129c85c28b8da1801fae9c2b1ecac46b7c74a635

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Sep 10 13:16:46 2019 -0700

spirv: Handle MakeTexelAvailable/Visible

Set the memory semantics and scope for later emitting the barrier.
Note the barrier emission code already exist in vtn_handle_image for
the Image atomics.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/compiler/spirv/spirv_to_nir.c | 47 ++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index cacac282b0f..2de9bdf3389 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -2659,31 +2659,62 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
       image.sample = NULL;
       break;
 
-   case SpvOpImageRead:
+   case SpvOpImageRead: {
       image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
       image.coord = get_image_coord(b, w[4]);
 
-      if (count > 5 && (w[5] & SpvImageOperandsSampleMask)) {
-         vtn_assert(w[5] == SpvImageOperandsSampleMask);
-         image.sample = vtn_ssa_value(b, w[6])->def;
+      const SpvImageOperandsMask operands =
+         count > 5 ? w[5] : SpvImageOperandsMaskNone;
+
+      int idx = 6;
+      if (operands & SpvImageOperandsSampleMask) {
+         image.sample = vtn_ssa_value(b, w[idx])->def;
+         idx++;
       } else {
          image.sample = nir_ssa_undef(&b->nb, 1, 32);
       }
+
+      if (operands & SpvImageOperandsMakeTexelVisibleMask) {
+         vtn_fail_if((operands & SpvImageOperandsNonPrivateTexelMask) == 0,
+                     "MakeTexelVisible requires NonPrivateTexel to also be set.");
+         semantics = SpvMemorySemanticsMakeVisibleMask;
+         scope = vtn_constant_uint(b, w[idx]);
+         idx++;
+      }
+
+      /* TODO: Volatile. */
+
       break;
+   }
 
-   case SpvOpImageWrite:
+   case SpvOpImageWrite: {
       image.image = vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
       image.coord = get_image_coord(b, w[2]);
 
       /* texel = w[3] */
 
-      if (count > 4 && (w[4] & SpvImageOperandsSampleMask)) {
-         vtn_assert(w[4] == SpvImageOperandsSampleMask);
-         image.sample = vtn_ssa_value(b, w[5])->def;
+      const SpvImageOperandsMask operands =
+         count > 4 ? w[4] : SpvImageOperandsMaskNone;
+
+      int idx = 5;
+      if (operands & SpvImageOperandsSampleMask) {
+         image.sample = vtn_ssa_value(b, w[idx])->def;
+         idx++;
       } else {
          image.sample = nir_ssa_undef(&b->nb, 1, 32);
       }
+
+      if (operands & SpvImageOperandsMakeTexelAvailableMask) {
+         vtn_fail_if((operands & SpvImageOperandsNonPrivateTexelMask) == 0,
+                     "MakeTexelAvailable requires NonPrivateTexel to also be set.");
+         semantics = SpvMemorySemanticsMakeAvailableMask;
+         scope = vtn_constant_uint(b, w[idx]);
+      }
+
+      /* TODO: Volatile. */
+
       break;
+   }
 
    default:
       vtn_fail_with_opcode("Invalid image opcode", opcode);




More information about the mesa-commit mailing list