When requesting GL_KHR_memory_scope_semantics the generated SPIRV is missing OpCapability VulkanMemoryModelDeviceScopeKHR. I tested this by compiling a similar shader to the following
and reading the disassembly (generated by spirv-dis.exe). Only OpCapability VulkanMemoryModel is present. This is caught by Vulkan validation layers and reported as the following error:
Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01379 ] | MessageID = 0x2a1bf17f | SPIR-V module not valid: Use of device scope with VulkanKHR memory model requires the VulkanMemoryModelDeviceScopeKHR capability
OpMemoryBarrier %uint_1 %uint_24648
Note: Here the instruction reported is MemoryBarrier but the same should apply for other instructions affected by the GL_KHR_memory_scope_semantics extension.
When manually adding the OpCapability VulkanMemoryModelDeviceScopeKHR to the spirv there are no validation layer errors reported.
The shader was compiled via glslang --target-env spirv1.6 -V shader.comp -o shader.comp.spv. Glslang version:
Glslang Version: 11:12.3.1
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 12.3.1
GLSL Version: 4.60 glslang Khronos. 12.3.1
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100
This does seem to be a bug and unfortunately seems to have escaped the unit tests. It seems like the code to add the capabilities when the scope arguments are passed to atomicAdd and friends was never added.
When requesting GL_KHR_memory_scope_semantics the generated SPIRV is missing
OpCapability VulkanMemoryModelDeviceScopeKHR
. I tested this by compiling a similar shader to the followingand reading the disassembly (generated by spirv-dis.exe). Only
OpCapability VulkanMemoryModel
is present. This is caught by Vulkan validation layers and reported as the following error:Note: Here the instruction reported is MemoryBarrier but the same should apply for other instructions affected by the GL_KHR_memory_scope_semantics extension.
When manually adding the
OpCapability VulkanMemoryModelDeviceScopeKHR
to the spirv there are no validation layer errors reported.The shader was compiled via
glslang --target-env spirv1.6 -V shader.comp -o shader.comp.spv
. Glslang version: