[Feature Request] [SPIR-V] Add a command line option to set storage image and storage texel buffer format to Unknown
Is your feature request related to a problem? Please describe.
DXC tries to guess the format of storage images and storage texel buffers from the type of the resource. For example, for RWTexture<float4> DXC will set the format to Rgba32. Recent Vulkan validation throws a warning if the format in SPIR-V doesn't match the format of the VkImage.
So developers really have two choices. Either decorate the resource with [[vk::format(...)]] or ignore the validation warning. Both solutions are not ideal. The 1st solution means touching a potentially huge set of shader code and the 2nd solution might not be possible if validation runs through some tool that can't filter messages.
According to https://vulkan.gpuinfo.org the vast majority of GPUs (90%+) nowadays support reading and writing from Unknown.
Describe the solution you'd like To avoid breaking existing code DXC could add a command line option that stops it from guessing the format and always sets it to Unknown.
What version of Vulkan do you target? Starting in Vulkan 1.3 the feature is required. In Clang, we are using unknown by default, and plan to do that for VK1.3 and up. I wonder if we should do the same in DXC.
I'm targeting -fspv-target-env=vulkan1.1spirv1.4 but in reality I'm at Vulkan 1.3. I just realized I neglected to update the -fspv-target-env. Is that what you mean?
Tying the format to the target version sounds sensible.
Great. I'll try to get to this in the next few weeks.
I had to revert the change. It was causing regressions on some platform because the vulkan validation layers were complaining. I'll add an option as you originally suggested.