Repository navigation
[SPIR-V] Add descriptor heap RaytracingAccelerationStructure support - #8518
Gregory Roth (pow2clk) merged 13 commits into
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
d899b05 to
b12b9ea
Compare
|
@microsoft-github-policy-service agree company="NVIDIA" |
b12b9ea to
23eca97
Compare
23aff82 to
02f3581
Compare
Diego Novillo (dnovillo)
left a comment
There was a problem hiding this comment.
Only a question left on detecting RT usage of the heap.
6293723 to
20dd181
Compare
There was a problem hiding this comment.
Pull request overview
Extends native SPIR-V descriptor-heap lowering to acceleration structures and broader resource operations.
Changes:
- Adds descriptor-size-based heap strides, including acceleration structures.
- Adds native buffer, image, sampler, atomic, and alias lowering.
- Expands SPIR-V tests and documentation.
Reviewed changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
tools/clang/unittests/SPIRV/SpirvContextTest.cpp |
Extends runtime-array uniqueness tests. |
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 and samplers. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture.hlsl |
Tests texel buffers. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.texture-sampler-assignment.hlsl |
Tests resource 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.static-global.hlsl |
Tests static global resources. |
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 nonuniform-index handling. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.mixed-bound.hlsl |
Tests bound and heap resources together. |
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 gather operations. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.function-params.hlsl |
Tests resource function 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 and 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 native buffer lowering. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.hlsl |
Tests shared heap strides. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.accelstruct.hlsl |
Tests acceleration-structure stride inclusion. |
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 missing acceleration stride diagnostics. |
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.acceleration-structure.hlsl |
Tests acceleration-structure heap loads. |
tools/clang/test/CodeGenSPIRV/resource-heap-ext-texture.hlsl |
Removes the superseded aggregate test. |
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 heap-lowering and alias state. |
tools/clang/lib/SPIRV/SpirvEmitter.cpp |
Implements native heap lowering and acceleration support. |
tools/clang/lib/SPIRV/SpirvContext.cpp |
Canonicalizes buffer and runtime-array types. |
tools/clang/lib/SPIRV/SpirvBuilder.cpp |
Builds descriptor-size constants and 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 instructions and decorations. |
tools/clang/lib/SPIRV/DeclResultIdMapper.h |
Declares function-variable aliases. |
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp |
Registers function-variable aliases. |
tools/clang/lib/SPIRV/CapabilityVisitor.cpp |
Enforces Vulkan 1.3 for native heaps. |
tools/clang/lib/SPIRV/AstTypeProbe.cpp |
Recognizes acceleration-structure types. |
tools/clang/include/clang/SPIRV/SpirvVisitor.h |
Adds visitor methods. |
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 |
Extends type-context APIs. |
tools/clang/include/clang/SPIRV/SpirvBuilder.h |
Exposes descriptor-stride builders. |
tools/clang/include/clang/SPIRV/AstTypeProbe.h |
Declares acceleration-type probing. |
docs/SPIR-V.rst |
Documents native descriptor heaps. |
Comments suppressed due to low confidence (1)
tools/clang/lib/SPIRV/SpirvEmitter.cpp:7072
- Only casts are stripped here, so a syntactically valid parenthesized heap base such as
(ResourceDescriptorHeap)[i]is diagnosed as unsupported even though it still refers directly to the builtin variable. UseIgnoreParenCasts()consistently when resolving the base declaration.
const auto *declRefExpr = dyn_cast<DeclRefExpr>(baseExpr->IgnoreCasts());
const auto *decl =
declRefExpr ? dyn_cast<VarDecl>(declRefExpr->getDecl()) : nullptr;
if (!decl) {
emitError("unsupported ResourceDescriptorHeap/SamplerDescriptorHeap "
"expression",
baseExpr->getExprLoc());
return nullptr;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
20dd181 to
568efbb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 52 out of 52 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
tools/clang/lib/SPIRV/SpirvEmitter.cpp:5315
- A heap-to-heap reassignment of
RaytracingAccelerationStructurealso reaches this branch becausemixingDetectedincludes(isASType && wasHeap)regardless ofsrcIsHeap. That assignment does not mix bound and heap resources, so this diagnostic is misleading; report the unsupported AS reassignment separately.
emitError("mixing bound and descriptor heap resources in the same variable "
"is not supported with SPV_EXT_descriptor_heap",
loc);
tools/clang/test/CodeGenSPIRV/sm6_6.descriptorheap.ext.array-stride.hlsl:62
- Use the possessive “its” rather than “it's” (“it is”).
// The sampler array just uses the sampler size as it's stride.
docs/SPIR-V.rst:2089
- This is a significant user-visible compiler feature, but
docs/ReleaseNotes.mdhas no native descriptor-heap entry. Please add release-note coverage, or point to the shared release note planned for this four-PR series.
When ``-fspv-use-descriptor-heap`` is specified, DXC lowers
``ResourceDescriptorHeap`` and ``SamplerDescriptorHeap`` through
``SPV_EXT_descriptor_heap`` instead of the default emulated heap path. This
also requires ``SPV_KHR_untyped_pointers`` and ``-fspv-target-env=vulkan1.3``
|
Added an analysis on this series: #8517 (comment) |
Gregory Roth (pow2clk)
left a comment
There was a problem hiding this comment.
I don't know why copilot is not acknowledging the change to sm6_6.descriptorheap.ext.array-stride.accelstruct-ext.hlsl, but it all looks good to me!
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Looks like one of the tests I added is failing on Azure. Investigating |
Head branch was pushed to by a user without write access
|
Seems the issue was that a test was hitting an unexpected assert in debug builds, should be fixed now |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 8518 in repo microsoft/DirectXShaderCompiler |
Thank you Copilot lol |
|
/azp run |
1 similar comment
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |


Building off of #8517, this PR extends the SPV_EXT_descriptor_heap native heap lowering to cover RaytracingAccelerationStructure resources loaded from ResourceDescriptorHeap. It is part 2/4 in a series.
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.
Assisted by an AI agent
Diego Novillo (@dnovillo)