spirv: fix Uniform and Output MemoryAccessMakePointer{Visible,Available}
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 27 Jul 2020 13:48:12 +0000 (14:48 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 17:15:22 +0000 (17:15 +0000)
The Uniform storage class can be used for SSBOs. This should also fix make
available/visible for the Output storage class.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6090>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index 7324e9ca70b2b725b8874271562041f236173389..8aa9ac0e34f300dfc7b20cd9ba2436e56a6099ad 100644 (file)
@@ -2103,20 +2103,6 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
    vtn_foreach_decoration(b, val, handle_workgroup_size_decoration_cb, NULL);
 }
 
-SpvMemorySemanticsMask
-vtn_storage_class_to_memory_semantics(SpvStorageClass sc)
-{
-   switch (sc) {
-   case SpvStorageClassStorageBuffer:
-   case SpvStorageClassPhysicalStorageBuffer:
-      return SpvMemorySemanticsUniformMemoryMask;
-   case SpvStorageClassWorkgroup:
-      return SpvMemorySemanticsWorkgroupMemoryMask;
-   default:
-      return SpvMemorySemanticsMaskNone;
-   }
-}
-
 static void
 vtn_split_barrier_semantics(struct vtn_builder *b,
                             SpvMemorySemanticsMask semantics,
@@ -3539,7 +3525,7 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode,
    /* Atomic ordering operations will implicitly apply to the atomic operation
     * storage class, so include that too.
     */
-   semantics |= vtn_storage_class_to_memory_semantics(ptr->ptr_type->storage_class);
+   semantics |= vtn_mode_to_memory_semantics(ptr->mode);
 
    SpvMemorySemanticsMask before_semantics;
    SpvMemorySemanticsMask after_semantics;
index 6fc4f2e4f3eab67d55cb3be54351a79191e86a4f..9c96f1dd2be0100c957bc9fc73b97ff5dd22c1bc 100644 (file)
@@ -927,7 +927,7 @@ bool vtn_handle_amd_shader_explicit_vertex_parameter_instruction(struct vtn_buil
                                                                  const uint32_t *words,
                                                                  unsigned count);
 
-SpvMemorySemanticsMask vtn_storage_class_to_memory_semantics(SpvStorageClass sc);
+SpvMemorySemanticsMask vtn_mode_to_memory_semantics(enum vtn_variable_mode mode);
 
 void vtn_emit_memory_barrier(struct vtn_builder *b, SpvScope scope,
                              SpvMemorySemanticsMask semantics);
index 712c3db741574b16c65fdbbd52be93550a7c182b..fa78f80459483930b5f3605b4025ff440c4e6177 100644 (file)
@@ -2478,6 +2478,28 @@ vtn_get_mem_operands(struct vtn_builder *b, const uint32_t *w, unsigned count,
    return true;
 }
 
+SpvMemorySemanticsMask
+vtn_mode_to_memory_semantics(enum vtn_variable_mode mode)
+{
+   switch (mode) {
+   case vtn_variable_mode_ssbo:
+   case vtn_variable_mode_phys_ssbo:
+      return SpvMemorySemanticsUniformMemoryMask;
+   case vtn_variable_mode_workgroup:
+      return SpvMemorySemanticsWorkgroupMemoryMask;
+   case vtn_variable_mode_cross_workgroup:
+      return SpvMemorySemanticsCrossWorkgroupMemoryMask;
+   case vtn_variable_mode_atomic_counter:
+      return SpvMemorySemanticsAtomicCounterMemoryMask;
+   case vtn_variable_mode_image:
+      return SpvMemorySemanticsImageMemoryMask;
+   case vtn_variable_mode_output:
+      return SpvMemorySemanticsOutputMemoryMask;
+   default:
+      return SpvMemorySemanticsMaskNone;
+   }
+}
+
 void
 vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
                      const uint32_t *w, unsigned count)
@@ -2598,7 +2620,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       if (access & SpvMemoryAccessMakePointerVisibleMask) {
          SpvMemorySemanticsMask semantics =
             SpvMemorySemanticsMakeVisibleMask |
-            vtn_storage_class_to_memory_semantics(src->ptr_type->storage_class);
+            vtn_mode_to_memory_semantics(src->mode);
          vtn_emit_memory_barrier(b, scope, semantics);
       }
 
@@ -2647,7 +2669,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       if (access & SpvMemoryAccessMakePointerAvailableMask) {
          SpvMemorySemanticsMask semantics =
             SpvMemorySemanticsMakeAvailableMask |
-            vtn_storage_class_to_memory_semantics(dest->ptr_type->storage_class);
+            vtn_mode_to_memory_semantics(dest->mode);
          vtn_emit_memory_barrier(b, scope, semantics);
       }
       break;