Skip to content

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

Open
bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:rt-bvh-builder-throw
Open

bobcatchris wants to merge 1 commit into
ProjectLeonida:mainfrom
bobcatchris:rt-bvh-builder-throw

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

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.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor

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

Head 2e17d72 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 d3d12: serialize and deserialize XDXR acceleration structures (RT-XDXR-SERIALIZE) #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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…ILDER: serve XboxBvhBuilder.dll with the layer's XDXR builder

# Conflicts:
#	runtime/shims/d3d12_xs_device.cpp
#	scripts/build_runtime.ps1
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
Brings 58 PRs integration did not have (among them ProjectLeonida#359 ProjectLeonida#360 ProjectLeonida#402 ProjectLeonida#497 ProjectLeonida#557 ProjectLeonida#558
ProjectLeonida#560 ProjectLeonida#561 ProjectLeonida#572 ProjectLeonida#573 ProjectLeonida#574 ProjectLeonida#577) and the newer heads of ProjectLeonida#401 and ProjectLeonida#404. 15 files
conflicted; resolved by hand:

- frame_pacer.h, d3d12_xs_device.h/.cpp: ProjectLeonida#402's pacer (per-event ticks,
  issue_token_locked) now issues from ProjectLeonida#414's shared FrameTokenSource, so a token
  from the device-side WaitFrameEventX is one the pacer accepts (towade's ProjectLeonida#14
  finding: without it every PresentX is refused). The dead frame_next_token and
  issued_ counters are dropped. Queue slot 32 stays ProjectLeonida#414's PresentX; ProjectLeonida#402's
  presentation-handler routes serve slot 30 or LEONIDA_XS_PRESENT_X_SLOT.
  ProjectLeonida#402's GetFrameStatisticsX route moves into ProjectLeonida#385's route_xbox_device_slot.
- acphal.cpp/acphal_test.cpp: upstream's reworked SHAPE allocation and release;
  the release writes nothing through its first argument, as ProjectLeonida#405 requires; both
  sides' tests kept. Upstream's ProjectLeonida#401/ProjectLeonida#404 heads remove lifecycle.cpp and the C++
  xma2_decoder.cpp (replaced by runtime/xma_decoder), so build_runtime.ps1's
  cl.exe list drops them and keeps ProjectLeonida#549's and ProjectLeonida#400's files.
- vulkan_backend.h, statistics_sum.comp, its SPIR-V header, d3d12_mesh_test,
  replay_query_edges_test, d3d12_vulkan_device.cpp, docs: ProjectLeonida#577's clipping
  counter on top of ProjectLeonida#540, which both sides carry; the Timestamps sentence keeps
  integration's corrected wording (c33ce87).
- xs_proxy_mock_test.cpp: both sides' cases; pr_conflict_label.py keeps the
  guarded reconfigure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore the final content of the preserved 242a5db, 98c065c and 65a2da2 commits, whose files were dropped from main by later mirror merges. The shim serves the seven imports of XboxBvhBuilder.dll without loading the bundled DLL, avoiding its 52 console pipeline compiles and the cold-boot watchdog timeout. It builds layer BVHs, skips offline-statistics elements instead of throwing, unwraps console list proxies, and holds the device across prebuild calls. LEONIDA_BVH_BUILDER=console preserves the bundled DLL path.

Original work by romainveurrier, preserved in the local full history. AI-assisted.
@bobcatchris

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added needs rebase Conflicts with the base branch: rebase it on main and removed needs rebase Conflicts with the base branch: rebase it on main labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants