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

Closed
github-bot wants to merge 6 commits from github-bot/gh-354 into main AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 15:40 UTC · original
Androtim:feat/hw-rt-phase3-traversal-lifter → main · +11660 −20 · 21 files · 6 commits · closed without merging

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** on GitHub · 2026-12-02 15:40 UTC · [original](https://github.com/Androtim/MiniVI/pull/354) `Androtim:feat/hw-rt-phase3-traversal-lifter` → `main` · +11660 −20 · 21 files · 6 commits · closed without merging 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`
Clean-room port of the GFX10 BVH traversal-loop recognizer and DXIL
RayQuery emitter hooks for both Template A (image_bvh64_intersect_ray)
and Template B (image_bvh_intersect_ray) behind VICTORY_HW_RT=1.

- Split into modular submodules under emit/lower/rayquery/{mod,analyze,attrs,emit_rq}
  so lower.rs stays well under policy size limits.
- Expose hw_rt(), hw_rt_lift(), bvh_miss(), program_key(), and RayQueries on
  HostShader (automatically falling back to software miss/occlusion when unlifted
  or when VICTORY_HW_RT_LIFT=0 or lowering refuses a lifted plan).
- Add synthetic RayQuery, fallback, WARP DXR 1.1 pipeline, and end-to-end
  GFX10 Template A BVH64 loop lifting + dxil.dll validation tests.

Refs #339
GPL-3.0-or-later references: TrustNo1-Coder/Darner, readmet3xt-lab/foxhound
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 15:44:49 +00:00
Author
Owner

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

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** on GitHub · 2026-12-02 16:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/354#issuecomment-7351381849) <!-- 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`)._
github-bot changed target branch from feat/hw-rt-phase3-dxil-rayquery to main 2026-12-02 16:17:08 +00:00
github-bot force-pushed github-bot/gh-354 from 52dfd664fe to 6a686c532b 2026-12-02 16:33:16 +00:00 Compare
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/354#issuecomment-7352862964) 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).
- Cache key tracks normalized VICTORY_HW_RT / VICTORY_HW_RT_LIFT flags and serializes HostShader::ray_queries cleanly (#10)
- Implement CallbackKind::Blocks multi-block CFG/PHI lowering, sound CommitDecision handling, and bailouts for unsound callbacks (#11, #12)
- Distinguish loop-invariant TMax from TMin, preserve 8-bit InstanceInclusionMask via unified shift/bfe matching, and preserve live-out ray inputs (#13, #14, #15)
- Handle q.latch == q && q.exit == b counter back-edges, select proper Template B multi-exit latches, fix trace_tlas_from_shr dynamic2/coalesced/nonuniform/dead_sites, guard AttrSource::Single, and enforce strict opacity polarity & dyn_ray_flags checks (#16-#20)
- Add 11 regression unit + DXIL validation tests covering findings #10-#20
github-bot closed this pull request 2026-12-03 00:07:01 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-03 00:04 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:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/354#issuecomment-7362756243) 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!354
No description provided.