xbox_bvh_builder: implement RehydrateRaytracingAccelerationStructureBatched2X (RT-XDXR-BVH-REHYDRATE-BATCHED2X) #1759
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1759
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1759/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@abnalstlll-byte on GitHub · 2026-11-25 11:34 UTC · original
abnalstlll-byte:feat/rt-xdxr-bvh-rehydrate-batched2x→main· +421 −30 · 7 files · 5 commits · merged 2026-11-25 21:10 UTCClaimed in the coordination issue as: RT-XDXR-BVH-REHYDRATE-BATCHED2X (claim)
What and why
Addresses @timbot103's finding from interactive retail 1.0.2.1 boot past the story-load texture streaming phase (38,333 registered images):
Previously,
XboxBvhBuilder::RehydrateRaytracingAccelerationStructureBatched2X(runtime/shims/xbox_bvh_builder.cpp:231-236) was an unimplemented stub that unconditionally logged and returnedE_NOTIMPL. The title's interactive boot stopped immediately upon receivingE_NOTIMPL.This implements
builder_rehydrate_batched2x:S_OKimmediately ifcount == 0.E_INVALIDARGifdescsorlistis null.ID3D12GraphicsCommandList4*vialist4_of(list), logging and returningE_NOINTERFACEif unavailable.iin0..count-1:SourceAccelerationStructureDatafor fresh rebuilds (unlessPERFORM_UPDATEis set) so the layer does not attempt refits on dehydrated console streams (d3d12_vulkan_device.cpp:2639).NumDescs > 0), rebuilds the acceleration structure on the command list vialist4->BuildRaytracingAccelerationStructure(&build, 0, nullptr).ScratchAccelerationStructureData = 0, the shim allocates/reuses a dedicated scratch buffer viabuilder_ensure_scratchsized throughGetRaytracingAccelerationStructurePrebuildInfo, preventing command list poisoning/rejection.E_NOTIMPL(as offline dehydrated console streams cannot be directly read by PC GPUs without geometry reconstruction in the leaf framecompressionParamsgives;docs/bvh.md§4/§4a).NumDescs == 0without source) are logged once and skipped.docs/xdxr.mddocumenting the rehydration contract, notingsource_dataas a hypothesis for offline console stream buffers and retaining the leaf-frame geometry reconstruction note (compressionParams,docs/bvh.md§4a).runtime/test/xbox_bvh_builder_test.cppto verify:E_INVALIDARG, handlescount == 0withS_OK.E_NOTIMPL.NumDescs == 0) withS_OK.S_OKand valid non-zero total node count header.ScratchAccelerationStructureData == 0.tests/test_xbox_bvh_builder_rehydrate.pyverifying geometry rebuild, source-only refusal, and mangled export registration.Tested
python -I tests/test_xbox_bvh_builder_rehydrate.py: 3/3 tests pass (0.001s).python -I tests/test_docs_links.py: 16/16 pass.python -I tests/test_docs_design_rows.py: 5/5 pass.python -I tests/test_text_write_line_endings.py: 3/3 pass.python -I scripts/check_no_game_data.py: clean (0 violations, no game data).AI-assisted (Claude Code, Claude Opus 5.5).
@aslan2142 on GitHub · 2026-11-25 14:42 UTC · original
Thanks for picking this up, @abnalstlll-byte. It merges cleanly, and the call is a real gap (a retail run here reaches it), but two things need changing before it can go in:
docs/bvh.md§4/§4a measures the rehydrate source as a dehydrated console stream (element chunks, a level table, box overrides), not a D3D12 serialized blob. On the XDXR path aDESERIALIZEcopy is replayed as a byte clone, so the destination would hold dehydrated bytes the traversal shaders can't read. Please rebuild from geometry (§4a), or log and refuse.const UINT64*argument means isn't indocs/. Please quote the file and offset it comes from, or mark it as a hypothesis indocs/xdxr.md.Smaller points:
elsesilently builds an empty structure; please log it or return an error.AI-assisted (Claude Code, Claude Opus 5.5).
@Tyrannys on GitHub · 2026-11-25 15:25 UTC · original
Independent verification of head
5acf9b9f50f282bd564c9bd30e477bd4b61092af, merged onto currentmain(71a769d7d) without conflicts.Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.
xbox_bvh_builder,xbox_bvh_builder_console,xbox_bvh_builder_check, plus neighboursd3d12_indirect_rt,d3d12_indirect_rt_upload_sysmem: 5/5 pass (bvh_builderskips here as onmain). All 5 new rehydrate checks print PASS (null list, null descs, count 0, rebuild returns S_OK, non-zero node-count header).python -I tests/test_xbox_bvh_builder_rehydrate.py: 3/3 OK.Notes from the diff (not blockers for the build, but worth a look):
BuildRaytracingAccelerationStructurebranch runs. TheDESERIALIZEbranch is untested, and a D3D12 deserialize only accepts a blob serialized by this driver (its driver-matching identifier header); offline console data insource_datawould not be one.source_data[i]is written intoSourceAccelerationStructureData, which D3D12 only reads withPERFORM_UPDATEset; thecompressionParamsleaf frame thatdocs/xdxr.mdplanned for is not used.xbox_bvh_builderalready checks at run time.No game files used. AI-assisted (Claude Code).
@abnalstlll-byte on GitHub · 2026-11-25 16:17 UTC · original
Updated in commit
25b7fa4c9:builder_rehydrate_batched2xnow rebuilds structures exclusively from geometry (docs/bvh.md§4a).docs/bvh.md§4/§4a, offline dehydrated console streams cannot be deserialized directly as a D3D12 BLAS on PC. Whensource_datais supplied without geometry descriptions, the shim logs once and refuses withE_NOTIMPL.docs/xdxr.mdthat the 4th parameter (const UINT64* source_data, mangledPEB_K) is a hypothesis denoting the source buffer addresses of offline dehydrated console streams (e.g. forSourceAccelerationStructureDataor rehydration inputs).NumDescs == 0without source data are now logged once (s_empty_logged) and skipped rather than invoking an empty build.runtime/test/xbox_bvh_builder_test.cppnow tests the source-only path expectingE_NOTIMPLand the empty structure path expectingS_OK.tests/test_xbox_bvh_builder_rehydrate.pyupdated to verify both the geometry rebuild path and the source-only refusal.AI-assisted (Claude Code, Claude Opus 5.5).
@aslan2142 on GitHub · 2026-11-25 16:28 UTC · original
Thanks, @abnalstlll-byte: the deserialize branch is gone and the 4th parameter is marked as a hypothesis. Re-checked at
25b7fa4c9. Still needed:log_oncetakes(flag, text), so the call atxbox_bvh_builder.cpp:268that passes%uandifails with MSVC and clang-cl.source_data[i]intoSourceAccelerationStructureData. The layer reads that address for an update (d3d12_vulkan_device.cpp:2639), so withPERFORM_UPDATEset it would refit from a dehydrated stream.compressionParams,docs/bvh.md§4a) was dropped. Please keep it, or say why it doesn't apply.AI-assisted (Claude Code, Claude Opus 5.5).
@BubsMcgee on GitHub · 2026-11-25 16:40 UTC · original
Measured against the retail executable and the shipped DLL (file-only; no game data), for this path:
RehydrateRaytracingAccelerationStructureBatched2Xin batches of up to 16, with a non-null source array (the same translated pointers as the descs'SourceAccelerationStructureData). Each desc hasDest,Inputscopied from the source record, andSourceset — andScratchAccelerationStructureData = 0.ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure, soruntime/shims/d3d12_com.cpptakes the!cmd.scratch_vabranch: the layer rejects the call, and the list'sClosethen returnsE_INVALIDARGandExecuteCommandListsrefuses it. Saw exactly one such rejection per boot in three runs of this branch (state-rel4, fspx-1862, rehydrate-1759) and none on main.ScratchAccelerationStructureData, so it does not exercise the title's shape; ascratch = 0case would.source[i]when it is non-null, not only when the desc'sSourceis 0), and it returnsE_INVALIDARGunlesssourceis non-null,Destis non-null, and(*(u32*)source & 0x01000000) != 0. A desc with no geometry also fails the console validation, which compares a hash ofInputswith*(u32*)(source + 8).Suggested: give the rebuild its own scratch (size from
GetRaytracingAccelerationStructurePrebuildInfoon the desc'sInputs) and add thescratch = 0case, or keepE_NOTIMPLuntil #626's deserialize path lands — either way, avoid the list-poisoning rejection. The measured contract is in #1954 (and will be indocs/xdxr.md§6/§7).@abnalstlll-byte on GitHub · 2026-11-25 16:48 UTC · original
Updated in commit \5208120e9:
Build fix:
Source Acceleration Structure Data:
Scratch buffer allocation (\ScratchAccelerationStructureData == 0):
untime/test/xbox_bvh_builder_test.cpp\ to exercise the 0-scratch path.
Leaf-frame documentation:
untime/shims/xbox_bvh_builder.cpp\ and \docs/xdxr.md.
Stale text & tests:
ebuilds or deserializes\ comments in
untime/test/xbox_bvh_builder_test.cpp.
AI-assisted (Claude Code, Claude Opus 5.5).
@aslan2142 on GitHub · 2026-11-25 21:10 UTC · original
Merged, thanks! Before merging I pushed one maintainer commit on top of your head (
ef205eec9, a fast-forward):Reset. Before, all elements and lists shared one builder-wide buffer with no barrier, and growing it freed a buffer that recorded builds could still use.PERFORM_UPDATEis cleared together withSourceAccelerationStructureData, so the layer never refits from the dehydrated stream's bytes.compressionParamsis described as not applied yet, which matches the code.ScratchAccelerationStructureData = 0), the shape the title uses.Tested:
maine18b59a5b: no test went from pass to fail.mainadded only #1922 in the runtime (title HUD), which doesn't touch the BVH builder.main72006d61d+ef205eec9: it merges cleanly; the semantic suite passes (491 files, 6,312 tests, 0 files failed); the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 7 changed files.AI-assisted (Claude Code, Claude Opus 5.5).