victory-shader: lift remaining DXR 1.1 RayQuery Phase 3 fallback patterns #431

Merged
Androtim merged 4 commits from upstream-pr/431 into main 2026-12-04 12:12:34 +00:00
Androtim commented 2026-12-04 10:44:49 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T10:44:49Z.


Summary

Implements Wave 11B: DXR 1.1 Hardware RT RayQuery Phase 3 in crates/victory-shader/src/emit/lower/rayquery/analyze.rs, soundly lifting the remaining 4 fallback patterns that previously kept most active RT shaders on the slow inline software BVH path, plus fixing 3 pre-existing soundness / bvh32 lifting issues discovered during adversarial review.

Changes in crates/victory-shader/src/emit/lower/rayquery/analyze.rs

  1. Pattern 1 — Post-merge BVH software iteration-overflow watchdog clamp (is_iter_overflow_state_cndmask, feeds_latch_state_direct_or_iter_cap):
    • Permits unguarded post-merge v_cndmask_b32 v_state, 0, incoming_state, (v_iter < K) (both polarities) strictly when targeting traversal state (!tmax_phi && feeds_latch_state_check), K >= 1024, and v_iter is proven to be a pure unguarded +1 (v_add_nc_u32) loop counter initialized to a constant < K outside loop_blocks and never mutated inside cb_site_set.
    • Expands the opaque_sets_state_zero scan in search_blk[..ni] to inspect the full pre-callback slice (not just the last 4 instructions) and follow verified watchdog clamps.
  2. Patterns 2 & 3 — Callback-only user accumulators, same-guard dead staging PHIs, and inactive-lane old_dst walking:
    • Adds is_callback_only_user_accumulator + cb_val_routes_raw_bvh_ptr: allows non-tmax/non-hit_*/non-flags/non-state VGPR header PHIs proven untouched on every non-callback path (including non-callback tri_merge_block arms and inline inactive old_dst lanes) to accumulate cand_t (via v_min_f32, unguarded v_cndmask_b32, or inner-guarded v_cndmask_b32) verbatim in the emitted callback without routing raw cur_tri/cur_inst pointers.
    • Splits tri_merge_block PHI validation into two passes so direct candidate hit_*_phi bindings are populated before evaluating callback-only user accumulators.
    • Adds read_old_dst_inactive (bounded 16-hop walk past earlier same-block callback writes whose guard pg satisfies pg => cur_g and cb_exec_within_entry) so inline same-guard scratch writes before commit v_cndmask_b32 still verify opaque-lane preservation.
    • Tracks same-block guarded full-32-bit overwrite exclusions (def_blk, def_idx, excl_g) in val_has_explicit_read (u.0 == db && u.1 > di && ug => eg, cleared across blocks/PHIs) so dead staging header PHIs overwritten and read solely under the same guard g before unconditional overwrite do not falsely poison Pattern B.
  3. Pattern 4 — Pre-bound candidate attribute header PHIs & accumulator dominance soundness:
    • Excludes values pre-bound by emit_rq (cb_bound_vals) from read_in_cb in classify_live_outs and stops value_touches_cb_sites at pb == header (ignoring dead unguarded full overwrites), preventing cur_tri/cur_inst header PHIs from being misclassified as non-dominating accumulators.
    • Hardens find_callback_accumulator_next to require every non-callback arm of merge_block PHIs (and non-callback-touching cb_blocks arms) to preserve hp, reject non-callback modifications inside loop_blocks, require st.guards[site.0][site.1].is_some() for CallbackKind::Inline defs, and require a single consistent update value across arms.
  4. Additional bvh32 lifting & soundness fixes:
    • Adds is_dominating_search_guard + an O(1) SSA EXEC-chain fallback (exec_chain_proves_neg_cmp, immune to BDD MAX_MEET budget exhaustion on large multi-query shaders) to prove bvh32 cur_tri leaf-fetch copies under v_cmpx_ne_u32 EXEC, k, x unconditionally executed on all lanes reaching search_blk via a separate v_cmp_eq_u32 mask, k, x branch.
    • Recognizes dynamic-opacity s_and_saveexec_b32/64 non-opaque callback entry fed by !(1 == v_opaque) / (1 != v_opaque) where v_opaque is an unguarded v_and_or_b32(tri_dw12, 1, ...) dominating search_blk, and includes v_and_or_b32(tri_dw12, 1, ...) in tri_accept_block detection.
    • Hardens non-callback hit_and_cb_blocks (including all blocks in loop_blocks \ {latch} dominated by tri_accept_block/tri_block) and excludes hit_and_cb_blocks (except header) from iter_counter_phis so side-effecting updates inside unrecognized triangle-hit branches are never zeroed as BVH scratch or IterOverflowZero.

Soundness Unit Tests (crates/victory-shader/src/emit/rayquery_tests.rs)

Added 5 comprehensive positive + negative unit tests (22 subcases total, all validated with dxil.dll):

  • post_merge_iter_overflow_watchdog_lifts_and_rejects_unsound_clamps (2 positives + 6 negatives: wrong polarity, threshold < 1024, dynamic init, callback-mutated counter, guarded increment, non-zero fallback)
  • callback_only_user_accumulator_cand_t_flows_lift_and_reject_unsound (3 positives + 3 negatives: opaque-mutated accumulator, raw cur_tri routing through tri_merge_block PHI, tmax_phi v_min_f32 mutation)
  • dead_staging_header_phi_same_guard_overwrite_and_inline_inactive_old_dst (2 positives + 2 negatives: post-loop explicit read outside guard g, wider pre-callback scratch clobber of opaque lanes)
  • callback_prebound_cand_phi_and_non_dominating_accumulator_enforcement (positive pre-bound cur_tri PHI + negative opaque-modified merge_block PHI)
  • s_and_saveexec_inverted_opacity_callback_entry_lifts_and_rejects_unrelated (positive inverted opacity entry + negative unrelated compare)

Corpus Lifting & DXIL Validation Results (64 cached BVH shaders)

Metric Baseline (main) Phase 3 (perf/w11b-rayquery-phase3)
All-lifted shaders 13 32
Partly-lifted shaders 7 24
Unlifted shaders 39 8
bvh64 queries lifted 10 / 78 (12.8%) 64 / 78 (82.1%)
bvh32 queries lifted 18 106
Total queries lifted 28 170 (+6.1x)
dxil.dll validation failures — 0 / 56 lifted shaders (56 VALID, 0 INVALID)

Fallback counts across the 4 target patterns on the 64-shader corpus:

  • bvh64: unrecognized candidate flow through tri_merge_block PHI: 12 -> 0 (100% eliminated)
  • bvh64: callback accumulator PHI update does not dominate callback exit: 0 remaining (100% eliminated on pre-bound candidate PHIs while preserving dominance enforcement)
  • bvh64: callback commit cndmask has mismatched attribute kind or invalid old value: 4 -> 2 (remaining 2 already lift 6/8 and 1/8 queries and fail closed on genuine old-value mismatches)
  • bvh32: post-merge commit flow uses conditional or modified move: 13 -> 3 (all pure iteration-overflow watchdogs lifted 100%; remaining 3 are partial multi-query shaders already lifting 6/15–6/63 queries)

Verification

  • cargo test -p victory-shader -- rayquery: 63 / 63 passed
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo xtask policy: 365 files ok
  • File sizes (CRLF): analyze.rs 403,838 B, rayquery_tests.rs 308,824 B (well under 655,360 B)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5644972746 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/431). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T10:44:49Z. --- ## Summary Implements **Wave 11B: DXR 1.1 Hardware RT `RayQuery` Phase 3** in `crates/victory-shader/src/emit/lower/rayquery/analyze.rs`, soundly lifting the remaining 4 fallback patterns that previously kept most active RT shaders on the slow inline software BVH path, plus fixing 3 pre-existing soundness / `bvh32` lifting issues discovered during adversarial review. ### Changes in `crates/victory-shader/src/emit/lower/rayquery/analyze.rs` 1. **Pattern 1 — Post-merge BVH software iteration-overflow watchdog clamp** (`is_iter_overflow_state_cndmask`, `feeds_latch_state_direct_or_iter_cap`): - Permits unguarded post-merge `v_cndmask_b32 v_state, 0, incoming_state, (v_iter < K)` (both polarities) strictly when targeting traversal state (`!tmax_phi && feeds_latch_state_check`), `K >= 1024`, and `v_iter` is proven to be a pure unguarded `+1` (`v_add_nc_u32`) loop counter initialized to a constant `< K` outside `loop_blocks` and never mutated inside `cb_site_set`. - Expands the `opaque_sets_state_zero` scan in `search_blk[..ni]` to inspect the full pre-callback slice (not just the last 4 instructions) and follow verified watchdog clamps. 2. **Patterns 2 & 3 — Callback-only user accumulators, same-guard dead staging PHIs, and inactive-lane `old_dst` walking**: - Adds `is_callback_only_user_accumulator` + `cb_val_routes_raw_bvh_ptr`: allows non-`tmax`/non-`hit_*`/non-`flags`/non-`state` VGPR header PHIs proven untouched on every non-callback path (including non-callback `tri_merge_block` arms and inline inactive `old_dst` lanes) to accumulate `cand_t` (via `v_min_f32`, unguarded `v_cndmask_b32`, or inner-guarded `v_cndmask_b32`) verbatim in the emitted callback without routing raw `cur_tri`/`cur_inst` pointers. - Splits `tri_merge_block` PHI validation into two passes so direct candidate `hit_*_phi` bindings are populated before evaluating callback-only user accumulators. - Adds `read_old_dst_inactive` (bounded 16-hop walk past earlier same-block callback writes whose guard `pg` satisfies `pg => cur_g` and `cb_exec_within_entry`) so inline same-guard scratch writes before commit `v_cndmask_b32` still verify opaque-lane preservation. - Tracks same-block guarded full-32-bit overwrite exclusions `(def_blk, def_idx, excl_g)` in `val_has_explicit_read` (`u.0 == db && u.1 > di && ug => eg`, cleared across blocks/PHIs) so dead staging header PHIs overwritten and read solely under the same guard `g` before unconditional overwrite do not falsely poison Pattern B. 3. **Pattern 4 — Pre-bound candidate attribute header PHIs & accumulator dominance soundness**: - Excludes values pre-bound by `emit_rq` (`cb_bound_vals`) from `read_in_cb` in `classify_live_outs` and stops `value_touches_cb_sites` at `pb == header` (ignoring dead unguarded full overwrites), preventing `cur_tri`/`cur_inst` header PHIs from being misclassified as non-dominating accumulators. - Hardens `find_callback_accumulator_next` to require every non-callback arm of `merge_block` PHIs (and non-callback-touching `cb_blocks` arms) to preserve `hp`, reject non-callback modifications inside `loop_blocks`, require `st.guards[site.0][site.1].is_some()` for `CallbackKind::Inline` defs, and require a single consistent update value across arms. 4. **Additional `bvh32` lifting & soundness fixes**: - Adds `is_dominating_search_guard` + an O(1) SSA EXEC-chain fallback (`exec_chain_proves_neg_cmp`, immune to BDD `MAX_MEET` budget exhaustion on large multi-query shaders) to prove `bvh32` `cur_tri` leaf-fetch copies under `v_cmpx_ne_u32 EXEC, k, x` unconditionally executed on all lanes reaching `search_blk` via a separate `v_cmp_eq_u32 mask, k, x` branch. - Recognizes dynamic-opacity `s_and_saveexec_b32/64` non-opaque callback entry fed by `!(1 == v_opaque)` / `(1 != v_opaque)` where `v_opaque` is an unguarded `v_and_or_b32(tri_dw12, 1, ...)` dominating `search_blk`, and includes `v_and_or_b32(tri_dw12, 1, ...)` in `tri_accept_block` detection. - Hardens non-callback `hit_and_cb_blocks` (including all blocks in `loop_blocks \ {latch}` dominated by `tri_accept_block`/`tri_block`) and excludes `hit_and_cb_blocks` (except `header`) from `iter_counter_phis` so side-effecting updates inside unrecognized triangle-hit branches are never zeroed as BVH scratch or `IterOverflowZero`. ### Soundness Unit Tests (`crates/victory-shader/src/emit/rayquery_tests.rs`) Added 5 comprehensive positive + negative unit tests (22 subcases total, all validated with `dxil.dll`): - `post_merge_iter_overflow_watchdog_lifts_and_rejects_unsound_clamps` (2 positives + 6 negatives: wrong polarity, threshold `< 1024`, dynamic init, callback-mutated counter, guarded increment, non-zero fallback) - `callback_only_user_accumulator_cand_t_flows_lift_and_reject_unsound` (3 positives + 3 negatives: opaque-mutated accumulator, raw `cur_tri` routing through `tri_merge_block` PHI, `tmax_phi` `v_min_f32` mutation) - `dead_staging_header_phi_same_guard_overwrite_and_inline_inactive_old_dst` (2 positives + 2 negatives: post-loop explicit read outside guard `g`, wider pre-callback scratch clobber of opaque lanes) - `callback_prebound_cand_phi_and_non_dominating_accumulator_enforcement` (positive pre-bound `cur_tri` PHI + negative opaque-modified `merge_block` PHI) - `s_and_saveexec_inverted_opacity_callback_entry_lifts_and_rejects_unrelated` (positive inverted opacity entry + negative unrelated compare) ### Corpus Lifting & DXIL Validation Results (64 cached BVH shaders) | Metric | Baseline (`main`) | Phase 3 (`perf/w11b-rayquery-phase3`) | |---|---:|---:| | All-lifted shaders | 13 | **32** | | Partly-lifted shaders | 7 | **24** | | Unlifted shaders | 39 | **8** | | `bvh64` queries lifted | 10 / 78 (12.8%) | **64 / 78 (82.1%)** | | `bvh32` queries lifted | 18 | **106** | | Total queries lifted | 28 | **170 (+6.1x)** | | `dxil.dll` validation failures | — | **0 / 56 lifted shaders (`56 VALID`, `0 INVALID`)** | Fallback counts across the 4 target patterns on the 64-shader corpus: - `bvh64: unrecognized candidate flow through tri_merge_block PHI`: **12 -> 0** (100% eliminated) - `bvh64: callback accumulator PHI update does not dominate callback exit`: **0 remaining** (100% eliminated on pre-bound candidate PHIs while preserving dominance enforcement) - `bvh64: callback commit cndmask has mismatched attribute kind or invalid old value`: **4 -> 2** (remaining 2 already lift 6/8 and 1/8 queries and fail closed on genuine old-value mismatches) - `bvh32: post-merge commit flow uses conditional or modified move`: **13 -> 3** (all pure iteration-overflow watchdogs lifted 100%; remaining 3 are partial multi-query shaders already lifting 6/15–6/63 queries) ### Verification - `cargo test -p victory-shader -- rayquery`: **63 / 63 passed** - `cargo clippy --workspace --all-targets -- -D warnings`: **0 warnings** - `cargo xtask policy`: **365 files ok** - File sizes (CRLF): `analyze.rs` `403,838 B`, `rayquery_tests.rs` `308,824 B` (well under `655,360 B`)
Androtim commented 2026-12-04 11:01:42 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T11:01:42Z.


Triage (2fb54dcb, CI check PASS, MERGEABLE):

  • Wave 11B DXR 1.1 RayQuery Phase 3 (+1,743/-132 across rayquery/analyze.rs + rayquery_tests.rs, zero new toggles), however Gate 2 Adversarial Soundness Audit (#282 comment 7409489168) flagged CHANGES REQUESTED — 5 [P0], 2 [P1].
  • Marked triage: needs work pending fixes + Gate 2 clean re-audit + Gate 3 VICTORY_HW_RT=1 verification.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7409526951 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/431#issuecomment-7409526951). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T11:01:42Z. --- Triage (`2fb54dcb`, **CI `check` PASS**, `MERGEABLE`): - Wave 11B DXR 1.1 RayQuery Phase 3 (`+1,743/-132` across `rayquery/analyze.rs` + `rayquery_tests.rs`, zero new toggles), **however Gate 2 Adversarial Soundness Audit (`#282` comment `7409489168`) flagged `CHANGES REQUESTED — 5 [P0], 2 [P1]`**. - Marked `triage: needs work` pending fixes + Gate 2 clean re-audit + Gate 3 `VICTORY_HW_RT=1` verification.
Androtim commented 2026-12-04 11:54:46 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T11:54:46Z.


Gate 2 Soundness Audit Fixes (81b07f8, synced with origin/main)

All 5 [P0] and 2 [P1] Gate 2 findings from issue #282 comment 7409489168 are fixed and covered by positive + negative unit tests (all validated with dxil.dll):

1-to-1 Fix Checklist

  1. [P0] Inverted dynamic-opacity s_and_saveexec_b32/64 pre-callback lane bit (collect_bool_atoms / eval_pre_callback_lane_bit)
    • Added exact ROBDD atom_forced_by check against callback entry EXEC (ce) and st.reach[search_blk] in collect_bool_atoms, binding v_cmp_eq_u32(1, v_opaque) to PreboundLane::Const(false) instead of true.
    • Explicitly handled v_cmp_eq_u32/v_cmp_ne_u32 against v_opaque and cur_tri/cur_inst in eval_pre_callback_lane_bit, and made eval_pre_callback_lane_bit fail closed (Err) on unknown/unprovable pre-callback Atom::Lanes.
    • Strengthened s_and_saveexec_inverted_opacity_callback_entry_lifts_and_rejects_unrelated to assert PreboundLane::Const(false) on the opacity compare atom, evaluate the lowered commit mask under prebound_lanes (proving it is not constant-folded to false), and reject unprovable pre-callback lane bits.
  2. [P0] Opaque-lane mutations & post-merge discards of user accumulators (find_callback_accumulator_next & is_callback_only_user_accumulator)
    • Stored entry_exec: Bool (ce) on Callback, added shared collect_opaque_preserved_vals + compute_post_merge_reachable, and enforced cb_exec_within_entry_mask + read_old_dst_inactive_val across CallbackKind::Inline and Case 1b CallbackKind::Blocks (including tri_merge_block PHIs reached by !ce lanes and failing closed on unguarded writes reachable by !ce lanes).
    • Rejected any loop_blocks \ cb_blocks PHI in find_callback_accumulator_next where a post_merge_reachable predecessor drops the update back to hp.
    • Added callback_accumulator_inline_case1b_opaque_mutation_and_post_merge_discard (7 positive + negative subcases covering Inline, Case 1b find_callback_accumulator_next, Case 1b is_callback_only_user_accumulator, and post-merge discard).
  3. [P0] Synthetic sentinel leakage in cb_val_routes_raw_bvh_ptr / cb_acc_routes_synthetic_sentinel
    • Replaced the v_mov_b32/v_cndmask_b32-only walk with unified path-sensitive cb_val_routes_synthetic walking all Fields::Valu, Fields::Sop, and Fields::Ds explicit data reads (and guarded old_dst), stopping only at Fields::Flat loads, lane masks, and hardware-backed candidate/committed attributes, rejecting cur_tri, cur_inst, inv_d, cand_flags, committed_tri_old, and committed_inst_old (while pruning provably infeasible consecutive forward if/else cross-edges via st.bools.meet_seen).
    • Added negative tests for v_add_nc_u32(cur_tri, 4) (Blocks + Inline) and v_add_f32(acc, inv_d) through tri_merge_block PHIs.
  4. [P0] Cross-lane reads in val_has_explicit_read & v_writelane_b32 in read_old_dst_inactive_val
    • Added is_lane_local_read_inst (rejecting DPP, v_readlane_b32/v_readfirstlane_b32/v_writelane_b32/v_permlane*/v_movrel*/v_swaprel*, all Fields::Ds, and implicit-derivative Fields::Image ops) before treating a guarded same-block read as dead on !eg lanes, plus consecutive forward-edge infeasibility pruning for dead if/else cross-edges.
    • Stopped read_old_dst_inactive_val and collect_opaque_preserved_vals on v_writelane_b32.
    • Added negative tests for same-guard post-loop v_readfirstlane_b32 and inline v_writelane_b32 clobber.
  5. [P0] Non-invariant header PHIs read inside callback (classify_live_outs)
    • Required is_invariant_header_phi (or !val_has_explicit_read) whenever a non-live-out header PHI has read_in_cb == true and is not a valid callback-only accumulator across all back-edges — failing closed with Err(...) instead of silently freezing at pre-loop init.
    • Added non_invariant_header_phi_read_in_callback_fails_closed (positive invariant PHI + negative 2-PHI shift-register + negative outside-callback mutated counter).
  6. [P1] Iteration-overflow watchdog remaining-iteration margin & real cb_site_set in opaque_sets_state_zero
    • Changed c0 >= threshold to c0 > threshold.saturating_sub(1024) in is_iter_overflow_state_cndmask.
    • Moved the opaque_sets_state_zero search_blk[..ni] scan to run after extract_callback_region with the real &cb_site_set.
    • Added negative tests for c0 = 65534, K = 65535 and opaque-only v_state = 0 with a callback-mutated watchdog counter.
  7. [P1] Wave64 mask matching in is_non_opaque_mask/nonop_idx & s_mov_b32-only collapse_scalar_mov_phi
    • Matched s_and_saveexec_b64/s_xor_b64/s_mov_b64 vs _b32 strictly by p.wave64, required inline -1 (Operand::Const(193)) for 64-bit s_xor_b64, and verified matching (lo, hi) mask write/read pairs across Wave64 producers.
    • Restricted collapse_scalar_mov_phi to s_mov_b32.
    • Added wave64_inverted_opacity_callback_entry_mask_matching (positive Wave64 inverted opacity + negative high-dword clobber + negative 32-bit literal 0xFFFFFFFF in s_xor_b64).

Updated 64 Cached BVH Shader Corpus & DXIL Validation Results

Metric Baseline (main) Pre-Audit PR #431 Post-Audit PR #431 (81b07f8)
All-lifted shaders 13 32 32
Partly-lifted shaders 7 24 21
Unlifted shaders 39 8 11
bvh64 queries lifted 10 / 78 (12.8%) 64 / 78 (82.1%) 64 / 78 (82.1%)
bvh32 queries lifted 18 106 101 (5 unsound queries now fail closed)
Total queries lifted 28 170 165
dxil.dll validation — 56 VALID / 0 INVALID 53 VALID / 0 INVALID

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader -- rayquery: 66 / 66 passed
  • 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 xtask policy: 368 files ok
  • File sizes (CRLF): analyze.rs 421,799 B, rayquery_tests.rs 329,874 B, emit_rq.rs 58,190 B, rayquery.rs 29,866 B (all well under 655,360 B)
<!-- greyfinch-sync:Androtim/MiniVI:comment:7410722207 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/431#issuecomment-7410722207). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T11:54:46Z. --- ## Gate 2 Soundness Audit Fixes (`81b07f8`, synced with `origin/main`) All **5 `[P0]`** and **2 `[P1]`** Gate 2 findings from issue #282 comment `7409489168` are fixed and covered by positive + negative unit tests (all validated with `dxil.dll`): ### 1-to-1 Fix Checklist 1. **`[P0]` Inverted dynamic-opacity `s_and_saveexec_b32/64` pre-callback lane bit (`collect_bool_atoms` / `eval_pre_callback_lane_bit`)** - Added exact ROBDD `atom_forced_by` check against callback entry `EXEC` (`ce`) and `st.reach[search_blk]` in `collect_bool_atoms`, binding `v_cmp_eq_u32(1, v_opaque)` to `PreboundLane::Const(false)` instead of `true`. - Explicitly handled `v_cmp_eq_u32`/`v_cmp_ne_u32` against `v_opaque` and `cur_tri`/`cur_inst` in `eval_pre_callback_lane_bit`, and made `eval_pre_callback_lane_bit` fail closed (`Err`) on unknown/unprovable pre-callback `Atom::Lane`s. - Strengthened `s_and_saveexec_inverted_opacity_callback_entry_lifts_and_rejects_unrelated` to assert `PreboundLane::Const(false)` on the opacity compare atom, evaluate the lowered commit mask under `prebound_lanes` (proving it is not constant-folded to `false`), and reject unprovable pre-callback lane bits. 2. **`[P0]` Opaque-lane mutations & post-merge discards of user accumulators (`find_callback_accumulator_next` & `is_callback_only_user_accumulator`)** - Stored `entry_exec: Bool` (`ce`) on `Callback`, added shared `collect_opaque_preserved_vals` + `compute_post_merge_reachable`, and enforced `cb_exec_within_entry_mask` + `read_old_dst_inactive_val` across `CallbackKind::Inline` and Case 1b `CallbackKind::Blocks` (including `tri_merge_block` PHIs reached by `!ce` lanes and failing closed on unguarded writes reachable by `!ce` lanes). - Rejected any `loop_blocks \ cb_blocks` PHI in `find_callback_accumulator_next` where a `post_merge_reachable` predecessor drops the update back to `hp`. - Added `callback_accumulator_inline_case1b_opaque_mutation_and_post_merge_discard` (7 positive + negative subcases covering Inline, Case 1b `find_callback_accumulator_next`, Case 1b `is_callback_only_user_accumulator`, and post-merge discard). 3. **`[P0]` Synthetic sentinel leakage in `cb_val_routes_raw_bvh_ptr` / `cb_acc_routes_synthetic_sentinel`** - Replaced the `v_mov_b32`/`v_cndmask_b32`-only walk with unified path-sensitive `cb_val_routes_synthetic` walking all `Fields::Valu`, `Fields::Sop`, and `Fields::Ds` explicit data reads (and guarded `old_dst`), stopping only at `Fields::Flat` loads, lane masks, and hardware-backed candidate/committed attributes, rejecting `cur_tri`, `cur_inst`, `inv_d`, `cand_flags`, `committed_tri_old`, and `committed_inst_old` (while pruning provably infeasible consecutive forward `if/else` cross-edges via `st.bools.meet_seen`). - Added negative tests for `v_add_nc_u32(cur_tri, 4)` (Blocks + Inline) and `v_add_f32(acc, inv_d)` through `tri_merge_block` PHIs. 4. **`[P0]` Cross-lane reads in `val_has_explicit_read` & `v_writelane_b32` in `read_old_dst_inactive_val`** - Added `is_lane_local_read_inst` (rejecting DPP, `v_readlane_b32`/`v_readfirstlane_b32`/`v_writelane_b32`/`v_permlane*`/`v_movrel*`/`v_swaprel*`, all `Fields::Ds`, and implicit-derivative `Fields::Image` ops) before treating a guarded same-block read as dead on `!eg` lanes, plus consecutive forward-edge infeasibility pruning for dead `if/else` cross-edges. - Stopped `read_old_dst_inactive_val` and `collect_opaque_preserved_vals` on `v_writelane_b32`. - Added negative tests for same-guard post-loop `v_readfirstlane_b32` and inline `v_writelane_b32` clobber. 5. **`[P0]` Non-invariant header PHIs read inside callback (`classify_live_outs`)** - Required `is_invariant_header_phi` (or `!val_has_explicit_read`) whenever a non-live-out header PHI has `read_in_cb == true` and is not a valid callback-only accumulator across all back-edges — failing closed with `Err(...)` instead of silently freezing at pre-loop init. - Added `non_invariant_header_phi_read_in_callback_fails_closed` (positive invariant PHI + negative 2-PHI shift-register + negative outside-callback mutated counter). 6. **`[P1]` Iteration-overflow watchdog remaining-iteration margin & real `cb_site_set` in `opaque_sets_state_zero`** - Changed `c0 >= threshold` to `c0 > threshold.saturating_sub(1024)` in `is_iter_overflow_state_cndmask`. - Moved the `opaque_sets_state_zero` `search_blk[..ni]` scan to run after `extract_callback_region` with the real `&cb_site_set`. - Added negative tests for `c0 = 65534, K = 65535` and opaque-only `v_state = 0` with a callback-mutated watchdog counter. 7. **`[P1]` Wave64 mask matching in `is_non_opaque_mask`/`nonop_idx` & `s_mov_b32`-only `collapse_scalar_mov_phi`** - Matched `s_and_saveexec_b64`/`s_xor_b64`/`s_mov_b64` vs `_b32` strictly by `p.wave64`, required inline `-1` (`Operand::Const(193)`) for 64-bit `s_xor_b64`, and verified matching `(lo, hi)` mask write/read pairs across Wave64 producers. - Restricted `collapse_scalar_mov_phi` to `s_mov_b32`. - Added `wave64_inverted_opacity_callback_entry_mask_matching` (positive Wave64 inverted opacity + negative high-dword clobber + negative 32-bit literal `0xFFFFFFFF` in `s_xor_b64`). ### Updated 64 Cached BVH Shader Corpus & DXIL Validation Results | Metric | Baseline (`main`) | Pre-Audit PR #431 | Post-Audit PR #431 (`81b07f8`) | |---|---:|---:|---:| | All-lifted shaders | 13 | 32 | **32** | | Partly-lifted shaders | 7 | 24 | **21** | | Unlifted shaders | 39 | 8 | **11** | | `bvh64` queries lifted | 10 / 78 (12.8%) | 64 / 78 (82.1%) | **64 / 78 (82.1%)** | | `bvh32` queries lifted | 18 | 106 | **101** *(5 unsound queries now fail closed)* | | Total queries lifted | 28 | 170 | **165** | | `dxil.dll` validation | — | 56 VALID / 0 INVALID | **53 VALID / 0 INVALID** | ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader -- rayquery`: **66 / 66 passed** - `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 xtask policy`: **368 files ok** - File sizes (CRLF): `analyze.rs` `421,799 B`, `rayquery_tests.rs` `329,874 B`, `emit_rq.rs` `58,190 B`, `rayquery.rs` `29,866 B` (all well under `655,360 B`)
Androtim commented 2026-12-04 12:01:30 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-04T12:01:30Z.


Updated triage (c6523513, rebased onto 8503d1de, CI IN_PROGRESS, MERGEABLE):

  • Gate 2 Pure-Reasoning Re-Audit (#282 comment 7410830192): VERIFIED CLEAN (0 P0, 0 P1) — all 7 prior findings (5 P0 + 2 P1) resolved.
  • Swapped label triage: needs work -> triage: needs gpu test — awaiting CI check PASS + Gate 3 VICTORY_HW_RT=1 GPU verification.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7410870532 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/431#issuecomment-7410870532). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-04T12:01:30Z. --- Updated triage (`c6523513`, rebased onto `8503d1de`, CI `IN_PROGRESS`, `MERGEABLE`): - **Gate 2 Pure-Reasoning Re-Audit (`#282` comment `7410830192`):** `VERIFIED CLEAN (0 P0, 0 P1)` — all 7 prior findings (5 P0 + 2 P1) resolved. - Swapped label `triage: needs work` -> `triage: needs gpu test` — awaiting CI `check` PASS + Gate 3 `VICTORY_HW_RT=1` GPU verification.
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!431
No description provided.