hwrt: add meshlet IB & quant24 VB decoders, menu switch, and telemetry (#339) #349

Closed
Androtim wants to merge 4 commits from upstream-pr/349 into feat/hw-rt-phase2-registry-hle
Androtim commented 2026-12-02 15:01:47 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:01:47Z.


Completes Phase 2 Native DXR 1.1 BLAS/TLAS support for #339 on top of #347 (still strictly behind \VICTORY_HW_RT=1, zero RT-off impact):

  • *\ ictory-gpu::hwrt::decoders* (decoders.rs):

    • eadable_len\ / \ itle_readable\ combining \watch::materialize\ + \VirtualQuery\ across lazy placeholder views.
    • Console compact meshlet index buffer decoder (\IndexFormat == 53) with winding-flip flag support, out-of-range triangle degeneration (\sane_triangle), and bounded 256 MiB \MeshletCache.
    • Console 24-24-16 quantized position vertex buffer decoder (\VertexFormat == 16) reading the \ b_va - 0x20\ quantization header, applying swizzle/scale/bias, and sanitizing extremes via \sane_position.
  • *\ ictory-gpu::hwrt* (hwrt.rs):
    • Standard-IB \ alidated_ibs\ scan hint cache in \prepare_triangles\ + eviction in \ itle_memory_freed.
    • Periodic 5-second \hwrt::report_line\ telemetry wired into \host.rs.
  • Cache & UI wiring:
    • \shader_cache.rs: appends \VICTORY_HW_RT=1\ / \VICTORY_HW_RT_LIFT=0\ cache keys ONLY when requested (zero RT-off cache invalidation).
    • \host/menu.rs: adds \VICTORY_HW_RT\ toggle (\HARDWARE RAY TRACING (DXR 1.1)).

Verification

  • \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1\ (26 passed; 0 failed)
  • \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib menu::tests -- --test-threads=1\ (6 passed; 0 failed)
  • \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shader_cache::tests -- --test-threads=1\ (2 passed; 0 failed)
  • \cargo +1.98.1-x86_64-pc-windows-gnu xtask policy --staged\ (\6 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 \TrustNo1-Coder/Darner.

<!-- greyfinch-sync:Androtim/MiniVI:issue:5609071916 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/349). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:01:47Z. --- Completes Phase 2 Native DXR 1.1 BLAS/TLAS support for #339 on top of #347 (still strictly behind \VICTORY_HW_RT=1\, zero RT-off impact): - **\ ictory-gpu::hwrt::decoders\** ([decoders.rs](crates/victory-gpu/src/hwrt/decoders.rs)): - \ eadable_len\ / \ itle_readable\ combining \watch::materialize\ + \VirtualQuery\ across lazy placeholder views. - Console compact meshlet index buffer decoder (\IndexFormat == 53\) with winding-flip flag support, out-of-range triangle degeneration (\sane_triangle\), and bounded 256 MiB \MeshletCache\. - Console 24-24-16 quantized position vertex buffer decoder (\VertexFormat == 16\) reading the \ b_va - 0x20\ quantization header, applying swizzle/scale/bias, and sanitizing extremes via \sane_position\. - **\ ictory-gpu::hwrt\** ([hwrt.rs](crates/victory-gpu/src/hwrt.rs)): - Standard-IB \ alidated_ibs\ scan hint cache in \prepare_triangles\ + eviction in \ itle_memory_freed\. - Periodic 5-second \hwrt::report_line\ telemetry wired into \host.rs\. - **Cache & UI wiring**: - \shader_cache.rs\: appends \VICTORY_HW_RT=1\ / \VICTORY_HW_RT_LIFT=0\ cache keys ONLY when requested (zero RT-off cache invalidation). - \host/menu.rs\: adds \VICTORY_HW_RT\ toggle (\HARDWARE RAY TRACING (DXR 1.1)\). ### Verification - \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1\ (26 passed; 0 failed) - \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib menu::tests -- --test-threads=1\ (6 passed; 0 failed) - \cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shader_cache::tests -- --test-threads=1\ (2 passed; 0 failed) - \cargo +1.98.1-x86_64-pc-windows-gnu xtask policy --staged\ (\6 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 \TrustNo1-Coder/Darner\.
Androtim commented 2026-12-02 15:11:24 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T15:11:24Z.


Automated triage for the maintainers (not an approval).

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

Review Summary

Logic, bounds checking, and isolation look solid, and CI is passing. Because this PR adds D3D12 upload-buffer caching (cached_meshlet_ib / MeshletCache), DXR 1.1 BLAS geometry decoders (decode_title_meshlet_ib, decode_title_quant24_vb), an in-game menu toggle (VICTORY_HW_RT), and periodic host telemetry (hwrt::report_line), it warrants a local real-GPU smoke test (with PR #347 merged first, since this branch builds on #347).

Verified Details

  • Zero RT-off impact:
    • crates/victory-gpu/src/host/menu.rs: VICTORY_HW_RT defaults to UNSET_ON (off) with live: false.
    • crates/victory-gpu/src/shader_cache.rs: VICTORY_HW_RT=1 / VICTORY_HW_RT_LIFT=0 are only hashed into the cache key when crate::hwrt::requested() is true, avoiding RT-off cache invalidation.
    • crates/victory-gpu/src/host.rs & crates/victory-gpu/src/hwrt.rs: hwrt::report_line returns immediately when !requested(), and acquires manager locks individually in separate scopes (no lock-ordering hazards).
  • Decoders & memory safety (crates/victory-gpu/src/hwrt/decoders.rs):
    • readable_len / title_readable materialize lazy views via watch::materialize and verify committed, non-guard, readable pages via VirtualQuery before any raw pointer reads.
    • decode_title_meshlet_ib bounds-checks num_meshlets, packed_tris_off, vertex_indices_off, meshlet_id, and base_vi + max_loc against max_vi_u16s, supports flip_winding, and degenerates out-of-range triangles via sane_triangle.
    • decode_title_quant24_vb validates vb_va >= 0x20, checks header/vertex readability and finiteness of bias/scale, and sanitizes output via sane_position.
    • MeshletCache enforces the 256 MiB (MESHLET_CACHE_BYTES) budget with generation tracking on forget (called from title_memory_freed), and cached_meshlet_ib calls list.keep(&entry.buffer) before dropping retired entries outside the cache lock.
  • Standard IB validation (crates/victory-gpu/src/hwrt.rs):
    • prepare_triangles caches max scanned indices in validated_ibs (evicted on title_memory_freed) and expands eff_vc when the existing non-staged shadow buffer covers exp_bytes, falling back to GPU index clamping otherwise.
    • Minor note: prepare_triangles uses std::slice::from_raw_parts on index_buffer after checking host_ib.is_multiple_of(isize); this relies on shadow buffer GPU VA preserving alignment modulo 2/4 and assumes no concurrent title CPU writes to the IB during the scan.

Local GPU Verification Needed

  • Confirm RT-off default run shows no shader cache invalidation, no hardware RT: log lines, and no regression.
  • Enable VICTORY_HW_RT=1 (and toggle via the F1/settings menu) on a DXR 1.1 GPU, verify hardware RT: / hardware RT meshlet index cache: telemetry logs report decoded quant24 VBs and meshlet IBs without device removal, validation errors, or unbounded upload memory growth.

Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7349891775 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/349#issuecomment-7349891775). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:11:24Z. --- <!-- minivi-triage v1 head=c2017ae597ea5e6efce95f849abea29e3bef6c5b verdict=needs-gpu-test ci=passing at=2026-12-02T17:09:21Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Logic, bounds checking, and isolation look solid, and CI is passing. Because this PR adds D3D12 upload-buffer caching (`cached_meshlet_ib` / `MeshletCache`), DXR 1.1 BLAS geometry decoders (`decode_title_meshlet_ib`, `decode_title_quant24_vb`), an in-game menu toggle (`VICTORY_HW_RT`), and periodic host telemetry (`hwrt::report_line`), it warrants a local real-GPU smoke test (with PR #347 merged first, since this branch builds on #347). ### Verified Details - **Zero RT-off impact**: - `crates/victory-gpu/src/host/menu.rs`: `VICTORY_HW_RT` defaults to `UNSET_ON` (off) with `live: false`. - `crates/victory-gpu/src/shader_cache.rs`: `VICTORY_HW_RT=1` / `VICTORY_HW_RT_LIFT=0` are only hashed into the cache key when `crate::hwrt::requested()` is true, avoiding RT-off cache invalidation. - `crates/victory-gpu/src/host.rs` & `crates/victory-gpu/src/hwrt.rs`: `hwrt::report_line` returns immediately when `!requested()`, and acquires manager locks individually in separate scopes (no lock-ordering hazards). - **Decoders & memory safety (`crates/victory-gpu/src/hwrt/decoders.rs`)**: - `readable_len` / `title_readable` materialize lazy views via `watch::materialize` and verify committed, non-guard, readable pages via `VirtualQuery` before any raw pointer reads. - `decode_title_meshlet_ib` bounds-checks `num_meshlets`, `packed_tris_off`, `vertex_indices_off`, `meshlet_id`, and `base_vi + max_loc` against `max_vi_u16s`, supports `flip_winding`, and degenerates out-of-range triangles via `sane_triangle`. - `decode_title_quant24_vb` validates `vb_va >= 0x20`, checks header/vertex readability and finiteness of `bias`/`scale`, and sanitizes output via `sane_position`. - `MeshletCache` enforces the 256 MiB (`MESHLET_CACHE_BYTES`) budget with generation tracking on `forget` (called from `title_memory_freed`), and `cached_meshlet_ib` calls `list.keep(&entry.buffer)` before dropping retired entries outside the cache lock. - **Standard IB validation (`crates/victory-gpu/src/hwrt.rs`)**: - `prepare_triangles` caches max scanned indices in `validated_ibs` (evicted on `title_memory_freed`) and expands `eff_vc` when the existing non-staged shadow buffer covers `exp_bytes`, falling back to GPU index clamping otherwise. - Minor note: `prepare_triangles` uses `std::slice::from_raw_parts` on `index_buffer` after checking `host_ib.is_multiple_of(isize)`; this relies on shadow buffer GPU VA preserving alignment modulo 2/4 and assumes no concurrent title CPU writes to the IB during the scan. ### Local GPU Verification Needed - Confirm RT-off default run shows no shader cache invalidation, no `hardware RT:` log lines, and no regression. - Enable `VICTORY_HW_RT=1` (and toggle via the F1/settings menu) on a DXR 1.1 GPU, verify `hardware RT:` / `hardware RT meshlet index cache:` telemetry logs report decoded quant24 VBs and meshlet IBs without device removal, validation errors, or unbounded upload memory growth. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 17:04:24 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T17:04:24Z.


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).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7352861563 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/349#issuecomment-7352861563). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T17:04:24Z. --- 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 commented 2026-12-03 00:04:00 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T00:04:00Z.


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).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7362755320 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/349#issuecomment-7362755320). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T00:04:00Z. --- 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

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
Androtim/MiniVI!349
No description provided.