Add SPV_EXT_descriptor_heap reflection support - #344
Merged
Conversation
Parses OpTypeBufferEXT and the untyped pointer ops (OpUntypedVariableKHR, OpUntypedAccessChainKHR). Reflects per-entry-point resource and sampler heap accesses. Includes test fixtures and YAML goldens.
- output_stream.cpp: print `(unspecified)` instead of `(implicit)` for UINT32_MAX stride in the text dump, and append ` # UNSPECIFIED` to the YAML stride line for resource and sampler heap accesses - tests/descriptor_heap YAML goldens: regenerate stride lines with the new annotation - tests/test-spirv-reflect.cpp: remove five fixture entries for files deleted in the prior fixture cleanup; the missing SPVs were causing every parameterized test to fail with a SetUp exception - spirv_reflect.c FindAccessChainBaseVariable: recognize SpvOpUntypedVariableKHR as a terminal base alongside SpvOpVariable so untyped-pointer access chains can resolve. Diagnostic fprintf is retained while the SpvOpBufferPointerEXT crash on multi_type_heap.comp.spv is being worked out and will be removed in the follow-up that closes that path.
- FindAccessChainBaseVariable steps back through OpBufferPointerEXT; default: assert(false) is kept so any future unhandled op still crashes loudly in Debug - OpUntypedAccessChainKHR and the three sibling variants (OpUntypedInBoundsAccessChainKHR, OpUntypedPtrAccessChainKHR, OpUntypedInBoundsPtrAccessChainKHR) are now counted in p_parser->access_chain_count and parsed into p_parser->access_chains with correct operand offsets (Base at word 4; PtrAccessChain variants push indexes to word 6 to account for the Element operand). This lets FindAccessChain resolve them like a regular OpAccessChain - Heap-access enumeration filter recognizes all four untyped variants - OpUntypedArrayLengthKHR and OpUntypedImageTexelPointerEXT are tracked in the function-variable count and access-list passes alongside OpArrayLength and OpImageTexelPointer - OpMemberDecorateIdEXT is added to the ParseDecorations instruction filter and the member_offset adjustment; SpvDecorationOffsetIdEXT now resolves its constant-id operand the same way SpvDecorationArrayStrideIdEXT does so id-form member offsets are reflected - Remove the diagnostic fprintf and <stdio.h> include left over from the crash investigation
spencer-lunarg
approved these changes
Jun 23, 2026
spencer-lunarg
left a comment
Contributor
There was a problem hiding this comment.
looks good enough to me, just need to solve the CI issue
The check-formatting CI job runs clang-format-diff over changed headers
(**/*.h) and flagged both tests/descriptor_heap/{glsl,slang}/shaderio.h.
The structs used Allman-style braces, which the Google-based style rewrites.
Move the opening brace onto the struct line to match the existing struct
style in spirv_reflect.h, and wrap each file body in
// clang-format off / // clang-format on so the intentional column
alignment of the shared shader-header layout is preserved, consistent
with how spirv_reflect.h exempts its aligned type definitions.
byte_address_buffer_0 and rw_byte_address_buffer are lib_6_4 shaders with two entry points (ClosestHit0 and AnyHit1). The per-entry-point entry_point_heap_accesses YAML section emits one block per entry point, but the golden files only contained the ClosestHit0 block, so the generated output was larger than the golden and the CheckYamlOutput test failed on the size comparison. Regenerate both goldens so they include the AnyHit1 block. The ByteAddressBuffer offsets are kept in the [4, 5, 11, 13] order the golden already had so the Linux test job continues to match; the platform-dependent ordering of those offsets is tracked separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for SPV_EXT_descriptor_heap and updated support for SPV_KHR_untyped_pointers. Test cases are a best effort since full compiler support for SPV_EXT_descriptor_heap is still in flight. A follow-up PR is planned once compiler support lands. Decorations, builtins, and instructions are parsed for compliance. These may need to be adjusted in the future.