victory-shader: fix Wave64 wave size, scc_some widening, and raw VCC branches #356

Merged
Androtim merged 2 commits from upstream-pr/356 into main 2026-12-02 22:03:07 +00:00
Androtim commented 2026-12-02 15:45:13 +00:00 (Migrated from github.com)

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


Fixes P0 RDNA4 / Wave64 shader lowering findings #6, #7, and #8 from #282 (related: #276).

Summary

  • Finding #6 (crates/victory-shader/src/emit/lower.rs):
    • Count non-waterfall v_readfirstlane_b32 (in groups with > 1 thread) in console_lanes, ensuring [WaveSize(64)] is emitted on Wave64 hosts while leaving waterfall descriptor reads untouched.
    • Include multi-wave Wave64 LDS compute shaders (x.native.wave64 && s.lds_dwords > 0) in lds_wave so Wave64 hosts emit [WaveSize(64)] and Wave32-only hosts enter split_lds.
  • Finding #7 (crates/victory-shader/src/emit/lower.rs):
    • Reject per-lane lowering (Err(MASK_ELSEWHERE) + need(made)) when scc_some reads an SCC value with bits outside EXEC built in a non-all_lane_blocks_native block on native waves, triggering branch/loop widening instead of reading bogus inactive bits.
  • Finding #8 (crates/victory-shader/src/structure.rs, emit/lower.rs, emit/mod.rs):
    • Evaluate s_cbranch_vccz / s_cbranch_vccnz against raw vcc instead of vcc & exec.
    • Track vcc_outside_exec across single-predecessor EXEC state in Lanes, reject un-widened native branches/exits whose VCC can hold bits outside EXEC or inactive lanes (Err(MASK_ELSEWHERE)), and teach widen() to widen conditional VCC branch blocks via wave_any.

Verification

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (passed)
  • cargo run -p xtask --locked -- policy (325 files ok)
  • Targeted cargo test -p victory-shader --lib -- --test-threads=1 suites including new regression tests (structure::tests, emit::lower::tests, emit::wave64_tests, emit::size_tests, emit::waterfall_tests, emit::lds_sub_tests, emit::threading::tests, ir::tests, resource::tests, spill::tests, bvh::tests, dxbc::tests, dxil::tests, emit::bitcode::tests, emit::own_bits::tests, emit::container::tests, emit::cost::tests, emit::atomic_tests)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5609845079 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/356). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T15:45:13Z. --- Fixes P0 RDNA4 / Wave64 shader lowering findings **#6**, **#7**, and **#8** from #282 (related: #276). ### Summary - **Finding #6 (`crates/victory-shader/src/emit/lower.rs`)**: - Count non-waterfall `v_readfirstlane_b32` (in groups with `> 1` thread) in `console_lanes`, ensuring `[WaveSize(64)]` is emitted on Wave64 hosts while leaving waterfall descriptor reads untouched. - Include multi-wave Wave64 LDS compute shaders (`x.native.wave64 && s.lds_dwords > 0`) in `lds_wave` so Wave64 hosts emit `[WaveSize(64)]` and Wave32-only hosts enter `split_lds`. - **Finding #7 (`crates/victory-shader/src/emit/lower.rs`)**: - Reject per-lane lowering (`Err(MASK_ELSEWHERE)` + `need(made)`) when `scc_some` reads an SCC value with bits outside `EXEC` built in a non-`all_lane_blocks_native` block on native waves, triggering branch/loop widening instead of reading bogus inactive bits. - **Finding #8 (`crates/victory-shader/src/structure.rs`, `emit/lower.rs`, `emit/mod.rs`)**: - Evaluate `s_cbranch_vccz` / `s_cbranch_vccnz` against raw `vcc` instead of `vcc & exec`. - Track `vcc_outside_exec` across single-predecessor `EXEC` state in `Lanes`, reject un-widened native branches/exits whose `VCC` can hold bits outside `EXEC` or inactive lanes (`Err(MASK_ELSEWHERE)`), and teach `widen()` to widen conditional VCC branch blocks via `wave_any`. ### Verification - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (passed) - `cargo run -p xtask --locked -- policy` (325 files ok) - Targeted `cargo test -p victory-shader --lib -- --test-threads=1` suites including new regression tests (`structure::tests`, `emit::lower::tests`, `emit::wave64_tests`, `emit::size_tests`, `emit::waterfall_tests`, `emit::lds_sub_tests`, `emit::threading::tests`, `ir::tests`, `resource::tests`, `spill::tests`, `bvh::tests`, `dxbc::tests`, `dxil::tests`, `emit::bitcode::tests`, `emit::own_bits::tests`, `emit::container::tests`, `emit::cost::tests`, `emit::atomic_tests`)
Androtim commented 2026-12-02 16:07:51 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers (not an approval).

Verdict: needs-rebase · CI (check): none

This PR no longer merges cleanly into main.

To change the verdict: Rebase onto current main and resolve conflicts; CI and triage will run again automatically.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7351484943 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7351484943). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T16:07:51Z. --- <!-- minivi-triage v1 head=b56e2809f524e8967ee795b91c2670ff2b2faf26 verdict=needs-rebase ci=none at=2026-12-02T18:02:48Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-rebase` · **CI (`check`):** `none` This PR no longer merges cleanly into `main`. **To change the verdict:** Rebase onto current `main` and resolve conflicts; CI and triage will run again automatically. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 17:04:16 +00:00 (Migrated from github.com)

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


Holding merge (triage: needs work) per Deep Static Audit Pass #2 (#282 comment 7352688269, P1 finding #22): lds_wave multi-wave x.native.wave64 expansion breaks 32 KiB TGSM shaders on NVIDIA — restrict multi-wave expansion to host_max_wave() >= 64 and re-run CI before merge.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7352858633 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7352858633). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T17:04:16Z. --- Holding merge (`triage: needs work`) per Deep Static Audit Pass #2 (`#282` comment `7352688269`, P1 finding #22): `lds_wave` multi-wave `x.native.wave64` expansion breaks 32 KiB TGSM shaders on NVIDIA — restrict multi-wave expansion to `host_max_wave() >= 64` and re-run CI before merge.
Androtim commented 2026-12-02 17:33:15 +00:00 (Migrated from github.com)

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


Finding #22 fix (host_max_wave() >= 64 guard on multi-wave lds_wave) looks clean! However, b56e2809 now conflicts with merged #358 (likely lower_tests.rs) and has no CI run yet (checks=[]). Please rebase onto main to resolve the conflict and trigger CI -> ready to merge once CI is green!

<!-- greyfinch-sync:Androtim/MiniVI:comment:7353416715 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7353416715). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T17:33:15Z. --- Finding #22 fix (`host_max_wave() >= 64` guard on multi-wave `lds_wave`) looks clean! However, `b56e2809` now conflicts with merged `#358` (likely `lower_tests.rs`) and has no CI run yet (`checks=[]`). Please rebase onto `main` to resolve the conflict and trigger CI -> ready to merge once CI is green!
Androtim commented 2026-12-02 22:03:03 +00:00 (Migrated from github.com)

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


Rebased cleanly onto main (c31bbebc), Deep Static Audit Pass #3 (#282 comment 7355749301) verified Finding #22 resolved (host_max_wave() >= 64 guard, zero NVIDIA Wave32 regressions), and CI 46979442126 is GREEN. Merging RDNA 4 Wave64 + scc_some + raw VCC branch fixes to main.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7360153154 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7360153154). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T22:03:03Z. --- Rebased cleanly onto `main` (`c31bbebc`), Deep Static Audit Pass #3 (`#282` comment `7355749301`) verified Finding `#22` resolved (`host_max_wave() >= 64` guard, zero NVIDIA Wave32 regressions), and CI `46979442126` is **GREEN**. Merging RDNA 4 Wave64 + `scc_some` + raw VCC branch fixes to `main`.
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!356
No description provided.