hwrt: add DXR 1.1 BLAS/TLAS registry and XboxBvhBuilder HLE (#339) #347

Closed
github-bot wants to merge 4 commits from github-bot/gh-347 into main AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 14:54 UTC · original
Androtim:feat/hw-rt-phase2-registry-hle → main · +5366 −3 · 10 files · 4 commits · closed without merging

Implements the core Phase 2 Native DXR 1.1 infrastructure for #339 behind \VICTORY_HW_RT=1\ (off by default; zero RT-off impact):

  • *\ ictory-gpu::hwrt* (hwrt.rs, budget.rs, sanitize.rs):
    • Feature gate checking \VICTORY_HW_RT=1, \D3D12_RAYTRACING_TIER_1_1, \device_shader_model >= 6.5, and \ID3D12Device5.
    • DXR 1.1 BLAS/TLAS registry keyed by console GPU VA with \PERFORM_UPDATE\ refit parity checks, \LeasePool\ scratch/instance leases, per-frame BLAS build throttling (\Budget/\Backlog), LRU eviction (\BlasLru\ + GPU instance feedback readback), and \WriteBufferImmediate\ size responses aligned to 256 bytes.
    • GPU compute sanitization (\SANITIZE_HLSL: \clamp_ib\ / \copy_vb) and \D3D12_RAYTRACING_INSTANCE_DESC::AccelerationStructure\ VA remapping (\REMAP_HLSL).
  • *\ ictory-hle::modules::xboxbvh* (xboxbvh.rs):
    • Intercepts all 12 C++ exports of \XboxBvhBuilder.dll, registered in \modules::all()\ only when \ ictory_gpu::hwrt::requested()\ is true.
  • Minimal hooks in \host.rs\ (\HostList::hold\ / \Deferred::held), \watch.rs\ (\ itle_memory_freed), and \lib.rs.

Verification

  • \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1\ (21 passed; 0 failed — CPU logic + \d3dcompiler_47\ HLSL compile checks for \REMAP_HLSL\ and \SANITIZE_HLSL)
  • \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle -- --test-threads=1\ (238 passed, 3 ignored benchmarks + 1 integration test passed)
  • \cargo +1.98.1-x86_64-pc-windows-gnu xtask policy --staged\ (\8 files ok)
  • \cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings\ & --all-features\ (0 warnings)

Adapted from GPL-3.0 upstream implementations in \TrustNo1-Coder/Darner\ and
eadmet3xt-lab/foxhound.

**@⁠Androtim** on GitHub · 2026-12-02 14:54 UTC · [original](https://github.com/Androtim/MiniVI/pull/347) `Androtim:feat/hw-rt-phase2-registry-hle` → `main` · +5366 −3 · 10 files · 4 commits · closed without merging Implements the core Phase 2 Native DXR 1.1 infrastructure for #339 behind \VICTORY_HW_RT=1\ (off by default; zero RT-off impact): - **\ ictory-gpu::hwrt\** ([hwrt.rs](crates/victory-gpu/src/hwrt.rs), [budget.rs](crates/victory-gpu/src/hwrt/budget.rs), [sanitize.rs](crates/victory-gpu/src/hwrt/sanitize.rs)): - Feature gate checking \VICTORY_HW_RT=1\, \D3D12_RAYTRACING_TIER_1_1\, \device_shader_model >= 6.5\, and \ID3D12Device5\. - DXR 1.1 BLAS/TLAS registry keyed by console GPU VA with \PERFORM_UPDATE\ refit parity checks, \LeasePool\ scratch/instance leases, per-frame BLAS build throttling (\Budget\/\Backlog\), LRU eviction (\BlasLru\ + GPU instance feedback readback), and \WriteBufferImmediate\ size responses aligned to 256 bytes. - GPU compute sanitization (\SANITIZE_HLSL\: \clamp_ib\ / \copy_vb\) and \D3D12_RAYTRACING_INSTANCE_DESC::AccelerationStructure\ VA remapping (\REMAP_HLSL\). - **\ ictory-hle::modules::xboxbvh\** ([xboxbvh.rs](crates/victory-hle/src/modules/xboxbvh.rs)): - Intercepts all 12 C++ exports of \XboxBvhBuilder.dll\, registered in \modules::all()\ only when \ ictory_gpu::hwrt::requested()\ is true. - Minimal hooks in \host.rs\ (\HostList::hold\ / \Deferred::held\), \watch.rs\ (\ itle_memory_freed\), and \lib.rs\. ### Verification - \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1\ (21 passed; 0 failed — CPU logic + \d3dcompiler_47\ HLSL compile checks for \REMAP_HLSL\ and \SANITIZE_HLSL\) - \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle -- --test-threads=1\ (238 passed, 3 ignored benchmarks + 1 integration test passed) - \cargo +1.98.1-x86_64-pc-windows-gnu xtask policy --staged\ (\8 files ok\) - \cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings\ & \--all-features\ (0 warnings) Adapted from GPL-3.0 upstream implementations in \TrustNo1-Coder/Darner\ and \ eadmet3xt-lab/foxhound\.
Implements Phase 2 infrastructure behind VICTORY_HW_RT=1 (off by default):
- Add modular victory-gpu::hwrt registry, scratch/work lease pools,
  per-frame BLAS build throttling, LRU eviction with GPU instance feedback,
  and HLSL input sanitization / instance VA remapping.
- Gate initialization on D3D12_RAYTRACING_TIER_1_1 and Shader Model >= 6.5.
- Add victory-hle::modules::xboxbvh intercepting all 12 XboxBvhBuilder.dll
  C++ exports when VICTORY_HW_RT=1 is requested (zero RT-off overhead).
- Wire list hold lifecycle in host.rs and memory-free eviction in watch.rs.

Adapted cleanly from GPL-3.0 upstream implementations:
- TrustNo1-Coder/Darner (crates/darner-gpu/src/hwrt.rs, crates/darner-hle/src/modules/xboxbvh.rs)
- readmet3xt-lab/foxhound (crates/victory-gpu/src/hwrt.rs, crates/victory-hle/src/modules/xboxbvh.rs)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 14:55:49 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 16:04 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Solid foundational DXR 1.1 infrastructure for #339, cleanly gated behind VICTORY_HW_RT=1 (off by default). CI is passing, and the lock hierarchy in HwRtManager (blas_table -> queue -> lru -> as_map -> shown) is acyclic.

Verified Changes

  • crates/victory-gpu/src/host.rs: Minimal addition of Deferred::held (Vec<Box<dyn Any + Send>>), HostList::hold, Deferred::reset clamping, and HostList::untouched check.
  • crates/victory-gpu/src/hwrt.rs & crates/victory-gpu/src/hwrt/budget.rs:
    • Capability gate (can_enable / supported) checks D3D12_RAYTRACING_TIER_1_1, SM >= 6.5, and ID3D12Device5.
    • Per-frame BLAS build throttling (BlasQueue / Budget / Backlog), VRAM-budgeted LRU eviction (BlasLru + GPU instance feedback readback via Feedback), scratch/work LeasePool, and PERFORM_UPDATE refit parity checks (geom_keys_from_descs).
    • GPU compute sanitization (clamp_ib_pso / copy_vb_pso) and TLAS instance VA remapping (remap_pso) with WriteBufferImmediate / EmitRaytracingAccelerationStructurePostbuildInfo responses.

Minor Edge Cases Noted

  1. State leak on OOM early return in HwRtManager::execute_build (crates/victory-gpu/src/hwrt.rs): When building a TLAS, dst_inst_buf is transitioned from UNORDERED_ACCESS to NON_PIXEL_SHADER_RESOURCE after the remap dispatch, but if self.lease (for TLAS scratch) or self.alloc_or_reuse_as (for dest_as) subsequently returns None, execute_build returns early without transitioning dst_inst_buf back to UNORDERED_ACCESS before Lease::drop returns it to self.leases. Moving the scratch lease / dest_as allocation ahead of the remap barrier (or restoring the state on early return) would prevent a D3D12 state mismatch on allocation failure.
  2. len == 0 in hwrt::title_memory_freed (crates/victory-gpu/src/hwrt.rs): Returns early when len == 0, whereas watch::title_memory_freed supports len == 0 for whole-allocation MEM_RELEASE frees (unless watch.rs passes a resolved byte length).

(Note: The PR diff payload was truncated at 120 KB of 171 KB, so sanitize.rs, xboxbvh.rs, the tail of budget.rs, and the small wiring hunks in lib.rs/watch.rs/modules/mod.rs were not directly inspected.)

Next Step

Warrants a local real-GPU DXR 1.1 smoke test (both RT-off default and VICTORY_HW_RT=1) before merging.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-12-02 16:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/347#issuecomment-7351386089) <!-- minivi-triage v1 head=5e532641930eaf7f11afc95cd5592d8f5369dcac verdict=needs-gpu-test ci=passing at=2026-12-02T16:04:39Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Solid foundational DXR 1.1 infrastructure for `#339`, cleanly gated behind `VICTORY_HW_RT=1` (off by default). CI is passing, and the lock hierarchy in `HwRtManager` (`blas_table` -> `queue` -> `lru` -> `as_map` -> `shown`) is acyclic. ### Verified Changes - **`crates/victory-gpu/src/host.rs`**: Minimal addition of `Deferred::held` (`Vec<Box<dyn Any + Send>>`), `HostList::hold`, `Deferred::reset` clamping, and `HostList::untouched` check. - **`crates/victory-gpu/src/hwrt.rs` & `crates/victory-gpu/src/hwrt/budget.rs`**: - Capability gate (`can_enable` / `supported`) checks `D3D12_RAYTRACING_TIER_1_1`, SM >= 6.5, and `ID3D12Device5`. - Per-frame BLAS build throttling (`BlasQueue` / `Budget` / `Backlog`), VRAM-budgeted LRU eviction (`BlasLru` + GPU instance feedback readback via `Feedback`), scratch/work `LeasePool`, and `PERFORM_UPDATE` refit parity checks (`geom_keys_from_descs`). - GPU compute sanitization (`clamp_ib_pso` / `copy_vb_pso`) and TLAS instance VA remapping (`remap_pso`) with `WriteBufferImmediate` / `EmitRaytracingAccelerationStructurePostbuildInfo` responses. ### Minor Edge Cases Noted 1. **State leak on OOM early return in `HwRtManager::execute_build`** (`crates/victory-gpu/src/hwrt.rs`): When building a TLAS, `dst_inst_buf` is transitioned from `UNORDERED_ACCESS` to `NON_PIXEL_SHADER_RESOURCE` after the remap dispatch, but if `self.lease` (for TLAS scratch) or `self.alloc_or_reuse_as` (for `dest_as`) subsequently returns `None`, `execute_build` returns early without transitioning `dst_inst_buf` back to `UNORDERED_ACCESS` before `Lease::drop` returns it to `self.leases`. Moving the scratch lease / `dest_as` allocation ahead of the remap barrier (or restoring the state on early return) would prevent a D3D12 state mismatch on allocation failure. 2. **`len == 0` in `hwrt::title_memory_freed`** (`crates/victory-gpu/src/hwrt.rs`): Returns early when `len == 0`, whereas `watch::title_memory_freed` supports `len == 0` for whole-allocation `MEM_RELEASE` frees (unless `watch.rs` passes a resolved byte length). *(Note: The PR diff payload was truncated at 120 KB of 171 KB, so `sanitize.rs`, `xboxbvh.rs`, the tail of `budget.rs`, and the small wiring hunks in `lib.rs`/`watch.rs`/`modules/mod.rs` were not directly inspected.)* ### Next Step Warrants a local real-GPU DXR 1.1 smoke test (both RT-off default and `VICTORY_HW_RT=1`) before merging. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 17:04 UTC · original

Holding merge (triage: needs work) per Deep Static Audit Pass #2 (#282 comment 7352688269, DXR 1.1 P0/P1 findings #1–#20 routed to #339; note #354 must not merge without #357's shader_cache.rs key isolation #10).

**@⁠Androtim** on GitHub · 2026-12-02 17:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/347#issuecomment-7352860129) Holding merge (`triage: needs work`) per Deep Static Audit Pass #2 (`#282` comment `7352688269`, DXR 1.1 P0/P1 findings #1–#20 routed to `#339`; note `#354` must not merge without `#357`'s `shader_cache.rs` key isolation #10).
github-bot closed this pull request 2026-12-03 00:06:59 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-03 00:03 UTC · original

Merged into main (b0efcacc) via the Audit Pass #5 green-lit superset PR #357 (complete #339 DXR 1.1 RayQuery stack behind VICTORY_HW_RT=1, zero non-RT impact).

**@⁠Androtim** on GitHub · 2026-12-03 00:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/347#issuecomment-7362754110) Merged into main (b0efcacc) via the Audit Pass #5 green-lit superset PR #357 (complete #339 DXR 1.1 RayQuery stack behind VICTORY_HW_RT=1, zero non-RT impact).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!347
No description provided.