spirv: Add SpvMemoryModelVulkan and related capabilities
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 10 Sep 2019 19:38:00 +0000 (12:38 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 24 Oct 2019 18:39:56 +0000 (11:39 -0700)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/shader_info.h
src/compiler/spirv/spirv_to_nir.c

index e8c875f333f665a8ed47f40f590d1d0b19314f86..cc33899ad3e98064068d16964d3d9277a1f8c782 100644 (file)
@@ -75,6 +75,8 @@ struct spirv_supported_capabilities {
    bool tessellation;
    bool transform_feedback;
    bool variable_pointers;
+   bool vk_memory_model;
+   bool vk_memory_model_device_scope;
    bool float16;
    bool amd_gcn_shader;
    bool amd_shader_ballot;
index 2be42fd35b4dcc5c4998e588cd42b381a4580289..47f00c8c16322d1d77553ac4096b3bf3edda880d 100644 (file)
@@ -3792,6 +3792,14 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
 
       case SpvCapabilityShaderClockKHR:
          spv_check_supported(shader_clock, cap);
+        break;
+
+      case SpvCapabilityVulkanMemoryModel:
+         spv_check_supported(vk_memory_model, cap);
+         break;
+
+      case SpvCapabilityVulkanMemoryModelDeviceScope:
+         spv_check_supported(vk_memory_model_device_scope, cap);
          break;
 
       default:
@@ -3842,9 +3850,20 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          break;
       }
 
-      vtn_assert(w[2] == SpvMemoryModelSimple ||
-                 w[2] == SpvMemoryModelGLSL450 ||
-                 w[2] == SpvMemoryModelOpenCL);
+      switch (w[2]) {
+      case SpvMemoryModelSimple:
+      case SpvMemoryModelGLSL450:
+      case SpvMemoryModelOpenCL:
+         break;
+      case SpvMemoryModelVulkan:
+         vtn_fail_if(!b->options->caps.vk_memory_model,
+                     "Vulkan memory model is unsupported by this driver");
+         break;
+      default:
+         vtn_fail("Unsupported memory model: %s",
+                  spirv_memorymodel_to_string(w[2]));
+         break;
+      }
       break;
 
    case SpvOpEntryPoint: