Repository navigation
XDXR builds: PERFORM_UPDATE refits instead of rebuilding (D3D-178) - #1789
Merged
Merged
Conversation
…R one Two `const auto* build` in one else-if chain: the second hides the first and MSVC /W4 warns (C4456) in every file that includes the header (reported by @zneel on ItsNotRexed#1667). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The radix sort's fixed latency dominated small builds (2,000 triangles: 0.81 ms with the sort, 0.08 ms without, on an RTX 2050; the 10k regression @exhawk measured on ItsNotRexed#1572). Up to 1,024 keys are now sorted in one workgroup's shared memory (bitonic, ties by element index: the stable order; 8 KiB, within the 16 KiB minimum with the radix arrays), and the radix tiles are 256 elements (4 chunks instead of 32 per workgroup). RTX 2050: 1,000 triangles 0.24 ms, 2,000 0.28 ms (0.83), 10,000 0.38 ms (0.81), 100,000 2.3 ms (2.5); 1M 21.9 ms (20.3, the larger scan). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An update (same topology, new positions or instance transforms) now keeps the source's tree and recomputes its boxes: the source is copied to the destination unless it is the destination (MODE_COPY), the elements are rewritten at their slots, MODE_LEVEL with arg2 = 1 recomputes each node's boxes from the children it already points to, and the header gets the new bounds. No Morton pass, no sort, and the parent table is kept. RTX 2050: 1,000 triangles 0.07 ms (build 0.19), 100,000 1.02 ms (2.24), 1,000,000 9.8 ms (22.0); Iris Xe 13.1 ms for 1M (47.9). - XdxrBuilder::record_blas / record_tlas take `update_from`; the Vulkan backend passes the source (or the destination, for an in-place update) when the D3D12 build has PERFORM_UPDATE. - vk_xdxr_build_test: a 3,000-triangle BLAS refitted in place (radix-sort tree), an R32-indexed grid refitted into another buffer (its untouched source is checked too), and the TLAS refitted after its instances move; the timing mode also times refits. - d3d12_xdxr_rt_test: the BLAS is built with ALLOW_UPDATE, its soup moves, and a PERFORM_UPDATE in place is checked as d3d12_blas_update. - tools/xdxr_bvh.py check-build: the case being checked answers reads at its address first (an in-place update leaves two dumps at one address). A sabotaged refit (no box pass) fails every update case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 22, 2026
Contributor
|
Tested
No game files. AI-assisted (Claude Code). |
wildheathen
added a commit
to wildheathen/Leonida
that referenced
this pull request
Nov 22, 2026
…or do now Three corrections from @romainveurrier's review (the D3D-178 owner): - the translator reads all four triangle node types, TRI0-TRI3, with the barycentric remap byte (ItsNotRexed#1525), while the GPU builder writes TRI0 leaves; the row said "TRI0/TRI1 leaves" for both; - the XDXR-vs-KHR default is decided: the layer builds XDXR records by default and `LEONIDA_RT_AS=khr` keeps ItsNotRexed#743's path (ItsNotRexed#1667), so only the rehydrate-or-rebuild question is still open; - the row now says that `PERFORM_UPDATE` refits instead of rebuilding (ItsNotRexed#1789), and that clone, compaction and the compacted/current postbuild sizes work (ItsNotRexed#1844), checked against the CPU reference on synthetic scenes. The measured parts of the row (the recovered build descriptions, the packs, the 8 of 10 sampled BLAS) are unchanged. Docs only: the documentation suites pass, with the same three duplicated-row failures the parent commit has.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item: D3D-178 (#313), a follow-up to the merged #1572/#1667.
Depends on: #1743. This branch contains #1743's two commits; this PR's own change is the last commit, f6d6121.
What
BuildRaytracingAccelerationStructurewithPERFORM_UPDATEused to rebuild the structure from scratch. D3D12 promises the same topology for an update (new positions, or new instance transforms), so the XDXR builder now refits:MODE_COPYcopies the source to the destination unless they're the same buffer. It is also a building block forCopyRaytracingAccelerationStructurelater.MODE_TRIANGLES/MODE_INSTANCESrewrite the elements at their slots, as a build does.MODE_LEVELwitharg2 = 1recomputes each node's boxes, level by level, from the children it already points to. An instance'sParentNodeis restored the same way.MODE_HEADERwrites the new bounds.The tree's grouping and the parent table are kept, so there is no Morton pass and no sort. A refit is valid for any motion. It only traverses more slowly as geometry moves away from where it was built, which is the usual refit trade-off, and the application chooses it by asking for an update.
(best of 3 single submissions, device-local memory;
vk_xdxr_build_test <dir> <n>now times both)XdxrBuilder::record_blas/record_tlastakeupdate_from. The Vulkan backend passesSourceAccelerationStructureData, or the destination when no source is given, if the D3D12 build hasPERFORM_UPDATE.UpdateScratchDataSizeInBytesstays the build's scratch size, which covers a refit.Tests
vk_xdxr_build_test, three new cases:_source;d3d12_xdxr_rt_testthrough the D3D12 API: the BLAS is built withALLOW_UPDATE, its soup moves in the upload buffer, and aPERFORM_UPDATEin place is checked asd3d12_blas_update.tools/xdxr_bvh.py check-build: the case being checked now answers reads at its own address first. An in-place update leaves two dumps at one address, before and after.Tested (Fedora 44)
xdxr_build,d3d12_xdxr_rt(with their checks) andd3d12_indirect_rtpass on both GPUs;LEONIDA_RT_AS=khr, the XDXR tests skip andd3d12_indirect_rtpasses;mainunder Wine (the clang 22.1.8 crash infsr_dispatch/bvh_builder;device_proxy,d3d12_present,d3d12_indirect_zero).python -I tests/test_xdxr_bvh.pyOK;xdxr_build.incmatchesglslc --target-env=vulkan1.2 -O -mfmt=c.No game files. AI-assisted (Claude Code).
🤖 Generated with Claude Code