upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_backend.h
diff options
context:
space:
mode:
authorzneel <14263028+zneel@users.noreply.github.com>2026-11-22 20:16:04 +0100
committerzneel <14263028+zneel@users.noreply.github.com>2026-11-22 23:30:06 +0100
commitb8c07f8ccfe866987a54ff52e0e0e9a050d2ac8a (patch)
treee36521241de0927aca478a3acd1173ca010ea744 /runtime/src/vulkan_backend.h
parenta3d682840fb2e2332b1f5ea40915d9a5fc25eac1 (diff)
XDXR builder: pair sibling triangles into TRI0/TRI1 leaves
A bottom-level build without ALLOW_UPDATE now pairs triangles, as the console builder does in its offline BLASes. The pass that writes the nodes above the leaves pairs a triangle with a later sibling (among that node's at most four children) that shares an edge in the opposite direction (the same vertex bits), from the same geometry, both active. The first triangle is rotated to put the shared edge in slots 1 -> 2, the sibling's third vertex goes in slot 3, its primitive in PrimitiveIndex2, and each node type's remap byte returns D3D12's barycentrics for its own vertex order. The node keeps one child per triangle with its own box, so the tree, the layout and the sizes do not change; the TRI1 child points at the first leaf and the sibling's leaf is left unused. Pairs never cross nodes: one thread owns each rewritten leaf and each parent-table entry. A refit rewrites the leaves one triangle each, so the layer does not pair builds with ALLOW_UPDATE (xdxr_pair), and record_blas ignores `pair` for updates. check-build now compares barycentrics as well as hits, and checks a case's "pairs" field: at least one TRI1 node, or none. New cases: paired grids (BOX32 and BOX16), a transform, a mixed scene, the radix path, and two that must not pair (pairs split across geometries, edges shared in the same direction), plus a D3D12 BLAS without ALLOW_UPDATE. Mutating the geometry or the direction rule, or the remap byte, fails check-build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/vulkan_backend.h')
-rw-r--r--runtime/src/vulkan_backend.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h
index f47abccb3..8c8a19d2f 100644
--- a/runtime/src/vulkan_backend.h
+++ b/runtime/src/vulkan_backend.h
@@ -897,7 +897,8 @@ public:
897 } else { 897 } else {
898 std::vector<XdxrTriangles> geometries; 898 std::vector<XdxrTriangles> geometries;
899 xdxr_inputs(b, &geometries, base); 899 xdxr_inputs(b, &geometries, base);
900 xdxr_->record_blas(cb, layout, geometries, base + b.dst_va, base + b.scratch_va, from); 900 xdxr_->record_blas(cb, layout, geometries, base + b.dst_va, base + b.scratch_va, from,
901 xdxr_pair(b));
901 } 902 }
902 }; 903 };
903 replay_.xdxr_copy = [this](VkCommandBuffer cb, std::uint64_t src, std::uint64_t dst, std::uint64_t bytes) { 904 replay_.xdxr_copy = [this](VkCommandBuffer cb, std::uint64_t src, std::uint64_t dst, std::uint64_t bytes) {
@@ -1116,6 +1117,12 @@ public:
1116 static bool xdxr_box16(const BuildAccelerationStructure& b) { 1117 static bool xdxr_box16(const BuildAccelerationStructure& b) {
1117 return !b.is_tlas && (b.build_flags & VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR) != 0; 1118 return !b.is_tlas && (b.build_flags & VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR) != 0;
1118 } 1119 }
1120 // Whether a bottom-level build pairs sibling triangles into TRI0/TRI1 leaves: not when the structure may be
1121 // updated (ALLOW_UPDATE), since a refit rewrites the leaves one triangle each. Pairing changes neither the layout
1122 // nor the tree, so prebuild info does not depend on it.
1123 static bool xdxr_pair(const BuildAccelerationStructure& b) {
1124 return !b.is_tlas && !b.update && (b.build_flags & VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR) == 0;
1125 }
1119 // Triangles (BLAS) or instances (TLAS) a build has: what XdxrLayout is computed from, for the build and for 1126 // Triangles (BLAS) or instances (TLAS) a build has: what XdxrLayout is computed from, for the build and for
1120 // GetRaytracingAccelerationStructurePrebuildInfo. 1127 // GetRaytracingAccelerationStructurePrebuildInfo.
1121 static std::uint32_t xdxr_elements(const BuildAccelerationStructure& b) { 1128 static std::uint32_t xdxr_elements(const BuildAccelerationStructure& b) {