Skip to content

[SPIR-V][Feature Request][SM6.6] ResourceDescriptorHeap support/emulation #4255

Closed

Description

Currently, attempting to assign a value indexed from ResourceDescriptorHeap results in a ICE (segfault) if -spirv is passed.

I'm writing this issue as sort of a placeholder to describe how this could be at least emulated in SPIR-V, at least until more direct support is available.

Consider a barebones shader like so:

[numthreads(32, 1, 1)]
void CSMain()
{
    Texture2D t = ResourceDescriptorHeap[0];
}

This shader fails to compile if -spirv -E CSMain are passed to dxc. However, one way this could be emulated is by creating "shadow" bindings for every resource type in a distinct space when -spirv is set. e.g. the compiler could transform the snippet above to:

[vk::binding(1000)]
Texture2D<float> __texture2d_float[];
[vk::binding(1000)]
Texture2D<float2> __texture2d_float2[];
[vk::binding(1000)]
Texture2D<float3> __texture2d_float3[];
// etc. for every resource type present in the shader. The set/binding for these emitted arrays can be set with a 
// command line argument but defaults to some high number
// The float and float2 texture types here are just illustrative.

[numthreads(32, 1, 1)]
void CSMain()
{
    Texture2D t = __texture2d_float2[0];
}

In the above transformation, the user could still write ResourceDescriptorHeap without thinking about which aliased descriptor array matched the resource type. The compiler does the following work:

  • Analyzes which types are present in the shader
  • Silently emits a binding at a deterministic set/binding slot corresponding to that type
  • Mutates ResourceDescriptorHeap to reference the correctly typed descriptor array

To use the shader, the user is responsible for creating the descriptor set that binds the descriptors themselves. However, the user is still able to access all resource types in a single unified heap (and more importantly, author shaders that work with both DX12 + vulkan using the same binding style).

Activity

  1. jeremyong-az commented on Feb 12, 2022

    @jeremyong-az
    Author

    Relevant discussion: KhronosGroup/Vulkan-Docs#871

  2. added
    spirv
    on Feb 15, 2022
  3. jaebaek commented on Feb 15, 2022

    @jaebaek
    Collaborator

    Thank you for reporting this issue.
    Ok .. we need some investigation for this topic. We will take a look.

  4. jeremyong-az commented on Feb 15, 2022

    @jeremyong-az
    Author

    Thanks, one edit I would make to my proposal above is that the binding scheme be changed to have a deterministic mapping between set/binding to resource type.

    For example:

    • Bit 0: RW vs non-RW variant
    • Bits 1-2: Dimensionality (1D, 2D, 3D)
    • Bits 3-x: Resource base type (e.g. ByteAddressBuffer, Texture2D, etc.)

    The binding number could be computed as above so that the user can be free to bind the descriptor sets that are needed and simply leave the remaining bindings unmapped.

    For samplers, we could use a different set from the resource descriptor types.

  5. hsiversson commented on Aug 18, 2022

    @hsiversson

    Thank you for reporting this issue. Ok .. we need some investigation for this topic. We will take a look.

    Jaebaek Seo (@jaebaek)
    Just curious, was there ever any progress made on this topic?
    Not having the ResourceDescriptorHeap available for SPIR-V is pretty much a showstopper for applications built with true bindless architecture, wanting to target Vulkan using DXC. You'd have to build large workarounds or manage additional root signatures and descriptors otherwise.

  6. changed the title [-][SPIR-V] ResourceDescriptorHeap support/emulation[/-] [+][SPIR-V][Feature Request][SM6.6] ResourceDescriptorHeap support/emulation[/+] on May 13, 2024
  7. added 4 commits that reference this issue on May 27, 2024
    aced8f1
    e3be089
    c059911
    e64b584
  8. added 2 commits that reference this issue on Jul 3, 2024
    f740d44
    664d2bf
  9. llvm-beanz commented on Jul 24, 2024

    @llvm-beanz
    Collaborator

    Should be fixed in #6650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementspirv

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions