[SPIR-V] Add SPV_EXT_descriptor_heap + SPV_KHR_untyped_pointers codegen#8517
[SPIR-V] Add SPV_EXT_descriptor_heap + SPV_KHR_untyped_pointers codegen#8517jzakharovnv wants to merge 1 commit into
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
4b4b143 to
f640327
Compare
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.
f640327 to
cbcae38
Compare
|
@microsoft-github-policy-service agree company="NVIDIA" |
dnovillo
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
I think I would float these defaults to SpirvEmitter.h and document where the seemingly magic values 32 and 64 come from.
There was a problem hiding this comment.
Definitely agree that these need some better documentation. I placed them at this scope because they seem a little niche, and I want to try to avoid polluting very wide scopes, but I can move them up.
| constexpr uint32_t kDefaultSamplerHeapStride = 32; | ||
| const uint32_t stride = | ||
| onSamplerHeap ? kDefaultSamplerHeapStride : kDefaultResourceHeapStride; | ||
| return spvContext.getRuntimeArrayType(elemType, stride); |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Yes, there is a healthy amount of testing in the last 2 PRs of this series, but I neglected to have for this one. I can fix that.
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