Skip to content

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

Open
legayclightning22 wants to merge 1 commit into
Marvisak:mainfrom
legayclightning22:fix/cndmask-b32
Open

legayclightning22 wants to merge 1 commit into
Marvisak:mainfrom
legayclightning22:fix/cndmask-b32

Conversation

@legayclightning22

@legayclightning22 legayclightning22 commented Nov 25, 2026 •

Copy link
Copy Markdown

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

@kotekompotek

Copy link
Copy Markdown

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.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@legayclightning22

Copy link
Copy Markdown
Author

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).

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):

  • cargo test -p victory-shader --lib emit::valu_tests::v_cndmask_b32_with_untracked_mask_selects_per_lane: 1 passed, 0 failed (RTX 5090 hardware + WARP).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants