victory-shader: DXR 1.1 RayQuery traversal-loop lifter behind VICTORY_HW_RT=1 (#339) #354

Closed
Androtim wants to merge 6 commits from upstream-pr/354 into main
Androtim commented 2026-12-02 15:40:38 +00:00 (Migrated from github.com)

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


Phase 3 PR #7 for #339 (stacked on #352).

Summary

  • Add modular BVH traversal-loop recognizer & DXIL RayQuery lifter under crates/victory-shader/src/emit/lower/rayquery/ (rayquery.rs, analyze.rs, attrs.rs, emit_rq.rs), gated on VICTORY_HW_RT=1 (off by default; zero RT-off impact).
  • Support both Template A (image_bvh64_intersect_ray) and Template B (image_bvh_intersect_ray wave-shared TLAS + per-lane BLAS), non-opaque candidate callbacks, committed/candidate attribute load lifting, cross-query merge dispatch, and automatic software-BVH forced-miss fallback (bvh_miss, VICTORY_HW_RT_LIFT=0, or lowering fallback).
  • Add RayQueries metadata on HostShader and Lowered, plus hw_rt(), hw_rt_lift(), bvh_miss(), and program_key().
  • Update emit::host and test HostShader literals (including victory-gpu/src/shader_cache.rs field initialization).
  • Add synthetic fallback, WARP DXR 1.1 compute pipeline, and GFX10 BVH64 traversal-loop lifting + dxil.dll validation tests in emit/rayquery_tests.rs.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy --staged (20 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 shader_cache::tests (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:5609767000 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/354). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:40:38Z. --- Phase 3 PR #7 for #339 (stacked on #352). ### Summary - Add modular BVH traversal-loop recognizer & DXIL `RayQuery` lifter under `crates/victory-shader/src/emit/lower/rayquery/` (`rayquery.rs`, `analyze.rs`, `attrs.rs`, `emit_rq.rs`), gated on `VICTORY_HW_RT=1` (off by default; zero RT-off impact). - Support both Template A (`image_bvh64_intersect_ray`) and Template B (`image_bvh_intersect_ray` wave-shared TLAS + per-lane BLAS), non-opaque candidate callbacks, committed/candidate attribute load lifting, cross-query merge dispatch, and automatic software-BVH forced-miss fallback (`bvh_miss`, `VICTORY_HW_RT_LIFT=0`, or lowering fallback). - Add `RayQueries` metadata on `HostShader` and `Lowered`, plus `hw_rt()`, `hw_rt_lift()`, `bvh_miss()`, and `program_key()`. - Update `emit::host` and test `HostShader` literals (including `victory-gpu/src/shader_cache.rs` field initialization). - Add synthetic fallback, WARP DXR 1.1 compute pipeline, and GFX10 BVH64 traversal-loop lifting + `dxil.dll` validation tests in `emit/rayquery_tests.rs`. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy --staged` (`20 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 shader_cache::tests` (`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:03:58 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers (not an approval).

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

Review Summary

CI is passing and the visible changes look structurally sound and cleanly gated behind VICTORY_HW_RT=1 (off by default, returning an empty Plan in rayquery::analyze when disabled).

Verified Changes

  • crates/victory-shader/src/emit/lower.rs: Integrates rayquery::analyze, adds automatic fallback to unlifted lowering if lower_with_plan fails on an active plan (lowering_refused), excludes eliminated instructions (rq.is_eliminated) from insts()/LDS/s_barrier checks, declares lifted root TLAS SRVs via root_tlas_handle, lowers lifted headers via emit_ray_query, and wires rq_merge_phis and header back-edge skipping in PHI patching.
  • crates/victory-shader/src/emit/lower/rayquery.rs & analyze.rs: Cleanly separates Template A (image_bvh64_intersect_ray) and Template B (image_bvh_intersect_ray) structural analysis from fixed-point multi-query live-out/attribute verification.
  • crates/victory-shader/src/emit/intersect.rs: Forces bvh_miss() to true when crate::emit::hw_rt() is enabled so unlifted loops miss/occlude instead of reading unpopulated console BVH memory.
  • crates/victory-shader/src/emit/host.rs: Chains s.ray_queries.tlas_srvs into root SRV parameters in Host::root_signature_for.
  • crates/victory-gpu/src/shader_cache.rs: Initializes ray_queries: Default::default() in decode and tests::shader (full cache serialization is deferred to stacked PR #357).

Notes / Minor Observations

  • Diff truncation: The review payload was truncated at 120 KB of 363 KB total, so attrs.rs, emit_rq.rs, rayquery_tests.rs, emit.rs, and the lower half of analyze.rs were not directly inspected here; CI and dxil.dll validation tests pass on the full diff.
  • Stacking / cache: Since shader_cache::decode sets ray_queries: Default::default() in this PR, ensure PR #357 lands alongside it before relying on disk-cached shaders under VICTORY_HW_RT=1.
  • Minor cleanups (non-blocking):
    • crates/victory-shader/src/emit/intersect_tests.rs (build_compute_shader) sets ray_queries: Default::default() instead of forwarding lowered.ray_queries.
    • crates/victory-shader/src/emit/lower/rayquery/analyze.rs builds all_active_blocks in the fixed-point loop and discards it (let _ = &all_active_blocks;).
    • rayquery::lowering_refused and Plan::skipped call s.truncate(96) on a String; safe for ASCII messages, though floor_char_boundary would avoid any UTF-8 boundary risk.

Verdict

needs-gpu-test — touches DXIL shader lowering (emit/lower.rs, emit/intersect.rs, emit/lower/rayquery/*) and D3D12 root signatures (emit/host.rs), warranting a local real-GPU DXR 1.1 smoke test (and RT-off regression check) before merging. (Automated review; not formal maintainer approval.)


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7351381849 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/354#issuecomment-7351381849). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T16:03:58Z. --- <!-- minivi-triage v1 head=52dfd664fe0d95f0702576f8648d2f4dd5b1fcf3 verdict=needs-gpu-test ci=passing at=2026-12-02T16:04:29Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary CI is passing and the visible changes look structurally sound and cleanly gated behind `VICTORY_HW_RT=1` (off by default, returning an empty `Plan` in `rayquery::analyze` when disabled). ### Verified Changes - **`crates/victory-shader/src/emit/lower.rs`**: Integrates `rayquery::analyze`, adds automatic fallback to unlifted lowering if `lower_with_plan` fails on an active plan (`lowering_refused`), excludes eliminated instructions (`rq.is_eliminated`) from `insts()`/LDS/`s_barrier` checks, declares lifted root TLAS SRVs via `root_tlas_handle`, lowers lifted headers via `emit_ray_query`, and wires `rq_merge_phis` and header back-edge skipping in PHI patching. - **`crates/victory-shader/src/emit/lower/rayquery.rs` & `analyze.rs`**: Cleanly separates Template A (`image_bvh64_intersect_ray`) and Template B (`image_bvh_intersect_ray`) structural analysis from fixed-point multi-query live-out/attribute verification. - **`crates/victory-shader/src/emit/intersect.rs`**: Forces `bvh_miss()` to `true` when `crate::emit::hw_rt()` is enabled so unlifted loops miss/occlude instead of reading unpopulated console BVH memory. - **`crates/victory-shader/src/emit/host.rs`**: Chains `s.ray_queries.tlas_srvs` into root SRV parameters in `Host::root_signature_for`. - **`crates/victory-gpu/src/shader_cache.rs`**: Initializes `ray_queries: Default::default()` in `decode` and `tests::shader` (full cache serialization is deferred to stacked PR #357). ### Notes / Minor Observations - **Diff truncation**: The review payload was truncated at 120 KB of 363 KB total, so `attrs.rs`, `emit_rq.rs`, `rayquery_tests.rs`, `emit.rs`, and the lower half of `analyze.rs` were not directly inspected here; CI and `dxil.dll` validation tests pass on the full diff. - **Stacking / cache**: Since `shader_cache::decode` sets `ray_queries: Default::default()` in this PR, ensure PR #357 lands alongside it before relying on disk-cached shaders under `VICTORY_HW_RT=1`. - **Minor cleanups (non-blocking)**: - `crates/victory-shader/src/emit/intersect_tests.rs` (`build_compute_shader`) sets `ray_queries: Default::default()` instead of forwarding `lowered.ray_queries`. - `crates/victory-shader/src/emit/lower/rayquery/analyze.rs` builds `all_active_blocks` in the fixed-point loop and discards it (`let _ = &all_active_blocks;`). - `rayquery::lowering_refused` and `Plan::skipped` call `s.truncate(96)` on a `String`; safe for ASCII messages, though `floor_char_boundary` would avoid any UTF-8 boundary risk. ### Verdict `needs-gpu-test` — touches DXIL shader lowering (`emit/lower.rs`, `emit/intersect.rs`, `emit/lower/rayquery/*`) and D3D12 root signatures (`emit/host.rs`), warranting a local real-GPU DXR 1.1 smoke test (and RT-off regression check) before merging. *(Automated review; not formal maintainer approval.)* --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 17:04:28 +00:00 (Migrated from github.com)

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


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

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


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:7362756243 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/354#issuecomment-7362756243). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-03T00:04:02Z. --- 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!354
No description provided.