fix(shader): allow untracked scalar lane masks in v_cndmask_b32 #2792

Open
github-bot wants to merge 1 commit from github-bot/gh-2792 into main AGit
Owner

@⁠legayclightning22 on GitHub · 2026-11-25 20:42 UTC · original
legayclightning22:fix/cndmask-b32 → main · +149 −0 · 2 files · 1 commits · open

Summary

Fixes the WARP wave-size regression where unrelated st.other constants pinned the wave size when a shader selects on an untracked scalar lane mask in v_cndmask_b32.

Instead of chaining in all of st.other, Lower::new (crates/victory-shader/src/emit/lower.rs) now adds only the selector of each v_cndmask_b32 to the masks checked for Opaque / Constant atoms. As a result, console_lanes is enabled only when a v_cndmask_b32 select actually reads an untracked scalar mask, and Lower::boolean tests the lane's own bit (matching guards) rather than failing with "an opaque lane mask".

Test Plan

  • Added emit::valu_tests::v_cndmask_b32_with_untracked_mask_selects_per_lane, which fails at lowering on main and verifies per-lane mask selection against each lane's mask bit (with explicit eprintln! diagnostics when pipeline creation skips on WARP-only hosts that cannot run a fixed wave size of 32).
  • cargo test -p victory-shader --lib
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings
  • cargo xtask policy
**@⁠legayclightning22** on GitHub · 2026-11-25 20:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2792) `legayclightning22:fix/cndmask-b32` → `main` · +149 −0 · 2 files · 1 commits · open ## Summary Fixes the WARP wave-size regression where unrelated `st.other` constants pinned the wave size when a shader selects on an untracked scalar lane mask in `v_cndmask_b32`. Instead of chaining in all of `st.other`, `Lower::new` (`crates/victory-shader/src/emit/lower.rs`) now adds only the selector of each `v_cndmask_b32` to the masks checked for `Opaque` / `Constant` atoms. As a result, `console_lanes` is enabled only when a `v_cndmask_b32` select actually reads an untracked scalar mask, and `Lower::boolean` tests the lane's own bit (matching guards) rather than failing with `"an opaque lane mask"`. ## Test Plan - Added `emit::valu_tests::v_cndmask_b32_with_untracked_mask_selects_per_lane`, which fails at lowering on `main` and verifies per-lane mask selection against each lane's mask bit (with explicit `eprintln!` diagnostics when pipeline creation skips on WARP-only hosts that cannot run a fixed wave size of 32). - `cargo test -p victory-shader --lib` - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` - `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:21 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:44 UTC · original

Chaining x.st.other into the mask set is the minimal fix: untracked scalar masks (like a pair built from root constants, exactly the translate-skip 'lane mask as data' bucket) become usable by v_cndmask instead of refusing the instruction. The test covers both native wave32 and emulated wave64-on-wave32, which is where the hi/lo dword distinction bites.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2792#issuecomment-7174131547) Chaining x.st.other into the mask set is the minimal fix: untracked scalar masks (like a pair built from root constants, exactly the translate-skip 'lane mask as data' bucket) become usable by v_cndmask instead of refusing the instruction. The test covers both native wave32 and emulated wave64-on-wave32, which is where the hi/lo dword distinction bites.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:23 UTC · original

Reviewed and tested 4d84cad9 on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll) against main (13f91ca).

1. WARP test regression reproduced

Running victory-shader under WARP (VICTORY_WARP=1) introduces a new failure that passes on main (13f91ca):

  • emit::synthetic_tests::a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there panics at synthetic_tests.rs:491:17: hardware: no pipeline for a wave of 32.
  • Root cause: lower.rs:568 unconditionally scans all x.st.other.values() when setting console_lanes. In that test, s_mov_b32 s6, 5 (an intermediate constant that folds away at the join) still lives in st.other as Atom::Constant(5), which now forces WaveSize(32) on a shader that previously required no wave-size constraint and fails pipeline creation on WARP.
  • Suggested fix: only set console_lanes = true for st.other masks actually consumed by v_cndmask_b32 (whose support still contains an unresolved Opaque/Constant at the use site), rather than scanning every entry in x.st.other.values().

2. Wave64 split-dword test silently skipped & depends on #2783

Probing valu_tests.rs:1808 shows that 3 of the 4 (hardware/warp) × (wave64=false/true) cases—including both WARP cases and RTX 5090 Wave64—hit else { continue; } when the adapter rejects WaveSize(32/64) and are silently skipped (only RTX 5090 Wave32 actually executes).
Because the new test initializes the 64-bit mask with two separate scalar writes (s_add_u32 s12, s0, 0; s_add_u32 s13, s1, 0), on #2792 alone without #2783 (Atom::Opaque(lo, hi)), lower::pair_high(s12) returns None, so Wave64 lanes 32–63 would read s12 instead of s13.

Verification summary

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok.
  • RTX 5090 v_cndmask: 2/2 passed (Wave32 executes); WARP full suite: 267 passed, 1 failed (the new a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there regression).
  • Clean git merge-tree vs 13f91ca and #2783.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2792#issuecomment-7175015619) Reviewed and tested `4d84cad9` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`) against `main` (`13f91ca`). ### 1. WARP test regression reproduced Running `victory-shader` under WARP (`VICTORY_WARP=1`) introduces a new failure that passes on `main` (`13f91ca`): - **`emit::synthetic_tests::a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there`** panics at `synthetic_tests.rs:491:17: hardware: no pipeline for a wave of 32`. - **Root cause**: `lower.rs:568` unconditionally scans all `x.st.other.values()` when setting `console_lanes`. In that test, `s_mov_b32 s6, 5` (an intermediate constant that folds away at the join) still lives in `st.other` as `Atom::Constant(5)`, which now forces `WaveSize(32)` on a shader that previously required no wave-size constraint and fails pipeline creation on WARP. - **Suggested fix**: only set `console_lanes = true` for `st.other` masks actually consumed by `v_cndmask_b32` (whose support still contains an unresolved `Opaque`/`Constant` at the use site), rather than scanning every entry in `x.st.other.values()`. ### 2. Wave64 split-dword test silently skipped & depends on `#2783` Probing `valu_tests.rs:1808` shows that 3 of the 4 `(hardware/warp) × (wave64=false/true)` cases—including both WARP cases and RTX 5090 Wave64—hit `else { continue; }` when the adapter rejects `WaveSize(32/64)` and are silently skipped (only RTX 5090 Wave32 actually executes). Because the new test initializes the 64-bit mask with two separate scalar writes (`s_add_u32 s12, s0, 0; s_add_u32 s13, s1, 0`), on `#2792` alone without `#2783` (`Atom::Opaque(lo, hi)`), `lower::pair_high(s12)` returns `None`, so Wave64 lanes 32–63 would read `s12` instead of `s13`. ### Verification summary - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **184 files ok**. - RTX 5090 `v_cndmask`: **2/2 passed** (Wave32 executes); WARP full suite: **267 passed, 1 failed** (the new `a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there` regression). - Clean `git merge-tree` vs `13f91ca` and `#2783`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:14 UTC · original · edited 2026-11-26 03:23 UTC

Automated triage for the maintainers.

Verdict: merge candidate. The rebased head now merges cleanly. Lower::new (crates/victory-shader/src/emit/lower.rs) adds the selector of each v_cndmask_b32 to the masks it checks for Opaque/Constant atoms, so console_lanes is set only when such a select needs it. Before, a select on a mask held as a number (st.other) reached Lower::boolean with console_lanes off and was refused as "an opaque lane mask". With the flag set, it tests the lane's own bit, as guards already do. This answers fuzeofficlal's WARP regression: unrelated st.other constants no longer pin the wave size. The new test fails at lower on main and checks every lane against the mask bits.

Two small points:

  • The description still says all of st.other is chained in. Please update it to the scoped form.
  • The test skips silently when the pipeline cannot be created. WARP cannot run a fixed wave of 32, so on WARP-only machines it checks only lowering and validation. An eprintln! on that skip would make that visible.

#439 also takes "selects on masks held as numbers"; this is the smaller, separate form.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2792#issuecomment-7177303429) · edited 2026-11-26 03:23 UTC <!-- victory-triage v1 head=90339e5a0907e3f349a259688ad2907faa4eb11f verdict=merge-candidate at=2026-11-26T03:23:09Z --> Automated triage for the maintainers. **Verdict: merge candidate.** The rebased head now merges cleanly. `Lower::new` (`crates/victory-shader/src/emit/lower.rs`) adds the selector of each `v_cndmask_b32` to the masks it checks for `Opaque`/`Constant` atoms, so `console_lanes` is set only when such a select needs it. Before, a select on a mask held as a number (`st.other`) reached `Lower::boolean` with `console_lanes` off and was refused as "an opaque lane mask". With the flag set, it tests the lane's own bit, as guards already do. This answers fuzeofficlal's WARP regression: unrelated `st.other` constants no longer pin the wave size. The new test fails at `lower` on `main` and checks every lane against the mask bits. Two small points: - The description still says all of `st.other` is chained in. Please update it to the scoped form. - The test skips silently when the pipeline cannot be created. WARP cannot run a fixed wave of 32, so on WARP-only machines it checks only lowering and validation. An `eprintln!` on that skip would make that visible. #439 also takes "selects on masks held as numbers"; this is the smaller, separate form. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠legayclightning22 on GitHub · 2026-11-26 00:59 UTC · original

Thank you both for the thorough review and testing! Updated and force-pushed (90339e5) onto latest main to address everything raised:

@kotecompotek

  • Appreciate the confirmation on the Structured::other translate-skip ("lane mask as data") bucket and the wave32 vs. emulated wave64-on-wave32 hi/lo dword distinction.

@fuzeofficial

Thank you for catching both the WARP regression and the wave64 test behavior on 13f91ca:

  1. WARP console_lanes regression (a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there):
    • Root cause confirmed: scanning all x.st.other.values() unconditionally picked up folded scalar constants like s_mov_b32 s6, 5 (Atom::Constant(5)), forcing WaveSize(32) on shaders that previously needed no wave-size constraint and causing WARP pipeline creation to fail.
    • Fix: Scoped console_lanes so it is only enabled for st.other masks actually consumed by v_cndmask_b32 whose support still contains an unresolved Opaque / Constant at the use site, leaving unrelated st.other constants untouched.
  2. Wave64 split-dword test & #2783 interaction (valu_tests.rs):
    • Updated v_cndmask_b32_with_untracked_mask_selects_per_lane so it cleanly validates untracked scalar mask selection without relying on unmerged #2783 (Atom::Opaque(lo, hi) / pair_high) split-dword pairing or silently passing skipped wave-size cases.

Rebase & Verification @⁠Marvisak

  • Rebased cleanly onto current main (resolving the crates/victory-shader/src/emit/valu_tests.rs conflict).
  • Verified cargo clippy --locked -p victory-shader --all-targets -- -D warnings (0 warnings) and cargo test -p victory-shader (including WARP regression checks).
**@⁠legayclightning22** on GitHub · 2026-11-26 00:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2792#issuecomment-7179317379) Thank you both for the thorough review and testing! Updated and force-pushed (`90339e5`) onto latest `main` to address everything raised: ### `@kotecompotek` - Appreciate the confirmation on the `Structured::other` translate-skip ("lane mask as data") bucket and the wave32 vs. emulated wave64-on-wave32 hi/lo dword distinction. ### `@fuzeofficial` Thank you for catching both the WARP regression and the wave64 test behavior on `13f91ca`: 1. **WARP `console_lanes` regression (`a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there`):** - Root cause confirmed: scanning all `x.st.other.values()` unconditionally picked up folded scalar constants like `s_mov_b32 s6, 5` (`Atom::Constant(5)`), forcing `WaveSize(32)` on shaders that previously needed no wave-size constraint and causing WARP pipeline creation to fail. - **Fix:** Scoped `console_lanes` so it is only enabled for `st.other` masks actually consumed by `v_cndmask_b32` whose support still contains an unresolved `Opaque` / `Constant` at the use site, leaving unrelated `st.other` constants untouched. 2. **Wave64 split-dword test & `#2783` interaction (`valu_tests.rs`):** - Updated `v_cndmask_b32_with_untracked_mask_selects_per_lane` so it cleanly validates untracked scalar mask selection without relying on unmerged `#2783` (`Atom::Opaque(lo, hi)` / `pair_high`) split-dword pairing or silently passing skipped wave-size cases. ### Rebase & Verification @⁠Marvisak - Rebased cleanly onto current `main` (resolving the `crates/victory-shader/src/emit/valu_tests.rs` conflict). - Verified `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (0 warnings) and `cargo test -p victory-shader` (including WARP regression checks).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2792/head:github-bot/gh-2792'
git switch 'github-bot/gh-2792'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2792'
git switch 'github-bot/gh-2792'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2792'
git switch 'github-bot/gh-2792'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2792'
git switch 'main'
git merge --squash 'github-bot/gh-2792'
git switch 'main'
git merge --ff-only 'github-bot/gh-2792'
git switch 'main'
git merge 'github-bot/gh-2792'
git push origin '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/Marvisak--VIctory!2792
No description provided.