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

Manually merged
github merged 2 commits from github-bot/gh-356 into gh-pr/356/base 2026-12-02 22:05:42 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 15:45 UTC · original
Androtim:fix/rdna4-wave64-culling → main · +681 −12 · 4 files · 2 commits · merged 2026-12-02 22:03 UTC

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** on GitHub · 2026-12-02 15:45 UTC · [original](https://github.com/Androtim/MiniVI/pull/356) `Androtim:fix/rdna4-wave64-culling` → `main` · +681 −12 · 4 files · 2 commits · merged 2026-12-02 22:03 UTC 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`)
Fixes findings #6, #7, and #8 from #282 (see also #276):
- Treat non-waterfall v_readfirstlane_b32 in multi-thread groups and multi-wave Wave64 LDS compute shaders as needing native wave sizing (or split_lds on Wave32-only hosts).
- Widen when scc_some reads an out-of-EXEC mask built inside a divergent native-wave branch/loop rather than an all-lanes block.
- Evaluate s_cbranch_vccz / s_cbranch_vccnz against raw VCC instead of VCC & EXEC, widening when VCC holds bits outside EXEC.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 15:50:16 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 16:07 UTC · original · edited 2026-12-02 18:02 UTC

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** on GitHub · 2026-12-02 16:07 UTC · [original](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7351484943) · edited 2026-12-02 18:02 UTC <!-- 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`)._
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, 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** on GitHub · 2026-12-02 17:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7352858633) 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.
Addresses #282 Pass #2 finding #22 (see #276):
- Restrict the multi-wave x.native.wave64 expansion of lds_wave in emit/lower.rs to hosts supporting 64-lane waves (host_max_wave() >= 64), keeping one_wave && s.lds_dwords > 0 unchanged on Wave32-only hosts.
- Prevents Wave32-only hosts from forcing split_lds + halves/pairs onto 32 KiB TGSM multi-wave compute shaders or emitting illegal WaveSize(64).
- Update and add unit tests verifying Wave32-only vs Wave64 host behavior for multi-wave Wave64 LDS compute shaders with console_lanes == false.
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 17:33 UTC · original

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** on GitHub · 2026-12-02 17:33 UTC · [original](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7353416715) 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!
github-bot force-pushed github-bot/gh-356 from b56e2809f5 to c31bbebcc1 2026-12-02 22:00:10 +00:00 Compare
github-bot changed target branch from main to gh-pr/356/base 2026-12-02 22:05:40 +00:00
github manually merged commit c31bbebcc1 into gh-pr/356/base 2026-12-02 22:05:42 +00:00
Author
Owner

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

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.

**@⁠Androtim** on GitHub · 2026-12-02 22:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/356#issuecomment-7360153154) 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`.
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!356
No description provided.