Skip to content

[SPIR-V] Add SPV_EXT_descriptor_heap + SPV_KHR_untyped_pointers codegen#8517

Open
jzakharovnv wants to merge 1 commit into
microsoft:mainfrom
jzakharovnv:pr1-descriptor-heap-core
Open

[SPIR-V] Add SPV_EXT_descriptor_heap + SPV_KHR_untyped_pointers codegen#8517
jzakharovnv wants to merge 1 commit into
microsoft:mainfrom
jzakharovnv:pr1-descriptor-heap-core

Conversation

@jzakharovnv

@jzakharovnv jzakharovnv commented Jun 4, 2026

Copy link
Copy Markdown

Building off of #8281, this PR adds a native lowering via SPV_EXT_descriptor_heap and SPV_KHR_untyped_pointers and is part 1/4 in a series.

ResourceDescriptorHeap and SamplerDescriptorHeap are lowered to untyped variables decorated with ResourceHeapEXT and SamplerHeapEXT. Each heap access emits OpUntypedAccessChainKHR into a runtime array of the appropriate descriptor type. Buffer-like resources (StructuredBuffer, ByteAddressBuffer, ConstantBuffer, TextureBuffer) use OpTypeBufferEXT and OpBufferPointerEXT; image and sampler resources use OpLoad. Interlocked operations on RWTexture use OpUntypedImageTexelPointerEXT.

Requires -fspv-target-env=vulkan1.3.

Assisted by an AI agent.

@dnovillo

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

Building off of microsoft#8281, this commit adds a native lowering via SPV_EXT_descriptor_heap and SPV_KHR_untyped_pointers.

ResourceDescriptorHeap and SamplerDescriptorHeap are lowered to untyped variables decorated with ResourceHeapEXT and SamplerHeapEXT. Each heap access emits OpUntypedAccessChainKHR into a runtime array of the appropriate descriptor type. Buffer-like resources (StructuredBuffer, ByteAddressBuffer, ConstantBuffer, TextureBuffer) use OpTypeBufferEXT and OpBufferPointerEXT; image and sampler resources use OpLoad. Interlocked operations on RWTexture use OpUntypedImageTexelPointerEXT.

Requires -fspv-target-env=vulkan1.3.

Assisted-by: Claude.
@jzakharovnv jzakharovnv force-pushed the pr1-descriptor-heap-core branch from f640327 to cbcae38 Compare June 4, 2026 22:42
@jzakharovnv

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="NVIDIA"

@dnovillo dnovillo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I just started looking at it and have a couple of questions. I'll add more as I read the PRs.

SpirvEmitter::getDescriptorHeapRuntimeArrayType(const SpirvType *elemType,
bool onSamplerHeap) {
constexpr uint32_t kDefaultResourceHeapStride = 64;
constexpr uint32_t kDefaultSamplerHeapStride = 32;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would float these defaults to SpirvEmitter.h and document where the seemingly magic values 32 and 64 come from.

constexpr uint32_t kDefaultSamplerHeapStride = 32;
const uint32_t stride =
onSamplerHeap ? kDefaultSamplerHeapStride : kDefaultResourceHeapStride;
return spvContext.getRuntimeArrayType(elemType, stride);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem that there are tests for OpDecorate ArrayStride N in this PR. I haven't checked the others. Could you add one (unless I missed it?)

@github-project-automation github-project-automation Bot moved this from New to In progress in HLSL Roadmap Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants