Skip to content

Add InstanceContributionToHitGroupIndex YAML field and shader query#1286

Merged
EmilioLaiso merged 1 commit into
llvm:mainfrom
Traverse-Research:inlinert-instance-contribution
Jun 15, 2026
Merged

Add InstanceContributionToHitGroupIndex YAML field and shader query#1286
EmilioLaiso merged 1 commit into
llvm:mainfrom
Traverse-Research:inlinert-instance-contribution

Conversation

@MarijnS95

@MarijnS95 MarijnS95 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Depends on #1245

Summary

Adds a 24-bit per-instance InstanceContributionToHitGroupIndex slot on AccelerationStructureInstance / InstanceDesc, plumbed through:

  • DX: D3D12_RAYTRACING_INSTANCE_DESC.InstanceContributionToHitGroupIndex
  • Vulkan: instanceShaderBindingTableRecordOffset
  • Metal: the IR converter's addressOfInstanceContributions sidecar (the existing stub buffer in setupDispatch is now filled from per-instance values instead of being hardcoded to zeros — intersectionFunctionTableOffset is left at zero because the IRC bypasses it for inline RT)

The covering test (Feature/InlineRT/instance-contribution.test) verifies CommittedInstanceContributionToHitGroupIndex() returns the per-instance value across three distinct instances, including the top-of-range 0xFFFFFF.

Part of the inline-RT test coverage epic (#1258).

Test plan

Local on an NVIDIA RTX 3060:

  • Linux Vulkan (native offloader)
  • Linux D3D12 (Wine + vkd3d-proton + cross-compiled offloader.exe)
  • Windows Vulkan (native offloader.exe)
  • Windows D3D12 (native offloader.exe)

CI (RT-capable runners):

  • windows-nvidia D3D12 (RaytracingTier 1.2)
  • windows-intel VK (VK_KHR_ray_tracing_pipeline)
  • macOS Metal (supportsRaytracing)

@MarijnS95 MarijnS95 marked this pull request as draft June 4, 2026 16:11
@MarijnS95 MarijnS95 force-pushed the inlinert-instance-contribution branch 2 times, most recently from b7fb53e to 852802f Compare June 11, 2026 13:46
Adds a 24-bit per-instance InstanceContributionToHitGroupIndex slot on
AccelerationStructureInstance / InstanceDesc, plumbed through DX
(D3D12_RAYTRACING_INSTANCE_DESC), VK (instanceShaderBindingTableRecord-
Offset), and the Metal IR converter's addressOfInstanceContributions
sidecar. The covering test verifies CommittedInstanceContributionToHit-
GroupIndex() returns the per-instance value across distinct instances,
including the top-of-range 0xFFFFFF.

Part of the inline-RT test coverage epic
(llvm#1258).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MarijnS95 MarijnS95 marked this pull request as ready for review June 11, 2026 16:57
@MarijnS95 MarijnS95 force-pushed the inlinert-instance-contribution branch from 852802f to 9d292c0 Compare June 11, 2026 16:57
@EmilioLaiso EmilioLaiso merged commit e22dcf7 into llvm:main Jun 15, 2026
26 checks passed
EmilioLaiso pushed a commit that referenced this pull request Jun 24, 2026
Depends on #1245, #1286

## Summary
Introduces `AccelerationStructureInstanceFlags` with bit values that
intentionally match `D3D12_RAYTRACING_INSTANCE_FLAGS`,
`VkGeometryInstanceFlagBitsKHR`, and
`MTLAccelerationStructureInstanceOptions` so the value passes straight
through each backend's instance fill with a single `static_cast`. YAML
exposes the field as a bitset list (e.g. `InstanceFlags:
[TriangleCullDisable, ForceOpaque]`).

The covering test (`Feature/InlineRT/instance-flags.test`) sets
`TriangleFrontCounterclockwise` on one of two instances of the same
single-triangle BLAS and verifies `CommittedTriangleFrontFace()` flips —
same world-space ray, same vertices, only the per-instance flag changes.

Part of the inline-RT test coverage epic
(#1258).

## Test plan

Local on an NVIDIA RTX 3060:
- [x] Linux Vulkan (native `offloader`)
- [ ] Linux D3D12 (Wine + vkd3d-proton + cross-compiled `offloader.exe`)
- [ ] Windows Vulkan (native `offloader.exe`)
- [ ] Windows D3D12 (native `offloader.exe`)

CI (RT-capable runners):
- [x] windows-nvidia D3D12 (`RaytracingTier 1.2`)
- [ ] windows-intel VK (`VK_KHR_ray_tracing_pipeline`)
- [x] macOS Metal (`supportsRaytracing`)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

4 participants