Skip to content

runtime: serve XboxBvhBuilder.dll with the layer's XDXR builder (RT-5, boot stop 18) - #7516

Closed
romainveurrier wants to merge 3 commits into
ProjectLeonida:mainfrom
romainveurrier:rt/xboxbvhbuilder-shim
Closed

romainveurrier wants to merge 3 commits into
ProjectLeonida:mainfrom
romainveurrier:rt/xboxbvhbuilder-shim

Conversation

@romainveurrier

Copy link
Copy Markdown
Contributor

Item: new RT-5 item, claimed in #7333 (claim). Stage 1 of 2; stage 2 is rehydration.

Why

XboxBvhBuilder.dll's constructor creates its 52 console compute programs as pipelines, on the title's thread. Translated, they take 25–60 s to compile on a cold driver cache: 31.2 s for one of them on an RTX 4080 (@kapitche), 59.5 s for all 52 on an RX 9070 XT (@sennecools). The title's startup watchdog fires at about 30 s, so a first boot ends at the builder (stop 18). @KkelebekK hit the same thing under Wine on an RTX 4070 Laptop.

The layer already builds XDXR BVH4 structures itself (D3D-178, runtime/src/xdxr_build.*), in the node format the game's translated traversal shaders read, and its pipeline compiles in well under a second. The loader binds an import to a shim before a bundled module (Loader::resolve). So this serves the DLL's exports with the layer's builder, and the DLL is never loaded. It's the same kind of substitution as DLSS behind the FFX upscaler shim.

What

runtime/shims/xbox_bvh_builder.cpp serves the seven exports the executable imports. Measured statically on my own 1.0.2.1 copy (game_scarlett_master.exe, SHA-256 e95020b2…a08993); nothing was run for this; export names and call counts only, all through the IAT:

Export Call sites The shim
constructor (ID3D12Device11*, bool) 1 keeps the device in a table keyed by this; nothing is written into the title's object, whose size isn't known; no programs
destructor 1 releases that entry
Set64BitMortonCodes(bool) 8 recorded; the layer's builder has no such option
GetRaytracingAccelerationStructurePrebuildInfo(INPUTS*, XDXR_STREAM_DESC*, PREBUILD_INFO*) 3 the layer's sizes
BuildRaytracingAccelerationStructureBatched2X(GCL6*, UINT, BATCHED_DESC2*) 6 one layer build per element (docs/xdxr.md §1, src/xdxr_descs.h), with its postbuild descriptions
CopyRaytracingAccelerationStructure(GCL4*, dest, source, mode) 2 the layer's copy
RehydrateRaytracingAccelerationStructureBatched2X(GCL8*, UINT, BUILD_DESC*, UINT64*) 4 E_NOTIMPL + a log line for now (stage 2)

Where it differs from the DLL, on purpose:

Stage 2: RehydrateRaytracingAccelerationStructureBatched2X, rebuilding each structure on the GPU from the source geometry its description carries (docs/bvh.md §4a), in the leaf frame compressionParams gives, so it agrees with #4011's TLAS folding.

Tests

xbox_bvh_builder_test (12 checks) calls every export through rt::shims::find("xboxbvhbuilder.dll", <mangled name>), the way the title's imports bind, with this first:

  • Builds: a BLAS (with a non-empty XDXR stream and a COMPACTED_SIZE postbuild) and a TLAS through the batched export; the BLAS compacted through the copy export into a buffer of exactly that size.
  • Prebuild sizes: the layer's own, with or without a stream.
  • The refused element: it's skipped, and its destination and postbuild slot are left untouched.
  • Rehydration: answers E_NOTIMPL.
  • The builder object: nothing is written into it, and the destructor releases its state, also when called twice.

xbox_bvh_builder_check runs tools/xdxr_bvh.py check-build on the three structures. xbox_bvh_builder_console checks that LEONIDA_BVH_BUILDER=console registers nothing.

Tested

Fedora 44, clang-cl with xwin (SDK 10.0.26100), Wine 11.21, NVIDIA GeForce RTX 2050:

  • xbox_bvh_builder: 12/12. xbox_bvh_builder_check: 0 validation errors and 0/1000 rays differing from brute force on the BLAS, the compacted BLAS and the TLAS. xbox_bvh_builder_console passes.
  • Retail executable, gta6rt --dry-run (my own copy; binding kinds and counts only): all 7 XboxBvhBuilder.dll imports bind to shim, and 4 modules are mapped instead of 5, so the bundled DLL isn't loaded.
  • Not yet run: a live boot to stop 18. On main alone the run stops well before it, since stops 1–17 are in open PRs. If you run the boot stack (@rafaelpssz, @KkelebekK, @Pipodi), a run with this on top would confirm the watchdog stop is gone. I'll do the same on an integration tree next.
  • tests/test_docs_links.py fails on main too (an anchor in docs/dev-tools.md); scripts/check_no_game_data.py passes on the new files.

No game files in the repository. AI-assisted (Claude Code).

🤖 Generated with Claude Code

…, boot stop 18)

The package's XboxBvhBuilder.dll creates 52 console compute programs as
pipelines in its constructor, on the title's thread. Translated, they take
25-60 s to compile on a cold driver cache (ItsNotRexed#7231/ItsNotRexed#7049: 31.2 s for one on
an RTX 4080, 59.5 s for all 52 on an RX 9070 XT), longer than the title's
~30 s startup watchdog, so a first boot ends at the builder.

runtime/shims/xbox_bvh_builder.cpp serves the seven exports the executable
imports (measured statically on 1.0.2.1: constructor 1 call site,
destructor 1, Set64BitMortonCodes 8, GetRaytracingAccelerationStructure-
PrebuildInfo 3, BuildRaytracingAccelerationStructureBatched2X 6,
CopyRaytracingAccelerationStructure 2, RehydrateRaytracingAcceleration-
StructureBatched2X 4) with the layer's own XDXR builder (D3D-178). The
loader binds imports to a shim before a bundled module, so the DLL is not
loaded and its programs are never created.

- each BATCHED_DESC2 element (docs/xdxr.md §1) is one layer build with its
  postbuild descriptions; the offline-statistics type (0x10), which the DLL
  refuses by throwing, skips the element instead (a shim must not throw);
- XDXR stream records and Set64BitMortonCodes tune the console builder's
  heuristics and are ignored (logged once);
- prebuild sizes and copies are the layer's;
- the builder's state is kept in a table keyed by `this`: nothing is
  written into the title's object, whose size isn't known;
- rehydration answers E_NOTIMPL for now (stage 2);
- LEONIDA_BVH_BUILDER=console keeps the bundled DLL.

xbox_bvh_builder_test (12 checks) calls the exports through the shim
registry as the title binds them; xdxr_bvh.py check-build validates the
BLAS, TLAS and compacted BLAS it builds (0/1000 rays differ on each).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KarolKurzyna

Copy link
Copy Markdown
Contributor

Independent native Windows 11 dual-GPU review of 242a5dbf14a1324d6605da8268769189d5e1892c (plus clean merge check onto origin/main 37398f9): PASS (with two non-blocking code-audit notes below).

Environment

  • OS / Toolchain: Windows 11 x64 (10.0.26300), MSVC 19.52.37029 (VS 2026), Windows SDK 10.0.26100.0, CMake + Ninja RelWithDebInfo, Khronos Validation Layer 1.4.363
  • GPUs: NVIDIA GeForce RTX 3070 Ti (driver 621.24, Vulkan 1.4.357) and Intel(R) UHD Graphics 770 (driver 101.6129, Vulkan 1.3.295)
  • Layers: VK_LOADER_LAYERS_DISABLE=~implicit~, DISABLE_VULKAN_OBS_CAPTURE=1, DISABLE_RTSS_LAYER=1

Results (242a5dbf14, 0 compiler warnings on xbox_bvh_builder.cpp, xbox_bvh_builder_test.cpp, and gta6rt.exe)

  • NVIDIA GeForce RTX 3070 Ti (LEONIDA_VK_VALIDATION off & on, 0 validation errors):
    • xbox_bvh_builder: PASS (0 of 12 checks failed)
    • xbox_bvh_builder_console (LEONIDA_BVH_BUILDER=console): PASS (0 of 1 checks failed)
    • xbox_bvh_builder_check (tools/xdxr_bvh.py check-build --rays 1000): PASS (shim_blas: 55424 bytes, 0/1000 rays differ; shim_blas_compacted: 55424 bytes, 0/1000 rays differ; shim_tlas: 512 bytes, 0/1000 rays differ)
  • Intel(R) UHD Graphics 770 (LEONIDA_VK_VALIDATION off & on, 0 validation errors):
    • xbox_bvh_builder: PASS (0 of 12 checks failed)
    • xbox_bvh_builder_console: PASS (0 of 1 checks failed)
    • xbox_bvh_builder_check: PASS (identical 55424 / 55424 / 512 byte outputs, 0/1000 rays differ across all three structures)
  • Clean merge onto origin/main (37398f9): merges cleanly; gta6rt.exe and xbox_bvh_builder_test.exe build cleanly and ctest -R "^xbox_bvh_builder" passes 3/3 on RTX 3070 Ti with LEONIDA_VK_VALIDATION=1.

Non-blocking code-audit notes

  1. Lifetime / thread-safety in builder_device() (runtime/shims/xbox_bvh_builder.cpp:209-237): builder_device(self) releases g_mutex and returns an un-AddRef'd ID3D12Device5*. If another thread destroys or reconstructs self while builder_prebuild_info is inside device->GetRaytracingAccelerationStructurePrebuildInfo(...), builder_destruct can Release() the last held reference mid-call. Calling AddRef() under g_mutex and Release() after the call (matching list4_of's owning-ref pattern) closes that race.
  2. Test coverage note: xbox_bvh_builder_test.cpp passes an unwrapped ID3D12Device5* from create_vulkan_device_standalone, so the rt::d3d12_xs::device_proxy_real_device(device) unwrap path in device5_of() is not yet exercised by the test.

Synthetic tests only, no game data. AI-assisted.

@MartinIndra02

Copy link
Copy Markdown
Contributor

Independent Windows + GPU test of 242a5dbf1: pass.

Setup: Windows 11 x64, MSVC 19.44.35220 (RelWithDebInfo, Windows SDK 10.0.26100.0), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24), Vulkan SDK 1.4.363.1, no game files.

  • ctest -R xbox_bvh_builder --output-on-failure: PASS (exit 0, both default and --console tests passed).

AI-assisted review/test.

@cdomergue

Copy link
Copy Markdown

Native Windows retail A/B at 242a5dbf1, Windows 11 x64, MSVC 19.44 Release, RTX 4070 SUPER (616.92). I used the same built loader and Xbox 1.0.2.1 package in both runs. The only changed setting was LEONIDA_BVH_BUILDER.

Retail dry-run Default console
Builder imports handled by Leonida 7 0
Modules mapped 4 5
Unimplemented imports 29 29

Both exited 0. The seven additional shim bindings correspond to seven fewer bindings to a packaged module. On the same machine all three builder CTests passed. The synthetic BLAS, compacted BLAS and TLAS each had zero structure-validation errors and 0/1,000 rays differing from brute force.

This checks module selection on Windows and geometry correctness on Ada. The retail runs stopped after mapping, so they do not measure initialization time or show whether the startup watchdog is cleared. AI-assisted verification.

@zohaiblazuli

Copy link
Copy Markdown

Tested 242a5dbf1 live on the retail executable, with the earlier stops cleared: pass, past stop 18.

Retail Xbox Series 1.0.2.1 package + executable (sizes match game/xbox-1.0.2.1.json), Windows 11 10.0.26300, MSVC 14.50, GeForce RTX 3060 (driver 32.0.16.1742). Vulkan backend (LEONIDA_D3D12=vulkan, Vulkan SDK 1.4.363), no translated shader library. gta6rt --run with --overlay to a scratch folder, outbound network blocked, LEONIDA_UNIMPLEMENTED=stop, no LEONIDA_SKIP_INT3, no LEONIDA_STUB_PIPELINES. Base: main 8575d36ed plus local console-queue-flag and struct-return (slots 25/26/43) changes, with #6953, #7187, #7076, #7075, #7021, #7066 and #7235 (with #7052) merged, then this PR.

Outcomes only; no game data.

@Marukooh

Copy link
Copy Markdown
Contributor

Live run on top of a boot stack (environment below), 242a5dbf1 merged cleanly except scripts/build_runtime.ps1 (not used by this Linux cross build, kept from main).

Environment: CachyOS, Wine 11.22, RTX 5070 Ti / NVIDIA 620.73.04, Vulkan 1.4.357, clang-cl 23.1.5 + xwin SDK 10.0.26100, Release, LEONIDA_D3D12=vulkan, network blocked, own 1.0.2.1 copy. Boot stack: main 86a7807 + #7411, #7110, #7076, #7066, #6954, #6582, #4348, #7216, #4313, #7499, #7516 (PR heads merged, conflicts resolved locally). AI-assisted (Claude Code).

@ciagnij

ciagnij commented Nov 23, 2026

Copy link
Copy Markdown

Native Windows check of 242a5dbf14a1324d6605da8268769189d5e1892c merged cleanly into 976b3ec91c086b6637d38ec2f88571652c48c6d1. Windows 11 build 26300, MSVC 19.44 / Windows SDK 10.0.26100, Vulkan Headers 1.4.363.

  • AMD Radeon 1002:13c0 (26.1.1) and RTX 5070 Ti (621.14): xbox_bvh_builder was 12/12 on each. The console override check also passed. The three synthetic structures (BLAS, compacted BLAS, TLAS) had zero validation errors and zero discrepancies in 1,000 rays each against the CPU reference on both GPUs.
  • With the same loader executable and matching package layout, local --dry-run exited 0 in both modes. The default routed seven builder imports to the shim and mapped four modules. LEONIDA_BVH_BUILDER=console routed zero to the shim and mapped five modules. Both had 22 unresolved imports overall at this main revision.

The local package check only exercised mapping and import routing. These measurements don't cover live startup or the rehydration implementation.

@sambagarandawertanda

Copy link
Copy Markdown

Additional stop-18 data point for the console BVH path on an RTX 3080.

Windows build 26300, NVIDIA 621.14, MSVC 19.44 RelWithDebInfo. I used the public RT-5 integration at c6f58906d, with LLVM 23.1.5, SPIRV-Tools v2026.4 and wave64 emulation. All 52 compute modules passed validation and all 52 pipelines compiled in each standalone vk_pipeline_check run with --jobs 2.

Run Pipeline-check wall time Slowest pipeline
First run, no saved Leonida cache 40.9 s 36.01 s
Repeat with the saved Leonida cache Under 0.1 s 0.01 s
Repeat with the NVIDIA driver already warmed, without loading the Leonida cache 0.4 s 0.16 s

The 36-second compile exceeds the roughly 30-second startup watchdog budget described in this PR. The warm-driver control also sped up the run. These measurements cover standalone Vulkan pipeline creation. A retail boot with this cache is pending.

AI-assisted with Codex.

@sennecools

Copy link
Copy Markdown
Contributor

Tested 242a5dbf1 merged into the RT-5 integration branch (tibzejoker:rt5-integration c6f58906d) on Windows 11, RX 9070 XT (driver 32.0.32029.2010), MSVC RelWithDebInfo, own 1.0.2.1 copy: pass, and it clears the watchdog stop on AMD. This is the live A/B the mapping-only checks above left open.

Retail --run, LEONIDA_D3D12=vulkan, same loader, only LEONIDA_BVH_BUILDER changed, no pipeline_cache.bin:

shim (default) console, translated programs, cold driver cache
Builder imports bound to the shim 7 0
Modules mapped 4 5
Device slot 62 calls at the builder 0 first call never returns
D3D12 calls 1,656 (0 failed) 1,640
End of run title assert after the slot 41 calls at 2.5 s (stop 19) process ended by the title at 31.9 s (0xC0000005)

With LEONIDA_SKIP_INT3=1 the shim run continues exactly like the branch without this PR (1,661 calls, the xg_xs stop).

ctest -R ^xbox_bvh_builder: 3/3 on the RX 9070 XT (also with LEONIDA_VK_VALIDATION=1) and on the gfx1036 iGPU; 0/1000 rays differ for BLAS, compacted BLAS and TLAS.

Not covered: the title never reached a build, copy or rehydrate call in these runs, so the shim's results are not exercised on retail here. AI-assisted.

…he proxy path

From @KarolKurzyna's review of 242a5db:
- builder_device() returned the builder's device without a reference, so a
  destructor on another thread could release it during
  GetRaytracingAccelerationStructurePrebuildInfo. It now takes a reference
  under the lock, and the caller releases it after the call.
- The test only passed an unwrapped device. It now also constructs a builder
  on a d3d12_xs device proxy (create_device_proxy, as D3D12XboxCreateDevice
  hands out) and checks that its prebuild sizes are the real device's
  (13 checks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romainveurrier

Copy link
Copy Markdown
Contributor Author

Thanks all for the live runs: @zohaiblazuli, @Marukooh, @sennecools (the A/B with the 31.9 s watchdog end on AMD is the clearest measurement of the problem), and @KarolKurzyna, @MartinIndra02, @cdomergue, @ciagnij for the Windows runs.

@KarolKurzyna, both points are fixed in 98c065c:

  • builder_device() now takes a reference under the lock, and the caller releases it after the prebuild call.
  • The test also constructs a builder on a create_device_proxy device and checks that its sizes are the real device's (13 checks).

@sennecools, right: these runs never reached a build, copy or rehydrate call, so the retail exercise of those results is still to come. Rehydration is #7903 (stage 2). AI-assisted.

@FJKiXfaR

Copy link
Copy Markdown

checked: static read of the retail executable against this PR's call-site list | result: everything matches except one count. The image has 8 direct BuildRaytracingAccelerationStructureBatched2X call instructions, not 6: 4 in each of two sibling functions, all with the same (ID3D12GraphicsCommandList6*, UINT, const D3D12XBOX_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_BATCHED_DESC2*) shape and the same builder global. Caveat: neither sibling has an IDA xref (0 code, 0 data), so they are reached through a table or pointer the static scan does not resolve — 8 is the direct-call count, not proof that all 8 run. If the 6 came from a different tool, someone should confirm which two are considered dead before the count is written down.

Other shapes confirmed here: ctor 1 (the exe allocates exactly 24 bytes for the object and passes bool 0), dtor 1, Set64BitMortonCodes 8, prebuild-info 3 (stream desc null at two of them; the third's prebuild info drives a fixed 0x1A8000-byte scratch arena or heap fallback), copy 2 with (GCL4*, dest, source, mode) order, rehydrate 4 with (GCL8*, count <= 16, BUILD_DESC*, const UINT64*) and HRESULT return. The builder's own device reach is slot 16 CreateRootSignature (blob from its own d3d12_xs serialize) and slot 62 compute-PSO creation; the executable's own first console CreateComputePipelineState uses the same slot-62 shape, so one proxy branch serves both.
agent: yes

… its interfaces

From @tupacfan04's review of ItsNotRexed#7903: on a boot stack with the console list
proxy (ItsNotRexed#7076), the title's lists are proxies whose QueryInterface answers
only the console and public list IIDs. The shim asked the proxy itself, so a
private interface was refused, and a PC interface it did answer would have
been called through a console-shaped vtable.

d3d12_xs_device exposes real_object_behind_proxy(), the real object behind any
child proxy (proxy_real_object, which a console list proxy joins, as the file
and ItsNotRexed#7076 say), and the shim asks that real list for
ID3D12GraphicsCommandList4. On main lists aren't wrapped, so nothing changes
there; with ItsNotRexed#7076 the shim follows its lists without a further change.

docs/xdxr.md: BuildRaytracingAccelerationStructureBatched2X is 6 call
[rip+disp32] sites through the import table; IDA counts 8 direct calls, two
of them in another form (@FJKiXfaR on ItsNotRexed#7516).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romainveurrier added a commit to romainveurrier/Leonida that referenced this pull request Nov 23, 2026
… its interfaces

From @tupacfan04's review of ItsNotRexed#7903: on a boot stack with the console list
proxy (ItsNotRexed#7076), the title's lists are proxies whose QueryInterface answers
only the console and public list IIDs. The shim asked the proxy itself, so a
private interface was refused, and a PC interface it did answer would have
been called through a console-shaped vtable.

d3d12_xs_device exposes real_object_behind_proxy(), the real object behind any
child proxy (proxy_real_object, which a console list proxy joins, as the file
and ItsNotRexed#7076 say), and the shim asks that real list for
ID3D12GraphicsCommandList4. On main lists aren't wrapped, so nothing changes
there; with ItsNotRexed#7076 the shim follows its lists without a further change.

docs/xdxr.md: BuildRaytracingAccelerationStructureBatched2X is 6 call
[rip+disp32] sites through the import table; IDA counts 8 direct calls, two
of them in another form (@FJKiXfaR on ItsNotRexed#7516).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@autogenes-sudo

Copy link
Copy Markdown

Tested 65a2da200 on Windows 11 (26300), NVIDIA GeForce RTX 5060 (Blackwell, driver 621.14, Vulkan 1.4.357, 32-wide subgroups, wave64 emulated), MSVC 14.44 RelWithDebInfo, own 1.0.2.1 copy: pass. First NVIDIA result at this head.

Unit (main 6dda0630b + this PR, merged clean):

  • ctest -R xbox_bvh_builder: 3/3 passed
    • xbox_bvh_builder: 0 of 13 checks failed
    • xbox_bvh_builder_console (LEONIDA_BVH_BUILDER=console): 0 of 1 checks failed
    • xbox_bvh_builder_check: passed

Live retail --run, A/B (LEONIDA_D3D12=vulkan, work folder from make_game.py with the 52 bvh programs, network blocked). Base: ASTROWwwW:ladder ffc6f6da0 + #7163 #7330 #7115 #6885 #6981 #7323 #7858 #7529 #7403 #7679 #7290 #7755 #7201 (local merge), with and without this PR:

without #7516 with #7516
modules mapped 5 (bundled XboxBvhBuilder.dll loaded) 4 (DLL not loaded)
XboxBvhBuilder.dll imports bound to the DLL all 7 bound to the shim
D3D12 calls before the run ends 2,332 2,330 / 2,338
how it ends the title's int3, same site the title's int3, same site

Both end at the same later stop (slot 67 library pipelines, which my work folder doesn't have translated yet), so this PR changes nothing past the builder on this GPU.

Watchdog: not reproduced here. Both sides reach that stop in about 5 s (4.98 s / 4.73 s with a warm cache; 4.72 s / 5.05 s with __GL_SHADER_DISK_CACHE=0, which I can't confirm disables the Windows driver's cache). So this is no evidence for or against the cold-cache case on NVIDIA; @sambagarandawertanda's RTX 3080 numbers cover that.

AI-assisted (Claude Code).

@r1x0s

r1x0s commented Nov 23, 2026

Copy link
Copy Markdown

Tested 65a2da2 on Linux (cross-build: clang-cl 23.1.5 + xwin 0.10.0, SDK 10.0.26100, lld-link 23.1.4), Wine 11.22 + xvfb, on an NVIDIA GeForce RTX 4080 Laptop GPU (driver 620.73.04) and an Intel(R) Graphics RPL-S iGPU (Mesa 26.3.1 ANV):

  • xbox_bvh_builder: 13/13 on both GPUs (the test gained the device-proxy check in the second commit, so 13, not the 12 in the description).
  • xbox_bvh_builder_check: 0 validation errors, 0/1000 rays differing from brute force on the BLAS, the compacted BLAS and the TLAS, on both GPUs ("all cases match"); the three structures are the same size on both GPUs (BLAS and compacted 55,424 B, TLAS 512 B).
  • xbox_bvh_builder_console: passes on both GPUs.
  • gta6rt --dry-run on retail 1.0.2.1: all 7 XboxBvhBuilder.dll imports bind to the shim, 4 modules mapped instead of 5; with LEONIDA_BVH_BUILDER=console the bundled DLL is mapped again (5 modules, the 7 imports bind to it).
  • IAT call-site counts re-measured on the executable: 1/1/8/3/6/2/4, matching the table (the two further Batched2X call sites in another form are the (8)).
  • check_no_game_data.py passes on the new files; test_docs_links.py fails on the same pre-existing docs/dev-tools.md anchor that fails on main.
  • The RPL-S has no ray-tracing Vulkan extensions at all, so the iGPU run confirms the builder works on core compute + bufferDeviceAddress alone.

Not run here: a live boot to stop 18 (stops 1-17 are in open PRs, not in main). AI-assisted.

@wildheathen

Copy link
Copy Markdown
Contributor

Tested 65a2da200 on Windows 11, MSVC (VS 18 Build Tools), RTX 5080, Vulkan SDK 1.4.363.0, own 1.0.2.1 copy: pass, with one point about TLAS records below.

Security pass first: clean. I read the two build-system changes line by line. runtime/CMakeLists.txt adds the new source to the shim list and registers the three tests (the check runs the repository's tools/xdxr_bvh.py). scripts/build_runtime.ps1 adds the source to the cl.exe file list. Neither downloads anything or adds custom commands. The shim forwards to the layer's D3D12 device and list under a mutex, with reference counting. The only environment read is LEONIDA_BVH_BUILDER. The test writes only into its output directory. There are no processes, network or encoded data.

Tests:

Dry run (gta6rt --dry-run on my copy; binding kinds and counts only):

  • With this head, all 7 XboxBvhBuilder.dll imports bind to shim, and 4 modules are mapped instead of 5.
  • The unimplemented-import count is 29 here against 22 with a current-main loader. The 7 extra are all xmem.dll imports that main implemented after this branch's base, so the difference does not come from this PR.

The TLAS records the title now gets from the layer: with the shim, the title's top-level builds go to the layer's XDXR builder instead of the DLL's LoadInstances. The game's RT compute shaders read an instance's world-to-object matrix at +64 in the console order: the translation first (+64..+72), then the 3x3 row by row (+76, +88, +100). All 64 RT compute shaders in the package read it that way (D3D-412). The builder on main writes a row-major 3x4 there, so with this PR alone the boot gets past stop 18, but rays traced by the game would go through every instance with a transposed transform. #4011 fixes that order (and the leaf-frame fold you already name for stage 2). Stage 1 therefore depends on it for correct ray-tracing results too, not only stage 2. I'd add Depends on: #4011, or a line under "What differs from the console builder", so nobody reads a wrong image after stop 18 as a shim bug. This doesn't block the watchdog fix itself.

No live boot to stop 18 here. AI-assisted.

ASTROWwwW added a commit to ASTROWwwW/Leonida that referenced this pull request Nov 23, 2026
…Object tail

The ItsNotRexed#7516 merge resolution left a stray "`" fragment at the end of the $files
list and dropped its ForEach-Object tail, so PowerShell rejected the script.
Reported by ScarionWorkspace and tugasky on ItsNotRexed#7154; the parser reports 0 errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@altLov3r

Copy link
Copy Markdown

Tested 65a2da200f on Intel Arc A770 (Alchemist / Xe-HPG, PCI 0x8086:0x56a0, 16 GB VRAM, Windows 11, Intel driver 32.0.101.9150, Vulkan 1.4.359), built natively with MSVC 19.51.36257.0 (Windows SDK 10.0.26100, Vulkan-Headers 1.4.363.0, Python 3.14.4): PASS.

  • Build (gta6rt + xbox_bvh_builder_test): 23/23 targets built cleanly (0 errors).
  • ctest --test-dir runtime\build -C RelWithDebInfo -R "^xbox_bvh_builder" -V: 3/3 PASS (15.48 s total):
    • xbox_bvh_builder: PASS (1.76 s, 0 of 13 checks failed).
    • xbox_bvh_builder_console: PASS (0.01 s, 0 of 1 checks failed with LEONIDA_BVH_BUILDER=console).
    • xbox_bvh_builder_check: PASS (13.69 s) — shim_blas (55,424 B, 0 validation errors, 0/1000 rays differ), shim_blas_compacted (55,424 B, 0 validation errors, 0/1000 rays differ), shim_tlas (512 B, 0 validation errors, 0/1000 rays differ): all cases match.
  • Retail executable gta6rt --dry-run (own 1.0.2.1 copy outside the repo; binding counts only):
    • Default (shim active): 4 modules mapped, 29 unimplemented imports (shim=61 host=432 module=65), all 7/7 XboxBvhBuilder.dll imports bound to shim (bundled DLL not loaded).
    • LEONIDA_BVH_BUILDER=console: 5 modules mapped, 29 unimplemented imports (shim=54 host=432 module=72), 0 XboxBvhBuilder.dll imports bound to shim (bundled DLL mapped as expected).

AI-assisted test run (Antigravity / Gemini 4 Neon).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit 65a2da20)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…the layer's XDXR builder (RT-5, boot stop 18)

Squashed from ItsNotRexed#7516 by romainveurrier, head 242a5db (security scan PASS).
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ly pipeline compiles, so the title's startup hang check survives a cold boot (RT-5 follow-up, stop 18)

Squashed from ItsNotRexed#7858 by throny, head 4a51079 (security scan PASS).

Conflict in scripts/build_runtime.ps1 only: the file list keeps ItsNotRexed#7516's xbox_bvh_builder.cpp and adds host_stall.cpp.
dadnotdaddy pushed a commit to dadnotdaddy/Leonida that referenced this pull request Nov 23, 2026
…ocal static guards)

The descriptor-range table and heap-allocator locks (ItsNotRexed#7021) become constant-initialized SRWLOCK wrappers with a lazily made, immortal range vector; LEONIDA_XMEM_RESOURCE_BACKING (ItsNotRexed#7411) is cached in an atomic; XboxBvhBuilder's registration (ItsNotRexed#7516) makes its table with an immortal new. A function-local static with a dynamic initializer takes the CRT's thread-safe-init guard, which must not run on the title's thread once it owns TLS index 0 (the Wave 0 crash class).
Nikide added a commit to Nikide/Leonida that referenced this pull request Nov 23, 2026
@ramenbellic

Copy link
Copy Markdown

Tested 65a2da2 under Wine: Proton Experimental (wine 11), runtime cross-built with clang-cl 23.1.6 + xwin SDK 10.0.26100 (RelWithDebInfo), merged onto main dfe4e4ad3: pass

  • Build: OK with clang-cl.
  • The tests this PR adds or touches, under Proton: 14 passed, 3 skipped, 1 failed (of 18).
  • The 1 failing (xdxr_build_check) fail the same way on main dfe4e4ad3 alone in the same run, so none is from this PR.
  • Skipped under Wine, on main too: bvh_builder, device_proxy, device_proxy_trace (for example device_proxy needs a WARP adapter, which Wine doesn't have).

AI-assisted run (Claude Code); no game files used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.