You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SPIR-V] Missing VulkanMemoryModelDeviceScopeKHR Capability when using wave intrinsics #6066
Description
When building a raytracing shader (closestHit, miss or raygeneration) with a device atomic operation and wave intrinsic operations, the compilation fails due to a missing SPIR-V capability declaration.
Steps to Reproduce
Create a closestHit, miss or rayGeneration shader
Add an atomic operation on a device buffer
Add a waveintrinsic operation
Compile for Vulkan 1.2
compiled with -HV 2021 -fspv-target-env=vulkan1.2 spirv1.4 -T lib_6_4 -E main -spirv -O0
Actual Behavior
The compiler fails with the following error.
fatal error: generated SPIR-V is invalid: Use of device scope with VulkanKHR memory model requires the VulkanMemoryModelDeviceScopeKHR capability
%21 = OpAtomicIAdd %int %18 %uint_1 %uint_0 %20
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Compiler returned: 5
The created SPIR-V is obviously missing the required capability which should be added by dxc in this case.
Mateusz Kielan (@devshgraphicsprogramming) Great idea, thank you!
I tried adding [[vk::ext_capability(/*VulkanMemoryModelDeviceScopeKHR*/ 5346)]] next to my entry point, but it still fails to add the capability. Am I missing something?
devshgraphicsprogramming commented on Nov 30, 2023
Mateusz Kielan (@devshgraphicsprogramming) Great idea, thank you! I tried adding [[vk::ext_capability(/*VulkanMemoryModelDeviceScopeKHR*/ 5346)]] next to my entry point, but it still fails to add the capability. Am I missing something?
hmm no more ideas at this point, but maybe the SPIR-V is getting validated BEFORE this inline stuff gets added?
Activity
devshgraphicsprogramming commentedon Nov 29, 2023
btw if you need a quick fix, you can declare the capability yourself using inline SPIR-V somewhere in statically reachable code (by your entry point)
mourthag commentedon Nov 30, 2023
Mateusz Kielan (@devshgraphicsprogramming) Great idea, thank you!
I tried adding
[[vk::ext_capability(/*VulkanMemoryModelDeviceScopeKHR*/ 5346)]]next to my entry point, but it still fails to add the capability. Am I missing something?devshgraphicsprogramming commentedon Nov 30, 2023
hmm no more ideas at this point, but maybe the SPIR-V is getting validated BEFORE this inline stuff gets added?
mourthag commentedon Nov 30, 2023
I found the problem. The
[[vk::ext_capability()]]needs to be coupled with[[vk::ext_instruction()]]for example. (see also wiki and this issue)With this, I created a super hacky workaround: https://godbolt.org/z/x4c91ao35. Feel free to propose a better solution though.
sudonatalie commentedon Dec 4, 2023
Mourthag (@mourthag) Thanks for reporting! I'll take a look.
[SPIR-V] Add VulkanMemoryModelDeviceScope
[SPIR-V] Add VulkanMemoryModelDeviceScope
[SPIR-V] Add VulkanMemoryModelDeviceScope
[SPIR-V] Add VulkanMemoryModelDeviceScope
[SPIR-V] Add VulkanMemoryModelDeviceScope (#6186)
[SPIRV] Add vulkan memory option to DXC
[SPIRV] Add vulkan memory option to DXC (#6848)
[SPIRV] Add vulkan memory option to DXC (microsoft#6848)