upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/d3d12_com.cpp
diff options
context:
space:
mode:
authorromainveurrier <romain.veurrier@gmail.com>2026-11-22 14:04:34 +0100
committerromainveurrier <romain.veurrier@gmail.com>2026-11-22 14:04:34 +0100
commit1c58d6cfbc63ef3eb41d332c8aa443bb65ac4b4d (patch)
treead1aafa19ed74e0b550af8081fd7024b32596c83 /runtime/shims/d3d12_com.cpp
parent51a028115446da42565fa75d4657e82c214afc2d (diff)
D3D12: BuildRaytracingAccelerationStructure writes XDXR BVH4 records
The game's translated RT shaders read the console's XDXR records, which a VkAccelerationStructureKHR is not (docs/d3d12_vulkan.md 4.8). The standalone Vulkan device now builds them with src/xdxr_build.h, unless LEONIDA_RT_AS=khr keeps #743's KHR builds (the proposal in the maintainer decisions of #1548). - VulkanDeviceInfo::xdxr_acceleration_structures; the standalone device sets it with bufferDeviceAddress and then leaves the KHR extensions off, so acceleration-structure buffers keep their console VAs. - VulkanContext owns an XdxrBuilder; replay checks the inputs while the list is prepared (R32G32B32/R32G32 vertices, none/R16/R32 indices, addresses, counts) and records the build with heap_base added to every VA and as the bias for instance BLAS addresses. - GetRaytracingAccelerationStructurePrebuildInfo answers from XdxrLayout, exactly; an update rebuilds, so it needs the same scratch. - The geometry's vertex format is mapped per DXGI format (an unknown one is refused instead of read as R32G32B32), and its D3D12 flags reach the build. - test/d3d12_xdxr_rt_test.cpp: a two-geometry BLAS (a soup; an R16-indexed grid with stride 16 and a transform) and a TLAS of three instances through the D3D12 API; ctest d3d12_xdxr_rt + d3d12_xdxr_rt_check. - tools/xdxr_bvh.py: check-build compares TLAS hits by (geometry, primitive), and skips (77) when the build step wrote no cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
-rw-r--r--runtime/shims/d3d12_com.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp
index 44740dd98..418053333 100644
--- a/runtime/shims/d3d12_com.cpp
+++ b/runtime/shims/d3d12_com.cpp
@@ -603,9 +603,17 @@ public:
603 t.vertex_va = gd->Triangles.VertexBuffer.StartAddress; 603 t.vertex_va = gd->Triangles.VertexBuffer.StartAddress;
604 t.vertex_count = gd->Triangles.VertexCount; 604 t.vertex_count = gd->Triangles.VertexCount;
605 t.vertex_stride = static_cast<std::uint32_t>(gd->Triangles.VertexBuffer.StrideInBytes); 605 t.vertex_stride = static_cast<std::uint32_t>(gd->Triangles.VertexBuffer.StrideInBytes);
606 t.vertex_format = (gd->Triangles.VertexFormat == DXGI_FORMAT_R32G32_FLOAT) 606 // The vertex formats D3D12 allows for BLAS builds; any other stays VK_FORMAT_UNDEFINED and the
607 ? VK_FORMAT_R32G32_SFLOAT 607 // build is refused at replay instead of reading the wrong layout.
608 : VK_FORMAT_R32G32B32_SFLOAT; 608 switch (gd->Triangles.VertexFormat) {
609 case DXGI_FORMAT_R32G32B32_FLOAT: t.vertex_format = VK_FORMAT_R32G32B32_SFLOAT; break;
610 case DXGI_FORMAT_R32G32_FLOAT: t.vertex_format = VK_FORMAT_R32G32_SFLOAT; break;
611 case DXGI_FORMAT_R16G16B16A16_FLOAT: t.vertex_format = VK_FORMAT_R16G16B16A16_SFLOAT; break;
612 case DXGI_FORMAT_R16G16_FLOAT: t.vertex_format = VK_FORMAT_R16G16_SFLOAT; break;
613 case DXGI_FORMAT_R16G16B16A16_SNORM: t.vertex_format = VK_FORMAT_R16G16B16A16_SNORM; break;
614 case DXGI_FORMAT_R16G16_SNORM: t.vertex_format = VK_FORMAT_R16G16_SNORM; break;
615 default: t.vertex_format = VK_FORMAT_UNDEFINED; break;
616 }
609 t.index_va = gd->Triangles.IndexBuffer; 617 t.index_va = gd->Triangles.IndexBuffer;
610 t.index_count = gd->Triangles.IndexCount; 618 t.index_count = gd->Triangles.IndexCount;
611 if (gd->Triangles.IndexFormat == DXGI_FORMAT_R16_UINT) 619 if (gd->Triangles.IndexFormat == DXGI_FORMAT_R16_UINT)
@@ -614,6 +622,7 @@ public:
614 t.index_type = 2; 622 t.index_type = 2;
615 t.transform_va = gd->Triangles.Transform3x4; 623 t.transform_va = gd->Triangles.Transform3x4;
616 t.opaque = (gd->Flags & D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE) != 0; 624 t.opaque = (gd->Flags & D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE) != 0;
625 t.flags = static_cast<std::uint32_t>(gd->Flags);
617 cmd.triangles.push_back(t); 626 cmd.triangles.push_back(t);
618 } 627 }
619 } 628 }