Skip to content

Add SPV_EXT_descriptor_heap reflection support - #344

Merged
spencer-lunarg merged 5 commits into
mainfrom
descriptor-heap-combined
Jun 24, 2026
Merged

Add SPV_EXT_descriptor_heap reflection support#344
spencer-lunarg merged 5 commits into
mainfrom
descriptor-heap-combined

Conversation

@chaoticbob

Copy link
Copy Markdown
Contributor

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.

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
@chaoticbob
chaoticbob requested a review from spencer-lunarg May 20, 2026 01:10

@spencer-lunarg spencer-lunarg 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.

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.
@spencer-lunarg
spencer-lunarg merged commit 0dc7802 into main Jun 24, 2026
5 checks passed
@spencer-lunarg
spencer-lunarg deleted the descriptor-heap-combined branch June 24, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants