victory-gpu: DXR 1.1 TLAS root/heap binding, cache serialization & RayQuery telemetry (#339) #357

Merged
Androtim merged 26 commits from upstream-pr/357 into main 2026-12-03 00:03:11 +00:00
Androtim commented 2026-12-02 15:47:53 +00:00 (Migrated from github.com)

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


Phase 3 PR #8 for #339 (combines #354 [feat/hw-rt-phase3-traversal-lifter] and Phase 2 #349 [feat/hw-rt-phase2-mesh-decoders]; targeting feat/hw-rt-phase3-traversal-lifter).

Summary

  • Root TLAS SRVs (pipeline/host.rs, draw.rs): Declare D3D12_ROOT_PARAMETER_TYPE_SRV (Flags: NONE) root parameters for HostShader::ray_queries.tlas_srvs, resolve console TLAS GPU VAs from root descriptor tables in draw::bind, and bind host DXR TLAS VAs via hwrt::tlas_gpu_va (dropping dispatches safely if the DXR manager is unavailable).
  • Descriptor-heap TLAS SRVs (descriptor/host.rs): Create D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE SRVs on View::Shader entries via hwrt::tlas_for_descriptor and bypass ListViews caching for acceleration-structure slots so dynamic TLAS rebuilds stay current.
  • Shader cache (shader_cache.rs): Serialize/deserialize HostShader::ray_queries while staying backwards-compatible with legacy cache entries (entries_round_trip_and_reject_damage updated and verified).
  • Pipeline integration & telemetry (hwrt.rs, pipeline.rs, pipeline/make.rs, draw.rs): Log lifted RayQuery counts per compute program (note_program) and direct/indirect dispatch (note_dispatch), include per-frame lifted/partly/fallback stats in hwrt::report_line, and enable CS_RaytracingResolve when VICTORY_HW_RT=1 unless explicitly disabled (VICTORY_RT_RESOLVE=0).

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy --staged (7 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::rayquery -- --test-threads=1 (11 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1 (27 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shader_cache::tests (2 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib pipeline::make::tests (11 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib pipeline::host::tests (6 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib root::tests (11 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle --lib xboxbvh:: (2 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --all-features -- -D warnings (0 warnings)

GPL-3.0 references: TrustNo1-Coder/Darner, readmet3xt-lab/foxhound

<!-- greyfinch-sync:Androtim/MiniVI:issue:5609891932 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/357). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:47:53Z. --- Phase 3 PR #8 for #339 (combines #354 [`feat/hw-rt-phase3-traversal-lifter`] and Phase 2 #349 [`feat/hw-rt-phase2-mesh-decoders`]; targeting `feat/hw-rt-phase3-traversal-lifter`). ### Summary - **Root TLAS SRVs (`pipeline/host.rs`, `draw.rs`):** Declare `D3D12_ROOT_PARAMETER_TYPE_SRV` (`Flags: NONE`) root parameters for `HostShader::ray_queries.tlas_srvs`, resolve console TLAS GPU VAs from root descriptor tables in `draw::bind`, and bind host DXR TLAS VAs via `hwrt::tlas_gpu_va` (dropping dispatches safely if the DXR manager is unavailable). - **Descriptor-heap TLAS SRVs (`descriptor/host.rs`):** Create `D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE` SRVs on `View::Shader` entries via `hwrt::tlas_for_descriptor` and bypass `ListViews` caching for acceleration-structure slots so dynamic TLAS rebuilds stay current. - **Shader cache (`shader_cache.rs`):** Serialize/deserialize `HostShader::ray_queries` while staying backwards-compatible with legacy cache entries (`entries_round_trip_and_reject_damage` updated and verified). - **Pipeline integration & telemetry (`hwrt.rs`, `pipeline.rs`, `pipeline/make.rs`, `draw.rs`):** Log lifted `RayQuery` counts per compute program (`note_program`) and direct/indirect dispatch (`note_dispatch`), include per-frame lifted/partly/fallback stats in `hwrt::report_line`, and enable `CS_RaytracingResolve` when `VICTORY_HW_RT=1` unless explicitly disabled (`VICTORY_RT_RESOLVE=0`). ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy --staged` (`7 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::rayquery -- --test-threads=1` (`11 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib hwrt:: -- --test-threads=1` (`27 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib shader_cache::tests` (`2 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib pipeline::make::tests` (`11 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib pipeline::host::tests` (`6 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib root::tests` (`11 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-hle --lib xboxbvh::` (`2 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --all-features -- -D warnings` (0 warnings) GPL-3.0 references: `TrustNo1-Coder/Darner`, `readmet3xt-lab/foxhound`
Androtim commented 2026-12-02 16:08:03 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T16:08:03Z.


Automated triage for the maintainers (not an approval).

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

Automated Technical Review — PR #357

Verdict: needs-gpu-test (CI passing; gated behind VICTORY_HW_RT=1, off by default).

What was reviewed

(Note: this PR is stacked on #354 / feat/hw-rt-phase3-traversal-lifter + #349, so the diff against origin/main was truncated at 120 KB; descriptor/host.rs, draw.rs, host.rs, host/menu.rs, and the first ~2750 lines of hwrt.rs were inspected directly.)

  • crates/victory-gpu/src/descriptor/host.rs:
    • HostHeap::make_listed_batched skips ListViews caching for D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE when crate::hwrt::requested() is set, avoiding stale TLAS descriptors across rebuilds.
    • make_twinned decodes the 64-bit console VA from d[4]/d[5] (matching the 16-byte-aligned D3D12_SHADER_RESOURCE_VIEW_DESC union offset) and creates a D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE SRV with None resource via crate::hwrt::tlas_for_descriptor.
  • crates/victory-gpu/src/draw.rs:
    • State::bind resolves console TLAS VAs from stage.tlas_srvs root descriptor tables and binds the host VA via crate::hwrt::tlas_gpu_va, safely dropping the dispatch if no DXR TLAS manager is active.
    • Direct and indirect compute dispatches record RayQuery telemetry via crate::hwrt::note_dispatch.
  • crates/victory-gpu/src/host.rs & host/menu.rs:
    • Deferred::held / HostList::hold cleanly ties lease/readback lifetimes to command list reset, and HostList::untouched accounts for deferred.held.
    • VICTORY_HW_RT is exposed in ITEMS as UNSET_ON (off by default).

Minor non-blocking notes

  1. crates/victory-gpu/src/hwrt.rs (HwRtManager::execute_build): On the TLAS path, dst_inst_buf is transitioned from UNORDERED_ACCESS to NON_PIXEL_SHADER_RESOURCE before self.lease(list, info.ScratchDataSizeInBytes) and self.alloc_or_reuse_as(...). If either allocation returns None (OOM), the early return skips transitioning dst_inst_buf back to UNORDERED_ACCESS before it is returned to self.leases on list reset.
  2. crates/victory-gpu/src/hwrt.rs (HwRtManager::alloc_or_reuse_as): Still contains a leftover // TODO(phase3): notify TLAS SRV descriptor bindings when RayQuery traversal lifting lands. comment.
  3. Verify view_address for TLAS table entries: In draw.rs (State::bind), stage.tlas_srvs extracts console_tlas_va via crate::descriptor::view(handle).and_then(|v| crate::descriptor::host::view_address(&v)). Confirm during GPU testing that console TLAS table descriptors yield non-zero console_tlas_va (and don't silently fall back to 0 / empty TLAS) on real RT dispatches.

Suggested real-GPU smoke test

Requires a DXR 1.1 + SM 6.5+ GPU. Run with VICTORY_HW_RT=0 (default regression check) and VICTORY_HW_RT=1 (with D3D12 debug layer if available), checking:

  • No D3D12 validation errors on root TLAS SRVs, descriptor-heap TLAS SRVs, or BuildRaytracingAccelerationStructure barriers.
  • hwrt::report_line / hwrt: built native DXR TLAS logs show non-zero BLAS/TLAS builds, matched remaps, and lifted RayQuery dispatches without device removal.
  • Shader cache cold + warm restart round-trips cleanly with VICTORY_HW_RT=1.

Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7351489846 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/357#issuecomment-7351489846). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T16:08:03Z. --- <!-- minivi-triage v1 head=679283a2c1f66c77c355b2f532b5f090eb76e5b8 verdict=needs-gpu-test ci=passing at=2026-12-02T16:08:34Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Automated Technical Review — PR #357 **Verdict:** `needs-gpu-test` (CI passing; gated behind `VICTORY_HW_RT=1`, off by default). #### What was reviewed *(Note: this PR is stacked on #354 / `feat/hw-rt-phase3-traversal-lifter` + #349, so the diff against `origin/main` was truncated at 120 KB; `descriptor/host.rs`, `draw.rs`, `host.rs`, `host/menu.rs`, and the first ~2750 lines of `hwrt.rs` were inspected directly.)* - **`crates/victory-gpu/src/descriptor/host.rs`**: - `HostHeap::make_listed_batched` skips `ListViews` caching for `D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE` when `crate::hwrt::requested()` is set, avoiding stale TLAS descriptors across rebuilds. - `make_twinned` decodes the 64-bit console VA from `d[4]`/`d[5]` (matching the 16-byte-aligned `D3D12_SHADER_RESOURCE_VIEW_DESC` union offset) and creates a `D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE` SRV with `None` resource via `crate::hwrt::tlas_for_descriptor`. - **`crates/victory-gpu/src/draw.rs`**: - `State::bind` resolves console TLAS VAs from `stage.tlas_srvs` root descriptor tables and binds the host VA via `crate::hwrt::tlas_gpu_va`, safely dropping the dispatch if no DXR TLAS manager is active. - Direct and indirect compute dispatches record RayQuery telemetry via `crate::hwrt::note_dispatch`. - **`crates/victory-gpu/src/host.rs` & `host/menu.rs`**: - `Deferred::held` / `HostList::hold` cleanly ties lease/readback lifetimes to command list reset, and `HostList::untouched` accounts for `deferred.held`. - `VICTORY_HW_RT` is exposed in `ITEMS` as `UNSET_ON` (off by default). #### Minor non-blocking notes 1. **`crates/victory-gpu/src/hwrt.rs` (`HwRtManager::execute_build`)**: On the TLAS path, `dst_inst_buf` is transitioned from `UNORDERED_ACCESS` to `NON_PIXEL_SHADER_RESOURCE` before `self.lease(list, info.ScratchDataSizeInBytes)` and `self.alloc_or_reuse_as(...)`. If either allocation returns `None` (OOM), the early `return` skips transitioning `dst_inst_buf` back to `UNORDERED_ACCESS` before it is returned to `self.leases` on list reset. 2. **`crates/victory-gpu/src/hwrt.rs` (`HwRtManager::alloc_or_reuse_as`)**: Still contains a leftover `// TODO(phase3): notify TLAS SRV descriptor bindings when RayQuery traversal lifting lands.` comment. 3. **Verify `view_address` for TLAS table entries**: In `draw.rs` (`State::bind`), `stage.tlas_srvs` extracts `console_tlas_va` via `crate::descriptor::view(handle).and_then(|v| crate::descriptor::host::view_address(&v))`. Confirm during GPU testing that console TLAS table descriptors yield non-zero `console_tlas_va` (and don't silently fall back to `0` / empty TLAS) on real RT dispatches. #### Suggested real-GPU smoke test Requires a DXR 1.1 + SM 6.5+ GPU. Run with `VICTORY_HW_RT=0` (default regression check) and `VICTORY_HW_RT=1` (with D3D12 debug layer if available), checking: - No D3D12 validation errors on root TLAS SRVs, descriptor-heap TLAS SRVs, or `BuildRaytracingAccelerationStructure` barriers. - `hwrt::report_line` / `hwrt: built native DXR TLAS` logs show non-zero BLAS/TLAS builds, matched remaps, and lifted RayQuery dispatches without device removal. - Shader cache cold + warm restart round-trips cleanly with `VICTORY_HW_RT=1`. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 17:04:33 +00:00 (Migrated from github.com)

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


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:7352864829 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/357#issuecomment-7352864829). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T17:04:33Z. --- 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-02 22:03:53 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T22:03:53Z.


Holding merge per Deep Static Audit Pass #4 (#282 comment 7359964895):

  • Great news: Pass #3 Findings #1 and #3–#11 are all cleanly resolved!
  • 1 remaining [P0] blocker from a4aab821: ungated HostList::shadow_to / shadows_common breaks the VICTORY_HW_RT=0/unset zero-impact guarantee and traps Shadow::buffer in COPY_DEST / UNORDERED_ACCESS / GENERIC_READ across untracked descriptor-table SRV/CBV/UAV, root SRV/CBV, and texture.rs accesses.
  • Minimal fix: revert shadow_to / shadows_common hooks in draw.rs, host/place.rs, indirect.rs, and host.rs:9196, and write the 8–16 byte emit_postbuild result into sh.buffer inside hwrt::active() via a 1-thread UAV compute shader (SetComputeRootUnorderedAccessView + plain UAV barrier) so Shadow::buffer stays in COMMON outside hwrt.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7360172910 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/357#issuecomment-7360172910). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T22:03:53Z. --- Holding merge per Deep Static Audit Pass #4 (`#282` comment `7359964895`): - **Great news:** Pass #3 Findings `#1` and `#3–#11` are **all cleanly resolved**! - **1 remaining `[P0]` blocker from `a4aab821`:** ungated `HostList::shadow_to` / `shadows_common` breaks the `VICTORY_HW_RT=0`/unset zero-impact guarantee and traps `Shadow::buffer` in `COPY_DEST` / `UNORDERED_ACCESS` / `GENERIC_READ` across untracked descriptor-table SRV/CBV/UAV, root SRV/CBV, and `texture.rs` accesses. - **Minimal fix:** revert `shadow_to` / `shadows_common` hooks in `draw.rs`, `host/place.rs`, `indirect.rs`, and `host.rs:9196`, and write the 8–16 byte `emit_postbuild` result into `sh.buffer` inside `hwrt::active()` via a 1-thread UAV compute shader (`SetComputeRootUnorderedAccessView` + plain UAV barrier) so `Shadow::buffer` stays in `COMMON` outside `hwrt`.
Androtim commented 2026-12-03 00:03:08 +00:00 (Migrated from github.com)

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


Deep Static Logic Audit Pass #5 (#282 comment 7362568946) gave GREEN LIGHT to #357 (5d0eedbd, superset incorporating #347, #349, and #354) behind VICTORY_HW_RT=1:

  • Pass #4 [P0] resolved (d065fff: shadow_to/shadows_common reverted, strictly zero non-RT impact when VICTORY_HW_RT=0/unset, 1-thread compute UAV emit_postbuild).
  • Pass #4 [P2] resolved (65e3d13/e680116: transitive PHI-to-PHI seeding in collect_rq_needed_vals + resolve_rq_phi_arm).
  • CI 46994746181 GREEN and merges cleanly onto main (5bfc066c).
    Merging the complete #339 DXR 1.1 RayQuery superset to main (off by default behind VICTORY_HW_RT=1); closing subsumed stack PRs #347, #349, and #354.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7362738621 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/357#issuecomment-7362738621). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T00:03:08Z. --- Deep Static Logic Audit Pass #5 (`#282` comment `7362568946`) gave **GREEN LIGHT** to `#357` (`5d0eedbd`, superset incorporating `#347`, `#349`, and `#354`) behind `VICTORY_HW_RT=1`: - Pass #4 `[P0]` resolved (`d065fff`: `shadow_to`/`shadows_common` reverted, strictly zero non-RT impact when `VICTORY_HW_RT=0`/unset, 1-thread compute UAV `emit_postbuild`). - Pass #4 `[P2]` resolved (`65e3d13`/`e680116`: transitive PHI-to-PHI seeding in `collect_rq_needed_vals` + `resolve_rq_phi_arm`). - CI `46994746181` **GREEN** and merges cleanly onto `main` (`5bfc066c`). Merging the complete `#339` DXR 1.1 `RayQuery` superset to `main` (off by default behind `VICTORY_HW_RT=1`); closing subsumed stack PRs `#347`, `#349`, and `#354`.
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!357
No description provided.