[PR #1759] [MERGED] xbox_bvh_builder: implement RehydrateRaytracingAccelerationStructureBatched2X (RT-XDXR-BVH-REHYDRATE-BATCHED2X) #1772

Closed
opened 2026-11-26 21:18:54 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1759
Author: @abnalstlll-byte
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: feat/rt-xdxr-bvh-rehydrate-batched2x


📝 Commits (5)

  • 07e89b1 xbox_bvh_builder: implement RehydrateRaytracingAccelerationStructureBatched2X (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
  • cb1cb86 xbox_bvh_builder: rebuild from geometry and refuse source-only rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
  • b352aa9 xbox_bvh_builder: supply scratch buffer and address review feedback (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
  • 65235f3 test: update rehydration test comment to specify geometry rebuild (RT-XDXR-BVH-REHYDRATE-BATCHED2X)
  • ef205ee xbox_bvh_builder: review fixes for batched rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X)

📊 Changes

7 files changed (+421 additions, -30 deletions)

View changed files

📝 docs/xdxr.md (+18 -3)
📝 runtime/CMakeLists.txt (+2 -1)
📝 runtime/shims/d3d12_com.cpp (+13 -2)
📝 runtime/shims/d3d12_com.h (+8 -0)
📝 runtime/shims/xbox_bvh_builder.cpp (+177 -11)
📝 runtime/test/xbox_bvh_builder_test.cpp (+115 -13)
➕ tests/test_xbox_bvh_builder_rehydrate.py (+88 -0)

📄 Description

Claimed 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):

"late-run first calls reached list slot 61 (before 188.1 s), then device slot 71 (placed UAVs), ExecuteIndirect DISPATCH_MESH (not replayed yet), list slot 39/86/26/53, and RehydrateRaytracingAccelerationStructureBatched2X -> E_NOTIMPL (final stderr line); Windows Event 1000 recorded 0xc0000005 (faulting module unknown)"

Previously, XboxBvhBuilder::RehydrateRaytracingAccelerationStructureBatched2X (runtime/shims/xbox_bvh_builder.cpp:231-236) was an unimplemented stub that unconditionally logged and returned E_NOTIMPL. The title's interactive boot stopped immediately upon receiving E_NOTIMPL.

This implements builder_rehydrate_batched2x:

  1. Validates inputs:
    • Returns S_OK immediately if count == 0.
    • Returns E_INVALIDARG if descs or list is null.
    • Converts the command list to ID3D12GraphicsCommandList4* via list4_of(list), logging and returning E_NOINTERFACE if unavailable.
  2. For each element i in 0..count-1:
    • Clears SourceAccelerationStructureData for fresh rebuilds (unless PERFORM_UPDATE is set) so the layer does not attempt refits on dehydrated console streams (d3d12_vulkan_device.cpp:2639).
    • When geometry/instance descriptions are present (NumDescs > 0), rebuilds the acceleration structure on the command list via list4->BuildRaytracingAccelerationStructure(&build, 0, nullptr).
    • Addressing @BubsMcgee's retail boot measurement (#1954) where the title passes ScratchAccelerationStructureData = 0, the shim allocates/reuses a dedicated scratch buffer via builder_ensure_scratch sized through GetRaytracingAccelerationStructurePrebuildInfo, preventing command list poisoning/rejection.
    • When given a source-only dehydrated stream without geometry descriptions, logs once and refuses with E_NOTIMPL (as offline dehydrated console streams cannot be directly read by PC GPUs without geometry reconstruction in the leaf frame compressionParams gives; docs/bvh.md §4/§4a).
    • Empty structures (NumDescs == 0 without source) are logged once and skipped.
  3. Updates docs/xdxr.md documenting the rehydration contract, noting source_data as a hypothesis for offline console stream buffers and retaining the leaf-frame geometry reconstruction note (compressionParams, docs/bvh.md §4a).
  4. Updates runtime/test/xbox_bvh_builder_test.cpp to verify:
    • Input validation: rejects null inputs with E_INVALIDARG, handles count == 0 with S_OK.
    • Refusal of source-only streams with E_NOTIMPL.
    • Handling of empty structures (NumDescs == 0) with S_OK.
    • Rebuilding BLAS from geometry with S_OK and valid non-zero total node count header.
    • Supplying scratch when ScratchAccelerationStructureData == 0.
  5. Updates tests/test_xbox_bvh_builder_rehydrate.py verifying 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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1759 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `feat/rt-xdxr-bvh-rehydrate-batched2x` --- ### 📝 Commits (5) - [`07e89b1`](https://github.com/ubiquitarianism/leonida/commit/07e89b19358a9c79c1942e71fa4f37231621dabe) xbox_bvh_builder: implement RehydrateRaytracingAccelerationStructureBatched2X (RT-XDXR-BVH-REHYDRATE-BATCHED2X) - [`cb1cb86`](https://github.com/ubiquitarianism/leonida/commit/cb1cb86e9298de6f64f76fb5c627c96df9d3ffc9) xbox_bvh_builder: rebuild from geometry and refuse source-only rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X) - [`b352aa9`](https://github.com/ubiquitarianism/leonida/commit/b352aa9be9789d52a9f86246fb2241cdc08cd38c) xbox_bvh_builder: supply scratch buffer and address review feedback (RT-XDXR-BVH-REHYDRATE-BATCHED2X) - [`65235f3`](https://github.com/ubiquitarianism/leonida/commit/65235f36add54df162eef5cca1a30d24a21adc78) test: update rehydration test comment to specify geometry rebuild (RT-XDXR-BVH-REHYDRATE-BATCHED2X) - [`ef205ee`](https://github.com/ubiquitarianism/leonida/commit/ef205eec98801521ac19792432f4bc2d0ed26503) xbox_bvh_builder: review fixes for batched rehydration (RT-XDXR-BVH-REHYDRATE-BATCHED2X) ### 📊 Changes **7 files changed** (+421 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/xdxr.md` (+18 -3) 📝 `runtime/CMakeLists.txt` (+2 -1) 📝 `runtime/shims/d3d12_com.cpp` (+13 -2) 📝 `runtime/shims/d3d12_com.h` (+8 -0) 📝 `runtime/shims/xbox_bvh_builder.cpp` (+177 -11) 📝 `runtime/test/xbox_bvh_builder_test.cpp` (+115 -13) ➕ `tests/test_xbox_bvh_builder_rehydrate.py` (+88 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-XDXR-BVH-REHYDRATE-BATCHED2X ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161152265)) ### 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): > "late-run first calls reached list slot 61 (before 188.1 s), then device slot 71 (placed UAVs), ExecuteIndirect DISPATCH_MESH (not replayed yet), list slot 39/86/26/53, and RehydrateRaytracingAccelerationStructureBatched2X -> E_NOTIMPL (final stderr line); Windows Event 1000 recorded 0xc0000005 (faulting module unknown)" Previously, `XboxBvhBuilder::RehydrateRaytracingAccelerationStructureBatched2X` (`runtime/shims/xbox_bvh_builder.cpp:231-236`) was an unimplemented stub that unconditionally logged and returned `E_NOTIMPL`. The title's interactive boot stopped immediately upon receiving `E_NOTIMPL`. This implements `builder_rehydrate_batched2x`: 1. Validates inputs: - Returns `S_OK` immediately if `count == 0`. - Returns `E_INVALIDARG` if `descs` or `list` is null. - Converts the command list to `ID3D12GraphicsCommandList4*` via `list4_of(list)`, logging and returning `E_NOINTERFACE` if unavailable. 2. For each element `i` in `0..count-1`: - Clears `SourceAccelerationStructureData` for fresh rebuilds (unless `PERFORM_UPDATE` is set) so the layer does not attempt refits on dehydrated console streams (`d3d12_vulkan_device.cpp:2639`). - When geometry/instance descriptions are present (`NumDescs > 0`), rebuilds the acceleration structure on the command list via `list4->BuildRaytracingAccelerationStructure(&build, 0, nullptr)`. - Addressing @BubsMcgee's retail boot measurement (#1954) where the title passes `ScratchAccelerationStructureData = 0`, the shim allocates/reuses a dedicated scratch buffer via `builder_ensure_scratch` sized through `GetRaytracingAccelerationStructurePrebuildInfo`, preventing command list poisoning/rejection. - When given a source-only dehydrated stream without geometry descriptions, logs once and refuses with `E_NOTIMPL` (as offline dehydrated console streams cannot be directly read by PC GPUs without geometry reconstruction in the leaf frame `compressionParams` gives; `docs/bvh.md` §4/§4a). - Empty structures (`NumDescs == 0` without source) are logged once and skipped. 3. Updates `docs/xdxr.md` documenting the rehydration contract, noting `source_data` as a hypothesis for offline console stream buffers and retaining the leaf-frame geometry reconstruction note (`compressionParams`, `docs/bvh.md` §4a). 4. Updates `runtime/test/xbox_bvh_builder_test.cpp` to verify: - Input validation: rejects null inputs with `E_INVALIDARG`, handles `count == 0` with `S_OK`. - Refusal of source-only streams with `E_NOTIMPL`. - Handling of empty structures (`NumDescs == 0`) with `S_OK`. - Rebuilding BLAS from geometry with `S_OK` and valid non-zero total node count header. - Supplying scratch when `ScratchAccelerationStructureData == 0`. 5. Updates `tests/test_xbox_bvh_builder_rehydrate.py` verifying 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:18:54 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1772
No description provided.