Skip to content

[Feature Request] [SPIR-V] Add a command line option to set storage image and storage texel buffer format to Unknown #7484

Description

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.

Activity

  1. s-perron commented on May 29, 2025

    @s-perron
    Collaborator

    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.

  2. godlikepanos commented on May 30, 2025

    @godlikepanos
    ContributorAuthor

    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.

  3. s-perron commented on Jun 3, 2025

    @s-perron
    Collaborator

    Great. I'll try to get to this in the next few weeks.

  4. added a commit that references this issue on Jun 13, 2025
    57177f7
  5. s-perron commented on Jun 24, 2025

    @s-perron
    Collaborator

    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.

  6. moved this from New to In progress in HLSL Roadmapon Jul 8, 2025
  7. added a commit that references this issue on Jul 8, 2025
    a73b2f3
  8. moved this from In progress to Done in HLSL Roadmapon Jul 11, 2025
  9. added a commit that references this issue on Jul 14, 2025
    68dedee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions