Commit 2fd3384
Bind acceleration structures and enable the InlineRT tests
Wire up acceleration-structure descriptor binding end-to-end across all
three backends so shaders can actually consume the TLAS that
buildPipelineAccelerationStructures() produced — completing the stack
and promoting the three InlineRT tests from XFAIL to passing.
Per-resource AS handling lands in a new per-backend createAS() (paired
with createSRV() / createUAV() / createCBV()): a pure single-create
that queries TLAS sizes via Dev.getTLASBuildSizes() and allocates the
handle via Dev.createTLAS(), returning the unique_ptr to the caller. No
InvocationState or Pipeline access — the multi-create
(createBuffers() / createResources()) records the handle in
InvocationState::TLASes (a StringMap keyed by TLASDesc::Name) and
wires a non-owning AS pointer into the per-resource bundle the binding
loop reads. The shared AS-build helper picks up that map and walks
P.AccelStructs.TLAS to pair each YAML descriptor with its pre-allocated
handle by name (TLASes without a map entry are skipped, i.e. declared
but unbound). BLAS handles are still allocated by the helper itself
since BLASes aren't user-bindable.
executeProgram() in each backend now runs as:
createBuffers / createResources (createAS() allocates TLAS handles)
open encoder → buildPipelineAccelerationStructures() → end
Vulkan: createDescriptorPool() counts AS descriptors in a separate
scalar (the KHR enum value 1000150000 doesn't fit in the indexed
array used for the core types) and emits one VkDescriptorPoolSize
for them. createDescriptorSets() reads the resolved
VulkanAccelerationStructure handle from ResourceRef.AS (populated by
createResources()) and writes it through a
VkWriteDescriptorSetAccelerationStructureKHR chained on the descriptor
write's pNext. The dispatch's pre-barrier dst access now includes
VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR so the prior AS-build's
writes are made visible to the shader's RayQuery reads. Device creation
also enables VK_KHR_ray_query when supported so the RayQuery shader
instructions actually function. copyResourceDataToDevice() short-
circuits AS bundles (no host buffer to barrier) via a new
ResourceBundle::isAccelerationStructure() predicate.
DX12: writes a D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE
SRV with the AS GPU virtual address as Location into the heap slot
that createBuffers() reserved (CreateShaderResourceView() with a null
resource — the AS data lives in the buffer pointed to by Location).
Metal: the Metal shader converter doesn't bind the AS directly; the
shader reads a buffer containing an IRRaytracingAccelerationStructure-
GPUHeader that holds the AS's gpuResourceID plus a pointer to an
instance-contributions array. createBuffers() allocates and fills both
buffers per AS-descriptor entry, then points the descriptor at the
header buffer's GPU address. The TLAS itself is built with the UserID
instance-descriptor variant so HLSL CommittedInstanceID() returns the
YAML-specified per-instance ID instead of the array index.
The three InlineRT tests now actually exercise the AS end-to-end:
TraceRayInline() issues a RayQuery against `Scene` and writes a
hit-dependent value into `Output` (the instance ID for multi-instance,
1/0 otherwise). The catch-all `XFAIL: *` is dropped; `XFAIL: Clang`
remains. The test shaders gain explicit `[[vk::binding]]` annotations
since their `t0`/`u0` registers would otherwise collide under the
default dxc HLSL→SPIR-V mapping.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4c91450 commit 2fd3384
8 files changed
Lines changed: 360 additions & 103 deletions
File tree
- include/API
- lib/API
- DX
- MTL
- VK
- test/Feature/InlineRT
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
336 | 333 | | |
337 | 334 | | |
338 | 335 | | |
339 | 336 | | |
340 | 337 | | |
341 | 338 | | |
342 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
343 | 342 | | |
344 | 343 | | |
345 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
1084 | 1087 | | |
1085 | 1088 | | |
| 1089 | + | |
1086 | 1090 | | |
1087 | 1091 | | |
1088 | 1092 | | |
1089 | | - | |
| 1093 | + | |
1090 | 1094 | | |
1091 | 1095 | | |
1092 | 1096 | | |
1093 | 1097 | | |
1094 | 1098 | | |
1095 | 1099 | | |
| 1100 | + | |
1096 | 1101 | | |
1097 | 1102 | | |
1098 | 1103 | | |
| |||
1121 | 1126 | | |
1122 | 1127 | | |
1123 | 1128 | | |
1124 | | - | |
| 1129 | + | |
1125 | 1130 | | |
1126 | | - | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
1127 | 1134 | | |
1128 | 1135 | | |
1129 | 1136 | | |
| |||
2007 | 2014 | | |
2008 | 2015 | | |
2009 | 2016 | | |
2010 | | - | |
2011 | | - | |
2012 | | - | |
2013 | 2017 | | |
2014 | 2018 | | |
2015 | 2019 | | |
2016 | 2020 | | |
2017 | 2021 | | |
2018 | | - | |
2019 | | - | |
2020 | | - | |
2021 | | - | |
2022 | | - | |
2023 | | - | |
2024 | | - | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
2025 | 2051 | | |
2026 | 2052 | | |
2027 | 2053 | | |
| |||
2228 | 2254 | | |
2229 | 2255 | | |
2230 | 2256 | | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
2231 | 2267 | | |
2232 | 2268 | | |
2233 | 2269 | | |
2234 | 2270 | | |
2235 | 2271 | | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
2236 | 2286 | | |
2237 | 2287 | | |
2238 | 2288 | | |
| |||
2723 | 2773 | | |
2724 | 2774 | | |
2725 | 2775 | | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
2726 | 2780 | | |
2727 | 2781 | | |
2728 | 2782 | | |
2729 | 2783 | | |
2730 | 2784 | | |
2731 | | - | |
| 2785 | + | |
| 2786 | + | |
2732 | 2787 | | |
2733 | 2788 | | |
2734 | 2789 | | |
2735 | 2790 | | |
2736 | | - | |
2737 | | - | |
2738 | | - | |
2739 | | - | |
2740 | 2791 | | |
2741 | 2792 | | |
2742 | 2793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | | - | |
| 118 | + | |
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| |||
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | | - | |
165 | | - | |
| 166 | + | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
177 | | - | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
182 | 187 | | |
| 188 | + | |
183 | 189 | | |
184 | 190 | | |
185 | | - | |
186 | | - | |
| 191 | + | |
| 192 | + | |
187 | 193 | | |
188 | 194 | | |
189 | 195 | | |
| |||
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
197 | | - | |
| 203 | + | |
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
201 | 207 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | 208 | | |
213 | 209 | | |
214 | 210 | | |
| |||
0 commit comments