KhronosGroup / KhronosGroup/glslang
VulkanMemoryModelDeviceScopeKHR capability missing form SPIRV
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
When requesting [GL_KHR_memory_scope_semantics](https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_memory_scope_semantics.txt) the generated SPIRV is missing `OpCapability VulkanMemoryModelDeviceScopeKHR`. I tested this by compiling a similar shader to the following
```glsl
#version 460
#extension GL_KHR_memory_scope_semantics : require
layout(local_size_x = 1) in;
shared int i;
void main()
{
atomicAdd(i, 1, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsAcquire | gl_SemanticsMakeVisible);
}
```
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
```
Contributor guide
Assessment
This issue has not been assessed yet.