RT-BVH-BUILDER: serve XboxBvhBuilder.dll with the layer's XDXR builder #549

Closed
bobcatchris wants to merge 1 commit from upstream-pr/549 into main
bobcatchris commented 2026-11-24 07:30:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T07:30:26Z.


Claimed in the coordination issue as: RT-BVH-BUILDER-THROW

Depends on: none

What and why

After the slot-73 IID and XMem lease fixes, the title reaches XboxBvhBuilder.dll and ends in a C++ throw while the bundled DLL creates 52 console compute pipelines. Their translated compile time runs past the title's startup watchdog on a cold driver cache.

This restores the final state of three preserved commits whose content was dropped from main by later mirror merges. A shim serves the seven XboxBvhBuilder.dll imports the executable binds, so the DLL is never loaded and no 52 console programs are created. It builds the layer's own XDXR BVH4 structures in the format the translated traversal shaders read, skips the offline-statistics postbuild type instead of throwing, unwraps console command-list proxies, and holds the device reference across prebuild calls. LEONIDA_BVH_BUILDER=console preserves the bundled DLL path.

Original work by romainveurrier, preserved in the local full history as 242a5dbf1, 98c065ca2 and 65a2da200.

Tested

  • Built xbox_bvh_builder_test against current main with MSVC in a local out-of-tree build.
  • xbox_bvh_builder_test <out> — 13/13 checks pass, including proxy device handling, offline-statistics skip, E_NOTIMPL rehydration, destructor cleanup, and BLAS/TLAS/compacted-BLAS fixture output.
  • xbox_bvh_builder_test --console with LEONIDA_BVH_BUILDER=console — 1/1 check passes.
  • python -I tools/xdxr_bvh.py check-build <out> --rays 1000 — all cases match; 0 validation errors and 0/1000 ray differences for BLAS, compacted BLAS and TLAS.
  • python -I scripts/check_no_game_data.py on every changed file — clean.
  • git diff --check clean.
  • Patch, diff and direct-file security sweeps: 0 hits.
  • No game executable was run. No game files, keys or decryption are included.

A local MSVC 14.39 incompatibility in the unrelated src/crt_timed_wait.cpp was worked around only in the throwaway build directory; no repository source was changed for it.

GPUs tested: AMD Radeon RX 7900 XTX, driver 32.0.32029.2010, Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic: restore the XboxBvhBuilder shim and its tests.
  • No game data, keys or decryption.
  • Synthetic GPU/BVH fixtures and console-mode regression included.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5467986652 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/549). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T07:30:26Z. --- Claimed in the coordination issue as: RT-BVH-BUILDER-THROW Depends on: none ### What and why After the slot-73 IID and XMem lease fixes, the title reaches `XboxBvhBuilder.dll` and ends in a C++ throw while the bundled DLL creates 52 console compute pipelines. Their translated compile time runs past the title's startup watchdog on a cold driver cache. This restores the final state of three preserved commits whose content was dropped from `main` by later mirror merges. A shim serves the seven `XboxBvhBuilder.dll` imports the executable binds, so the DLL is never loaded and no 52 console programs are created. It builds the layer's own XDXR BVH4 structures in the format the translated traversal shaders read, skips the offline-statistics postbuild type instead of throwing, unwraps console command-list proxies, and holds the device reference across prebuild calls. `LEONIDA_BVH_BUILDER=console` preserves the bundled DLL path. Original work by romainveurrier, preserved in the local full history as `242a5dbf1`, `98c065ca2` and `65a2da200`. ### Tested - Built `xbox_bvh_builder_test` against current `main` with MSVC in a local out-of-tree build. - `xbox_bvh_builder_test <out>` — 13/13 checks pass, including proxy device handling, offline-statistics skip, E_NOTIMPL rehydration, destructor cleanup, and BLAS/TLAS/compacted-BLAS fixture output. - `xbox_bvh_builder_test --console` with `LEONIDA_BVH_BUILDER=console` — 1/1 check passes. - `python -I tools/xdxr_bvh.py check-build <out> --rays 1000` — all cases match; 0 validation errors and 0/1000 ray differences for BLAS, compacted BLAS and TLAS. - `python -I scripts/check_no_game_data.py` on every changed file — clean. - `git diff --check` clean. - Patch, diff and direct-file security sweeps: 0 hits. - No game executable was run. No game files, keys or decryption are included. A local MSVC 14.39 incompatibility in the unrelated `src/crt_timed_wait.cpp` was worked around only in the throwaway build directory; no repository source was changed for it. GPUs tested: AMD Radeon RX 7900 XTX, driver 32.0.32029.2010, Windows 11 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic: restore the XboxBvhBuilder shim and its tests. - [x] No game data, keys or decryption. - [x] Synthetic GPU/BVH fixtures and console-mode regression included.
bobcatchris commented 2026-11-24 07:40:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T07:40:39Z.


Runtime verification (not a clean pass yet): I built this PR on current upstream main, locally stacked the already-open prerequisites #445 and #375, and ran against the 1.0.2.1 package with LEONIDA_D3D12=vulkan and a 26,503-entry translated corpus. All seven XboxBvhBuilder.dll imports bind to the shim. The run advanced to 1,655 D3D12 calls (the old report stopped around 1,619 with a C++ throw from the bundled DLL), and the old XboxBvhBuilder.dll throw is gone. It now asserts at game_scarlett_master.exe+0x19f4f58 after the call site at +0x19f4f4f returns false. No shim runtime log appeared before that assert, so I am not claiming the boot is fixed; the next step is to check whether the title reads state from the builder object that the shim intentionally does not write. No game data was committed.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125249598 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/549#issuecomment-7125249598). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T07:40:39Z. --- Runtime verification (not a clean pass yet): I built this PR on current upstream main, locally stacked the already-open prerequisites #445 and #375, and ran against the 1.0.2.1 package with LEONIDA_D3D12=vulkan and a 26,503-entry translated corpus. All seven XboxBvhBuilder.dll imports bind to the shim. The run advanced to 1,655 D3D12 calls (the old report stopped around 1,619 with a C++ throw from the bundled DLL), and the old XboxBvhBuilder.dll throw is gone. It now asserts at game_scarlett_master.exe+0x19f4f58 after the call site at +0x19f4f4f returns false. No shim runtime log appeared before that assert, so I am not claiming the boot is fixed; the next step is to check whether the title reads state from the builder object that the shim intentionally does not write. No game data was committed.
kawaii-shakal commented 2026-11-24 11:39:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T11:39:14Z.


Independent run on Windows: passes, with and without validation.

Head 2e17d7208 built as it is (RelWithDebInfo, MSVC 19.50.35721.0), ctest -R "bvh_builder|xbox_bvh", both with LEONIDA_VK_VALIDATION unset and =1 (Vulkan SDK 1.4.363.0):

  • xbox_bvh_builder 13/13 checks, xbox_bvh_builder_console 1/1;
  • xbox_bvh_builder_check: shim_blas, shim_blas_compacted, shim_tlas each 0 validation errors, 0/1000 rays differing;
  • bvh_builder skips (no package), as expected.

Two notes from reading xbox_bvh_builder.cpp, neither blocking:

  1. RehydrateRaytracingAccelerationStructure*X answer E_NOTIMPL. docs/bvh.md §4/§4a (lines 454-457) records that the *_bvh4.rpf contents are dehydrated inputs for exactly that path and leaves open whether the runtime calls it. If it does, those BLAS stay empty under this shim, so it may be worth a log line that names the call (or a finding: for the follow-up) so a boot log shows it.
  2. Copy modes are passed through to the layer unchanged, so the XDXR SERIALIZE/DESERIALIZE modes in #626 would work through this shim with no change here.

GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7130374373 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/549#issuecomment-7130374373). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-24T11:39:14Z. --- Independent run on Windows: passes, with and without validation. Head 2e17d7208 built as it is (RelWithDebInfo, MSVC 19.50.35721.0), `ctest -R "bvh_builder|xbox_bvh"`, both with `LEONIDA_VK_VALIDATION` unset and `=1` (Vulkan SDK 1.4.363.0): - `xbox_bvh_builder` 13/13 checks, `xbox_bvh_builder_console` 1/1; - `xbox_bvh_builder_check`: `shim_blas`, `shim_blas_compacted`, `shim_tlas` each 0 validation errors, 0/1000 rays differing; - `bvh_builder` skips (no package), as expected. Two notes from reading `xbox_bvh_builder.cpp`, neither blocking: 1. `RehydrateRaytracingAccelerationStructure*X` answer `E_NOTIMPL`. `docs/bvh.md` §4/§4a (lines 454-457) records that the `*_bvh4.rpf` contents are dehydrated inputs for exactly that path and leaves open whether the runtime calls it. If it does, those BLAS stay empty under this shim, so it may be worth a log line that names the call (or a `finding:` for the follow-up) so a boot log shows it. 2. Copy modes are passed through to the layer unchanged, so the XDXR `SERIALIZE`/`DESERIALIZE` modes in #626 would work through this shim with no change here. GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300. AI-assisted.
bobcatchris commented 2026-11-24 23:42:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-24T23:42:50Z.


Rebased on current main; resolved the fallback-build script conflict while retaining ws2_offline. Verified: xs_proxy_mock and xbox_bvh_builder pass; package-gated BVH shim 13/13 checks; BLAS/compacted BLAS/TLAS 0 validation errors and 0/3000 ray differences; no-game-data and security checks clean.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7147711560 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/549#issuecomment-7147711560). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-24T23:42:50Z. --- Rebased on current main; resolved the fallback-build script conflict while retaining ws2_offline. Verified: xs_proxy_mock and xbox_bvh_builder pass; package-gated BVH shim 13/13 checks; BLAS/compacted BLAS/TLAS 0 validation errors and 0/3000 ray differences; no-game-data and security checks clean.
MoonEyes commented 2026-11-28 02:49:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:49:16Z.


Hi @bobcatchris, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/xdxr.md, runtime/CMakeLists.txt, runtime/shims/d3d12_xs_device.cpp, runtime/shims/d3d12_xs_device.h, runtime/shims/xbox_bvh_builder.cpp, runtime/test/xbox_bvh_builder_test.cpp, scripts/build_runtime.ps1), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232614988 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/549#issuecomment-7232614988). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:49:16Z. --- Hi @bobcatchris, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `docs/xdxr.md`, `runtime/CMakeLists.txt`, `runtime/shims/d3d12_xs_device.cpp`, `runtime/shims/d3d12_xs_device.h`, `runtime/shims/xbox_bvh_builder.cpp`, `runtime/test/xbox_bvh_builder_test.cpp`, `scripts/build_runtime.ps1`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
bobcatchris commented 2026-11-29 13:07:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T13:07:53Z.


Closing as superseded:
untime/shims/xbox_bvh_builder.cpp, xbox_bvh_builder_test.cpp, and the XboxBvhBuilder.dll shim are already present and further developed on main (e.g.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256311313 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/549#issuecomment-7256311313). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-29T13:07:53Z. --- Closing as superseded: untime/shims/xbox_bvh_builder.cpp, xbox_bvh_builder_test.cpp, and the XboxBvhBuilder.dll shim are already present and further developed on main (e.g.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!549
No description provided.