Commit e0a2df3
[VK] Add ray tracing pipeline, SBT, and DispatchRays bring-up
First per-backend bring-up in the PSO raytracing series (#1268). Adds
the API surface (ComputeEncoder::dispatchRays, Device::createPipelineRT,
Device::createShaderBindingTable, RayTracingPipelineCreateDesc) plus the
Vulkan implementation behind it. D3D12 and Metal stub the new methods
with not-yet-supported errors; their bring-up lands in follow-up PRs.
The pre-existing YAML schema struct from PR #1270 is renamed
ShaderBindingTable -> ShaderBindingTableDesc so the bare name is free
for the runtime resource class (parallel to BLASDesc / TLASDesc vs
AccelerationStructure). A new include/API/ShaderBindingTable.h holds
the abstract runtime base; concrete backend SBT classes derive from it
with LLVM-style classof / cast<>.
The VulkanDevice's prior `RaytracingFunctions RT` lumped AS and RT
pipeline entry points together. They split into two structs —
`ASFunctions AS` and `RTPipelineFunctions RT` — matching the actual
feature-gate split (AS+ray-query is a complete configuration on its
own, RT pipeline is layered on top). `HasRayTracingSupport` renames
to `HasASSupport`, and a separate `HasRTPipelineSupport` tracks the
new VK_KHR_ray_tracing_pipeline extension.
Vulkan bring-up:
- Extension: VK_KHR_ray_tracing_pipeline is requested when reported,
with VkPhysicalDeviceRayTracingPipelineFeaturesKHR chained into the
pre-create feature query. After the query the gating
rayTracingPipeline bool is checked; capture-replay / trace-rays-
indirect / traversal-primitive-culling sub-features are cleared
since the tests don't exercise them.
- Function pointers: vkCreateRayTracingPipelinesKHR,
vkGetRayTracingShaderGroupHandlesKHR, vkCmdTraceRaysKHR.
- Properties: VkPhysicalDeviceRayTracingPipelinePropertiesKHR is
cached at device-create time for SBT handle size / alignment /
base-alignment.
- VKRayTracingPipelineState derives from VulkanPipelineState; an
IsRayTracing flag on the base lets the existing Vulkan cast<>
path stay polymorphic without adding a new GPUAPI value.
classof tests both the API and the flag. The derived class also
carries a StringMap<uint32_t> resolving each shader EntryPoint or
HitGroup Name to its index in the pipeline's group array, plus
per-bucket counts so the SBT builder can slice the contiguous
handle blob into raygen / miss / hit / callable regions.
- createPipelineRT builds a single VkShaderModule (the DXIL library
compiles to one SPIR-V module with multiple OpEntryPoints), then
one VkPipelineShaderStageCreateInfo per Shader entry and one
VkRayTracingShaderGroupCreateInfoKHR per general shader / hit
group. Pipeline layout is shared with the compute path via
createPipelineLayout, gated on all six RT stage flags so any
binding can be consumed from any RT shader.
- createShaderBindingTable allocates a host-visible coherent buffer
big enough for four regions and lays out each entry as
[handle bytes][localRootData bytes][padding-to-stride]. Per-region
stride = align(handleSize + max-local-root-data-in-region,
handleAlignment); per-region size = align(count * stride,
baseAlignment). LocalRootData support comes free from the PR1 SBT
schema; the test doesn't exercise it yet. Each region's
VkStridedDeviceAddressRegionKHR derives from the buffer's
vkGetBufferDeviceAddress.
- dispatchRays binds the pipeline at
VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, emits a pre-barrier with
AS_READ + SHADER_READ/WRITE dst access into
RAY_TRACING_SHADER_BIT_KHR, then calls vkCmdTraceRaysKHR with the
SBT's four region structs.
- createCommands picks the new bind point for RT pipelines so
vkCmdBindDescriptorSets binds to the right point. executeProgram's
isRayTracing branch builds a RayTracingPipelineCreateDesc from the
YAML, calls createPipelineRT then createShaderBindingTable, and
keeps both on InvocationState for the dispatch.
raygen-roundtrip.test now expects DirectX/Metal/Clang to XFAIL; on a
DXC + Vulkan combo with VK_KHR_ray_tracing_pipeline supported the test
should PASS via this implementation. On the user's Linux + clang-dxc
loop the test still XFAILs because clang-dxc doesn't yet lower
[shader("raygeneration")] entry points to SPIR-V, so the Clang XFAIL
token catches the compile failure. CI on a working DXC install will
exercise the runtime path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ca07851 commit e0a2df3
10 files changed
Lines changed: 705 additions & 46 deletions
File tree
- include
- API
- Support
- lib
- API
- DX
- MTL
- VK
- Support
- test/Feature/RT
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
86 | 102 | | |
87 | 103 | | |
88 | 104 | | |
| |||
215 | 231 | | |
216 | 232 | | |
217 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
218 | 242 | | |
219 | 243 | | |
220 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
595 | | - | |
| 595 | + | |
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
617 | | - | |
| 617 | + | |
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
828 | | - | |
829 | | - | |
| 828 | + | |
| 829 | + | |
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
733 | 739 | | |
734 | 740 | | |
735 | 741 | | |
| |||
1356 | 1362 | | |
1357 | 1363 | | |
1358 | 1364 | | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
1359 | 1379 | | |
1360 | 1380 | | |
1361 | 1381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
605 | 611 | | |
606 | 612 | | |
607 | 613 | | |
| |||
1662 | 1668 | | |
1663 | 1669 | | |
1664 | 1670 | | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1665 | 1685 | | |
1666 | 1686 | | |
1667 | 1687 | | |
| |||
0 commit comments