microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Invalid SPIR-V when using globallycoherent in conjunction with the Vulkan memory model
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
When using a globallycoherent RWTexture and the Vulkan memory model via -fspv-use-vulkan-memory-model, the generated SPIR-V is invalid. When the default GLSL450 memory model is used, the code compiles correctly.
Coherent structured buffers don't seem to be affected.
Steps to Reproduce
https://godbolt.org/z/sGYzc8KW4
// -T ps_6_6 -E main -spirv -HV 2021 -fspv-target-env=vulkan1.3 -fspv-use-vulkan-memory-model
// Does not compile if vulkan memory model is requested
[[vk::binding(0, 0)]] globallycoherent RWTexture2D<float4> img;
struct PSInput {
float4 position : SV_Position;
};
float4 main(PSInput input) : SV_Target0 {
return img[uint2(input.position.xy)];
}
Actual Behavior
fatal error: generated SPIR-V is invalid: NonPrivatePointerKHR requires a pointer in Uniform, Workgroup, CrossWorkgroup, Generic, Image or StorageBuffer storage classes.
%22 = OpLoad %type_2d_image %img MakePointerVisible|NonPrivatePointer %uint_5
Environment
- DXC trunk
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the Godbolt reproduction with the listed DXC flags and compare it with the default GLSL450 memory model case. Trace the Vulkan memory-model handling through SPIR-V generation and validation; done means the globallycoherent RWTexture2D example produces valid SPIR-V while coherent structured buffers remain unaffected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100