From e135a4897a8bfeae99a6b34b70d4a939ef8fdfbd Mon Sep 17 00:00:00 2001 From: Jeff Bolz Date: Sun, 20 Jan 2019 00:59:17 -0600 Subject: [PATCH] More precisely check for the qualifiers that enable the vulkan memory model for buffer references. Not all memory qualifiers necessarily need the vulkan memory model, e.g. volatile/restrict that correspond to core SPIR-V features do not. --- Test/baseResults/spv.bufferhandle13.frag.out | 4 +--- glslang/Include/Types.h | 5 +++++ glslang/MachineIndependent/ParseHelper.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Test/baseResults/spv.bufferhandle13.frag.out b/Test/baseResults/spv.bufferhandle13.frag.out index 1438086..8c12c4f 100644 --- a/Test/baseResults/spv.bufferhandle13.frag.out +++ b/Test/baseResults/spv.bufferhandle13.frag.out @@ -4,13 +4,11 @@ spv.bufferhandle13.frag // Id's are bound by 58 Capability Shader - Capability CapabilityVulkanMemoryModelKHR Capability CapabilityPhysicalStorageBufferAddressesEXT Extension "SPV_EXT_physical_storage_buffer" Extension "SPV_KHR_storage_buffer_storage_class" - Extension "SPV_KHR_vulkan_memory_model" 1: ExtInstImport "GLSL.std.450" - MemoryModel PhysicalStorageBuffer64EXT VulkanKHR + MemoryModel PhysicalStorageBuffer64EXT GLSL450 EntryPoint Fragment 4 "main" ExecutionMode 4 OriginUpperLeft Source GLSL 450 diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index edd5cfc..cd9fc0e 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -537,6 +537,11 @@ public: { return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || volatil || restrict || readonly || writeonly; } + bool bufferReferenceNeedsVulkanMemoryModel() const + { + // include qualifiers that map to load/store availability/visibility/nonprivate memory access operands + return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || nonprivate; + } bool isInterpolation() const { diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index c8a5de5..8c6b7ca 100755 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -355,7 +355,7 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb intermediate.addIoAccessed(*string); if (variable->getType().getBasicType() == EbtReference && - variable->getType().getQualifier().isMemory()) { + variable->getType().getQualifier().bufferReferenceNeedsVulkanMemoryModel()) { intermediate.setUseVulkanMemoryModel(); } -- 2.7.4