You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mirror the existing buffer/texture array pattern (`ArraySize` plus an
ArraySize-driven YAML field) for top-level acceleration structures so
shaders can declare `RaytracingAccelerationStructure Scenes[N]` and bind
N distinct TLASes through a single resource entry.
Schema (`include/Support/Pipeline.h`, `lib/Support/Pipeline.cpp`):
- `TLASDesc` gains `ArraySize` (default 1) and reshapes `Instances` from
`SmallVector<InstanceDesc>` to `SmallVector<SmallVector<InstanceDesc>>`
— outer vector indexed by array element, inner vector lists instances
for that element.
- `MappingTraits<TLASDesc>` dispatches on `ArraySize` the same way
`setData()` does for CPUBuffer: flat `Instances: [...]` for the
scalar case, list-of-lists for arrays, with an `ActualSize !=
ArraySize` validation error on mismatch.
- `Resource::getArraySize()` returns `TLASPtr->ArraySize` for AS
resources; moved out-of-line so it can dereference the (still
forward-declared at the Resource definition) `TLASDesc`.
- BLAS-name resolution in the pipeline post-process descends through
the extra layer of nesting.
Backend plumbing (VK / DX / MTL):
- `createAS()` now takes `uint32_t InstanceCount` directly (no Resource
/ Pipeline / InvocationState access) — pure single-create that just
sizes and allocates one TLAS.
- The multi-create (`createBuffers` / `createResources`) loops
`TD.ArraySize` and pushes one bundle entry per element plus N handles
into `InvocationState::TLASes`, which becomes
`StringMap<SmallVector<unique_ptr<AccelerationStructure>>>` (one
vector per `TLASDesc::Name`, sized to `ArraySize`).
- `buildPipelineAccelerationStructures()` walks `P.AccelStructs.TLAS`
and, for each name with a pre-allocated vector, builds one
`TLASBuildRequest` per element using `TD.Instances[Elt]` and
`Handles[Elt]`.
- Vulkan descriptor write iterates the bundle's `ResourceRefs` to fill
N entries of `pAccelerationStructures` and sets `descriptorCount =
R.getArraySize()` so the descriptor set sees the full array.
- DX's `bindSRV` AS branch already loops `ResBundle`; with the new
multi-entry bundle it now writes N RAYTRACING_ACCELERATION_STRUCTURE
SRVs into consecutive heap slots automatically. Heap sizing already
uses `getDescriptorCountWithFlattenedArrays()`.
- Metal's AS descriptor-binding loop now builds one
`IRRaytracingAccelerationStructureGPUHeader` + instance-contributions
buffer pair per array element and writes a descriptor entry per
element via `IRDescriptorTableSetAccelerationStructure`.
`MarkASResident` descends into the per-name vector.
Test: `test/Feature/InlineRT/tlas-array.test` declares `Scenes[2]`,
each TLAS carries one triangle instance with a distinct `InstanceID`
(10 and 20), and the shader writes each `CommittedInstanceID()` into
`Output[i]`. Gated on `acceleration-structure`, `XFAIL: Clang`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments