[Research] XboxBvhBuilder.dll internals: vtable +0x2D0 / +0x490 calls and global flags blocking BVH build #3275

Open
opened 2026-11-26 15:36:30 +00:00 by megaliv3 · 1 comment
megaliv3 commented 2026-11-26 15:36:30 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by megaliv3 on 2026-11-26T15:36:30Z.


Hi! Noticed in the README status table that "The title's ray-tracing structures are never built". I did some static analysis on XboxBvhBuilder.dll (from build 1.0.2.1) in Ghidra and wanted to share a few specific RVA offsets and command-list interactions in case they help with HLE debugging:

Key Findings in XboxBvhBuilder.dll

  1. Non-standard ID3D12GraphicsCommandList6 VTable Calls (ExecuteBatchedBvhBuild @ 0x18000e6a0):

    • VTable +0x2D0: Called in a loop over batch elements when global flag 0x1800d773c is non-zero. Writes a 32-bit 0 marker directly to GPU memory (WriteValueImmediate style).
    • VTable +0x490: Called between std::function compute passes when global flag 0x1800d773b is non-zero, passing a memory range struct ({0x100000000, &{0x8000000080, 0x1000000010}}) for Xbox GPU cache flushing.
    • VTable +0x0D0: Standard ResourceBarrier (UAV) emitted at the end of BuildRaytracingAccelerationStructureBatched2X (0x1800216a0) if 0x1800d773c != 0.
  2. Compute Pass Emitter & Ring Buffer Check (0x180020760):

    • Checks internal command list pointers before emitting raw AMD PM4 packets (e.g. 0x4002c400 / IT_DISPATCH_DIRECT).
    • Note: Every PM4 fast-path block has a standard D3D12 else fallback branch (+0x108, +0x0C8, +0x168, +0x128, +0x070) when the ring-buffer space check fails.
    • Shader dispatch math (((count + 3) >> 2 + 0x1f) >> 5) indicates [numthreads(128, 1, 1)] (4 elements per lane, 32 lanes).
  3. Global State Flags & Validation:

    • 0x1800d7b4c (bool): Toggled by Set64BitMortonCodes(bool) (0x180021bd0), doubles Morton buffer allocation in the scratch layout calculator (0x18000e4c0).
    • 0x1800d7b4e (bool): Alters scratch buffer offset packing in 0x18000e4c0.
    • BuildRaytracingAccelerationStructureBatched2X throws C++ exception 0x80070057 (E_INVALIDARG) if DestAccelerationStructureData is not 256-byte aligned, and rejects postbuild info type 0x10 (OFFLINE_STATISTICS) at runtime.
  4. External Xbox Imports:

    • d3d12_xs.dll -> D3D12SerializeVersionedRootSignature
    • xmem.dll -> XMemVirtualQuery

Hope these offsets are useful if you decide to tackle BVH building next!

<!-- greyfinch-sync:Marvisak/VIctory:issue:6630055527 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3277). Originally posted by [megaliv3](https://github.com/megaliv3) on 2026-11-26T15:36:30Z. --- Hi! Noticed in the README status table that **"The title's ray-tracing structures are never built"**. I did some static analysis on `XboxBvhBuilder.dll` (from build `1.0.2.1`) in Ghidra and wanted to share a few specific RVA offsets and command-list interactions in case they help with HLE debugging: ### Key Findings in `XboxBvhBuilder.dll` 1. **Non-standard `ID3D12GraphicsCommandList6` VTable Calls (`ExecuteBatchedBvhBuild` @ `0x18000e6a0`):** - **VTable `+0x2D0`:** Called in a loop over batch elements when global flag `0x1800d773c` is non-zero. Writes a 32-bit `0` marker directly to GPU memory (`WriteValueImmediate` style). - **VTable `+0x490`:** Called between `std::function` compute passes when global flag `0x1800d773b` is non-zero, passing a memory range struct (`{0x100000000, &{0x8000000080, 0x1000000010}}`) for Xbox GPU cache flushing. - **VTable `+0x0D0`:** Standard `ResourceBarrier` (UAV) emitted at the end of `BuildRaytracingAccelerationStructureBatched2X` (`0x1800216a0`) if `0x1800d773c != 0`. 2. **Compute Pass Emitter & Ring Buffer Check (`0x180020760`):** - Checks internal command list pointers before emitting raw AMD PM4 packets (e.g. `0x4002c400` / `IT_DISPATCH_DIRECT`). - Note: Every PM4 fast-path block has a standard D3D12 `else` fallback branch (`+0x108`, `+0x0C8`, `+0x168`, `+0x128`, `+0x070`) when the ring-buffer space check fails. - Shader dispatch math (`((count + 3) >> 2 + 0x1f) >> 5`) indicates `[numthreads(128, 1, 1)]` (4 elements per lane, 32 lanes). 3. **Global State Flags & Validation:** - `0x1800d7b4c` (`bool`): Toggled by `Set64BitMortonCodes(bool)` (`0x180021bd0`), doubles Morton buffer allocation in the scratch layout calculator (`0x18000e4c0`). - `0x1800d7b4e` (`bool`): Alters scratch buffer offset packing in `0x18000e4c0`. - `BuildRaytracingAccelerationStructureBatched2X` throws C++ exception `0x80070057` (`E_INVALIDARG`) if `DestAccelerationStructureData` is not 256-byte aligned, and rejects postbuild info type `0x10` (`OFFLINE_STATISTICS`) at runtime. 4. **External Xbox Imports:** - `d3d12_xs.dll` -> `D3D12SerializeVersionedRootSignature` - `xmem.dll` -> `XMemVirtualQuery` Hope these offsets are useful if you decide to tackle BVH building next!
ZeOs360 commented 2026-11-27 08:35:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by ZeOs360 on 2026-11-27T08:35:21Z.


A data point on +0x2D0 and +0x490 from runs where the BVH builder does run.

Setup: main 63bcca4 with #2098, #2118, #2703, #2841, #2810 and #2501 merged (plus #2875, #2821, and local changes and diagnostics), diagnostics build, RX 7800 XT 16 GB, Windows 11. There the builder's shaders run: in the first such run they were dispatched in 709 of the 723 frames after their first use.

  • +0x2D0 is never called. The command list has no method in that slot, and every empty slot goes to a stub that logs method not implemented object="command list" slot=... the first time it is called. Across 18 runs of 2.5 to 20 minutes, that line never appears for any command-list slot. The only unimplemented methods logged are two device slots (0x1c8 and 0x218).
  • +0x490 is already handled. It is the enhanced barrier (barrier_groups in crates/victory-gpu/src/list.rs, slot 146 of the newer lists' table).

So on this setup the path that calls +0x2D0 is not taken; going by your reading, its flag stays zero here. I don't know whether the console sets it, so I can't say whether taking that path would change the builder's results.

AI-assisted: written with Claude Code (Claude Opus 5.5). I checked the code and ran the builds on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7213698684 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3277#issuecomment-7213698684). Originally posted by [ZeOs360](https://github.com/ZeOs360) on 2026-11-27T08:35:21Z. --- A data point on +0x2D0 and +0x490 from runs where the BVH builder does run. Setup: `main` `63bcca4` with #2098, #2118, #2703, #2841, #2810 and #2501 merged (plus #2875, #2821, and local changes and diagnostics), diagnostics build, RX 7800 XT 16 GB, Windows 11. There the builder's shaders run: in the first such run they were dispatched in 709 of the 723 frames after their first use. - **+0x2D0 is never called.** The command list has no method in that slot, and every empty slot goes to a stub that logs `method not implemented object="command list" slot=...` the first time it is called. Across 18 runs of 2.5 to 20 minutes, that line never appears for any command-list slot. The only unimplemented methods logged are two device slots (0x1c8 and 0x218). - **+0x490 is already handled.** It is the enhanced barrier (`barrier_groups` in `crates/victory-gpu/src/list.rs`, slot 146 of the newer lists' table). So on this setup the path that calls +0x2D0 is not taken; going by your reading, its flag stays zero here. I don't know whether the console sets it, so I can't say whether taking that path would change the builder's results. AI-assisted: written with Claude Code (Claude Opus 5.5). I checked the code and ran the builds on my machine.
Sign in to join this conversation.
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
Marvisak/VIctory#3275
No description provided.