Skip to content

Conversation

@jkiviluoto-nv
Copy link
Contributor

Fixes #8631

Implements automatic detection and binding of descriptor handle types (.Handle) in the slang-test framework, enabling execution tests for bindless descriptor features.

Changes:

  • Add isDescriptorHandleType() to detect .Handle types via reflection
  • Modify assignBuffer/Texture/Sampler to allocate and bind descriptor handles
  • Fix resource lifetime by adding all resources to TestResourceContext
  • Add test case for descriptor handle with TEST_INPUT directives

This fixes Vulkan validation errors (VUID-vkDestroyBuffer-buffer-00922) where buffers were destroyed while still in use by command buffers when using bindless descriptors.

The implementation uses getDescriptorHandle() on resources and setDescriptorHandle() on shader cursors to properly bind handles for Vulkan and D3D12 backends.

@jkiviluoto-nv jkiviluoto-nv requested a review from a team as a code owner October 24, 2025 15:10
@jkiviluoto-nv jkiviluoto-nv added the pr: non-breaking PRs without breaking changes label Oct 24, 2025
@jkiviluoto-nv jkiviluoto-nv marked this pull request as draft October 24, 2025 15:33
@jkiviluoto-nv jkiviluoto-nv force-pushed the feature/descriptor-handle-support branch 2 times, most recently from 2e9499e to 19290ee Compare October 27, 2025 14:28
@jkiviluoto-nv jkiviluoto-nv marked this pull request as ready for review October 28, 2025 07:35
Fixes shader-slang#8631

Implements automatic detection and binding of descriptor handle types
(.Handle) in the slang-test framework, enabling execution tests for
bindless descriptor features.

Detection Strategy: Descriptor handles are lowered to uint2 (SPIRV/DX12)
stored in uniform data. The detector specifically matches this pattern
and excludes uint64 (device addresses) and Resource types (Metal/CUDA
pointers) to avoid false positives. If getDescriptorHandle() fails,
falls back to regular binding.

Changes:
- Add isDescriptorHandleType() detecting uint2 in UNIFORM category
- Modify assignBuffer/Texture/Sampler to allocate and bind descriptor
  handles
- Determine access mode via getResourceAccess() reflection
- Fix resource lifetime by adding all resources to TestResourceContext
- Add test cases requiring -render-feature bindless and
  -emit-spirv-directly

This fixes Vulkan validation errors (VUID-vkDestroyBuffer-buffer-00922)
where buffers were destroyed while still in use by command buffers when
using bindless descriptors
@jkiviluoto-nv jkiviluoto-nv force-pushed the feature/descriptor-handle-support branch from 19290ee to b5d8cde Compare October 28, 2025 07:36
// Descriptor handles in SPIRV/DX12 with bindless are lowered to uint2
// stored in uniform data.
//
// IMPORTANT: We only check for uint2, NOT uint64!
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we check uint64?
It's used when spvBindlessTextureNV is enabled. Though we might not have executable test for sampler or storage image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was a mixup with device addresses which are also uint64. I'll add additional check for spvBindlessTextureNV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaizhangNV please have a look now.

Copy link
Contributor

@kaizhangNV kaizhangNV left a comment

Choose a reason for hiding this comment

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

LGTM

@jkiviluoto-nv jkiviluoto-nv added this pull request to the merge queue Oct 30, 2025
Merged via the queue into shader-slang:master with commit 2371d57 Oct 30, 2025
37 checks passed
jvepsalainen-nv pushed a commit to jvepsalainen-nv/slang that referenced this pull request Nov 4, 2025
…8814)

Fixes shader-slang#8631

Implements automatic detection and binding of descriptor handle types
(.Handle) in the slang-test framework, enabling execution tests for
bindless descriptor features.

Changes:
 - Add isDescriptorHandleType() to detect .Handle types via reflection
- Modify assignBuffer/Texture/Sampler to allocate and bind descriptor
handles
 - Fix resource lifetime by adding all resources to TestResourceContext
 - Add test case for descriptor handle with TEST_INPUT directives

This fixes Vulkan validation errors (VUID-vkDestroyBuffer-buffer-00922)
where buffers were destroyed while still in use by command buffers when
using bindless descriptors.

The implementation uses getDescriptorHandle() on resources and
setDescriptorHandle() on shader cursors to properly bind handles for
Vulkan and D3D12 backends.
juliusikkala pushed a commit to juliusikkala/slang that referenced this pull request Nov 12, 2025
…8814)

Fixes shader-slang#8631

Implements automatic detection and binding of descriptor handle types
(.Handle) in the slang-test framework, enabling execution tests for
bindless descriptor features.

Changes:
 - Add isDescriptorHandleType() to detect .Handle types via reflection
- Modify assignBuffer/Texture/Sampler to allocate and bind descriptor
handles
 - Fix resource lifetime by adding all resources to TestResourceContext
 - Add test case for descriptor handle with TEST_INPUT directives

This fixes Vulkan validation errors (VUID-vkDestroyBuffer-buffer-00922)
where buffers were destroyed while still in use by command buffers when
using bindless descriptors.

The implementation uses getDescriptorHandle() on resources and
setDescriptorHandle() on shader cursors to properly bind handles for
Vulkan and D3D12 backends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A gap in testing BindlessStorage

3 participants