Skip to content

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

Open
Jonathan Zakharov (jzakharovnv) wants to merge 12 commits into
microsoft:mainfrom
jzakharovnv:pr3-cli-stride-flags
Open

Jonathan Zakharov (jzakharovnv) wants to merge 12 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.

Diego Novillo (@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
Jonathan Zakharov (jzakharovnv) force-pushed the pr3-cli-stride-flags branch 3 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"

Comment thread docs/SPIR-V.rst Resolved
Comment thread lib/DxcSupport/HLSLOptions.cpp Resolved
@github-project-automation github-project-automation Bot moved this from New to In progress in HLSL Roadmap Jul 17, 2026
@dnovillo Diego Novillo (dnovillo) added the spirv Work related to SPIR-V label Jul 17, 2026
@jzakharovnv
Jonathan Zakharov (jzakharovnv) force-pushed the pr3-cli-stride-flags branch 3 times, most recently from 6bc5a9e to c69d8a0 Compare July 23, 2026 19:35

@dnovillo Diego Novillo (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
Jonathan Zakharov (jzakharovnv) force-pushed the pr3-cli-stride-flags branch 2 times, most recently from 2feca89 to 7edda02 Compare July 29, 2026 21:05
@damyanp

Copy link
Copy Markdown
Member

[Auto-generated note from Damyan Pepper (@damyanp)]

This looks like a user-visible bug fix/feature change. Please add (or point to) the corresponding entry in docs/ReleaseNotes.md.

If release-note coverage is planned in a related PR (including one that hasn’t been submitted yet), please mention that plan/link so we can avoid duplicate notes.

Copilot AI balanced review requested due to automatic review settings August 4, 2026 00:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds configurable resource and sampler descriptor-heap strides while expanding native SPV_EXT_descriptor_heap lowering.

Changes:

  • Adds and validates the two stride CLI options.
  • Supports literal and computed descriptor-array strides, including acceleration structures.
  • Expands documentation and SPIR-V regression coverage.

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tools/clang/unittests/SPIRV/SpirvContextTest.cpp Tests runtime-array uniquing.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.typed-formats.hlsl Tests typed image formats.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texturecube.hlsl Tests cube textures.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture.hlsl Tests buffer textures.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture-sampler-assignment.hlsl Tests texture/sampler reassignment.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture-ms.hlsl Tests multisampled textures.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture-dims.hlsl Tests sampled texture dimensions.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.structured-buffer-atomic.hlsl Tests structured-buffer atomics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.stride-cli.hlsl Tests literal CLI strides.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.stride-cli-permute.hlsl Tests stride values and validation.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.static-global.hlsl Tests static resource aliases.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.sampler-comparison.hlsl Tests comparison samplers.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.sample-grad-bias.hlsl Tests gradient and bias sampling.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.rwtexture-dims.hlsl Tests storage texture dimensions.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.rwtexture-atomics.hlsl Tests untyped image atomics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.rwbyteaddressbuffer.hlsl Tests writable byte buffers.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.nonuniform.hlsl Tests divergent heap indexing.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.mixed-bound.hlsl Tests bound/heap coexistence.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.mixed-alias.error.hlsl Tests mixed-alias diagnostics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.load-offset.hlsl Tests texture-load offsets.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.groupshared.hlsl Tests groupshared interoperability.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.gather.hlsl Tests texture gathers.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.function-params.hlsl Tests resource parameters.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.discarded.error.hlsl Tests discarded-access diagnostics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.counter-ops.error.hlsl Tests unsupported counter diagnostics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.constant-texture-buffer.hlsl Tests constant/texture buffers.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.constant-buffer-assignment.hlsl Tests constant-buffer reassignment.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.buffer.hlsl Tests buffer heap lowering.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.hlsl Tests computed default strides.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.accelstruct.hlsl Tests acceleration-structure strides.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.append-consume.error.hlsl Tests append/consume diagnostics.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.acceleration-structure.stride.error.hlsl Tests acceleration-stride errors.
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.acceleration-structure.hlsl Tests acceleration-structure loads.
tools/clang/test/CodeGenSPIRV/resource-heap-ext-texture.hlsl Removes superseded coverage.
tools/clang/lib/SPIRV/SpirvType.cpp Includes stride IDs in type equality.
tools/clang/lib/SPIRV/SpirvInstruction.cpp Implements new SPIR-V instructions.
tools/clang/lib/SPIRV/SpirvEmitter.h Declares descriptor-heap helpers/state.
tools/clang/lib/SPIRV/SpirvEmitter.cpp Implements native heap lowering and strides.
tools/clang/lib/SPIRV/SpirvContext.cpp Uniques extended descriptor types.
tools/clang/lib/SPIRV/SpirvBuilder.cpp Builds computed heap strides.
tools/clang/lib/SPIRV/LowerTypeVisitor.cpp Lowers untyped image pointers.
tools/clang/lib/SPIRV/EmitVisitor.h Declares new emission handlers.
tools/clang/lib/SPIRV/EmitVisitor.cpp Emits new types, constants, and decorations.
tools/clang/lib/SPIRV/DeclResultIdMapper.h Declares function alias support.
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp Implements function aliases.
tools/clang/lib/SPIRV/CapabilityVisitor.cpp Requires Vulkan 1.3 for native heaps.
tools/clang/lib/SPIRV/AstTypeProbe.cpp Detects acceleration structures.
tools/clang/include/clang/SPIRV/SpirvVisitor.h Extends visitor dispatch.
tools/clang/include/clang/SPIRV/SpirvType.h Stores runtime-array stride IDs.
tools/clang/include/clang/SPIRV/SpirvInstruction.h Defines new instruction classes.
tools/clang/include/clang/SPIRV/SpirvContext.h Exposes extended type uniquing.
tools/clang/include/clang/SPIRV/SpirvBuilder.h Exposes stride construction APIs.
tools/clang/include/clang/SPIRV/AstTypeProbe.h Declares acceleration-type detection.
lib/DxcSupport/HLSLOptions.cpp Parses and validates stride options.
include/dxc/Support/SPIRVOptions.h Stores stride overrides.
include/dxc/Support/HLSLOptions.td Defines the CLI flags.
docs/SPIR-V.rst Documents native heaps and strides.

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved
Comment thread lib/DxcSupport/HLSLOptions.cpp Resolved
Comment thread lib/DxcSupport/HLSLOptions.cpp Resolved
Comment thread include/dxc/Support/HLSLOptions.td Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Image atomic lowering now reverses base and coordinate evaluation order, potentially changing shaders with side effects.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.hlsl:62

  • Use the possessive “its” here.
  • Files reviewed: 64/64 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved
Copilot AI balanced review requested due to automatic review settings November 2, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Jonathan Zakharov (jzakharovnv) added a commit to jzakharovnv/DirectXShaderCompiler that referenced this pull request Nov 2, 2026
Copilot AI balanced review requested due to automatic review settings November 2, 2026 22:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the descriptor-heap stride changes.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The stride tests can miss regressions because the buffer override check can match a texture array, while the forbidden-instruction checks do not cover the full disassembly.

3 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Both regression tests scope their negative checks too narrowly, allowing forbidden stride-related SPIR-V instructions emitted before or between positive matches to go undetected.

3 open issues

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed for an unpublished concern about the release-note entry exceeding the contribution guidelines’ single-sentence limit.

1 open issue
2 resolved since last review

Review effort: Balanced

@pow2clk Gregory Roth (pow2clk) 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.

It looks good overall! I'd like to understand the need for the new onSamplerHeap parameter before I sign off.

The copy editing suggestions are purely optional.

Comment thread docs/ReleaseNotes.md Resolved
Comment thread docs/ReleaseNotes.md Outdated
Comment on lines +32 to +33
descriptors; otherwise compilation fails, unless `-fvk-resource-heap-stride`
is given.

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'm not actually suggesting these just get deleted, but these would be replaced by my suggestion above

Suggested change
descriptors; otherwise compilation fails, unless `-fvk-resource-heap-stride`
is given.

Comment thread docs/SPIR-V.rst Resolved
Comment thread docs/SPIR-V.rst Resolved
Comment thread docs/SPIR-V.rst Resolved
Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human judgment is needed to determine whether the unpublished release-note formatting concern should affect approval.

1 open issue

Review effort: Balanced

This branch has not been deployed

No deployments
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.

6 participants