Skip to content

[SPIR-V] Add descriptor heap -fvk-resource-heap-stride / -fvk-sampler-heap-stride CLI flags#8519

Open
jzakharovnv wants to merge 11 commits into
microsoft:mainfrom
jzakharovnv:pr3-cli-stride-flags
Open

[SPIR-V] Add descriptor heap -fvk-resource-heap-stride / -fvk-sampler-heap-stride CLI flags#8519
jzakharovnv wants to merge 11 commits into
microsoft:mainfrom
jzakharovnv:pr3-cli-stride-flags

Conversation

@jzakharovnv

Copy link
Copy Markdown
Collaborator

Building off of #8518, this PR adds two new command-line flags that override the ArrayStride of the descriptor heap runtime arrays emitted by -fspv-use-descriptor-heap. It is part 3/4 in a series.

-fvk-resource-heap-stride and -fvk-sampler-heap-stride sets the stride for ResourceDescriptorHeap SamplerDescriptorHeap arrays respectively. N and M must be a power of two in [8, 256]. When set, the CLI value takes the highest precedence.

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.

@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch from 190990b to 7429afb Compare June 4, 2026 21:58
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 pr3-cli-stride-flags branch 2 times, most recently from 1e2a278 to 5e7b928 Compare June 4, 2026 22:59
@jzakharovnv

Copy link
Copy Markdown
Collaborator Author

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

@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch from 5e7b928 to 9c5badc Compare June 29, 2026 21:45
@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch from 9c5badc to ff7bb88 Compare July 6, 2026 20:08
Comment thread docs/SPIR-V.rst Outdated
can be overridden, in increasing order of precedence:

- ``[[vk::resource_heap_stride_constant_id(id)]]`` and
``[[vk::sampler_heap_stride_constant_id(id)]]`` on a ``uint`` global emit the

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.

These spec constant attributes are actually in #8520, right? Maybe move them there? This way, this PR just handles the flags.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this was a bit clumsy on my part. Will fix the documentation to remove mention of (now dropped feature) stride spec const attributes.

!handleHeapStride(Args, OPT_fvk_sampler_heap_stride,
&opts.SpirvOptions.samplerHeapStride,
"-fvk-sampler-heap-stride", errors)) {
return 1;

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.

If both flags are wrong, this will short-circuit and only give a single error message. Could you make both calls always happen and return the aggregate? Something like this:

bool ok = handleHeapStride(...resource...);
ok &= handleHeapStride(...sampler...);
if (!ok) return 1;

@github-project-automation github-project-automation Bot moved this from New to In progress in HLSL Roadmap Jul 17, 2026
@dnovillo dnovillo added the spirv Work related to SPIR-V label Jul 17, 2026
@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch 2 times, most recently from 5925cdb to 6bc5a9e Compare July 17, 2026 22:26
Extends the SPV_EXT_descriptor_heap native heap lowering to cover RaytracingAccelerationStructure resources loaded from ResourceDescriptorHeap.

Acceleration structure descriptors are accessed via OpUntypedAccessChainKHR into a runtime array of OpTypeAccelerationStructureKHR, consistent with the image and sampler paths added in the previous commit.
@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch from 6bc5a9e to c69d8a0 Compare July 23, 2026 19:35

@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 the fixes. LGTM now.

@jzakharovnv
jzakharovnv force-pushed the pr3-cli-stride-flags branch from fcc9b25 to 2feca89 Compare July 24, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spirv Work related to SPIR-V

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants