Open kvark opened 4 years ago
Good news is - we don't really need to introspect the SPIR-V and set up the overrides based on the "readonly" flag: Root Signature spaces for UAV and SRV are separate, so we can just bind both, and let it figure out which one is needed.
Vulkan has this strange semantics: at the binding model level, there is no "read-only" option for storage resources. But at the shader level, one can specify a storage resource can be decorated with
NonReadable
orNonWritable
. When such "NonWritable" is encountered by our DX12 backend (say, produced by "readonly" GLSL SSBO), the translated shader uses non-writable variant, e.g.ByteAddressBuffer
as opposed toRWByteAddressBuffer
. There is a crucial difference here because DX12 binding model considers the former to be SRV and the latter to be UAV... but we have no means to detect this at the pipeline creation time.So there is an obvious conflict with DX12 binding model semantics. I could think of a number of ways to address this:
Also, a combination of these methods is possible: have the flag in the API that specifies read-only/write-only/both. Have the Root Signature creation code respect that setting, and for the "both" case still make the override based on the shader. This solution would allow both get the maximum of the API and keep the compatibility with Vulkan. We'd also consider upstreaming the API changes to VkPI in this case.