victory-shader: lower all-zero and all-one constant lane masks #1057

Closed
github-bot wants to merge 1 commit from gh-pr/1057/head into gh-pr/1057/base
Owner

@⁠bartikele on GitHub · 2026-11-24 15:21 UTC · original
bartikele:shader-constant-lane-mask → main · +4 −0 · 1 files · 1 commits · closed without merging

Lowers \Atom::Constant(0)\ to \ alse\ and all-ones constant lane masks (\u64::MAX, or \u32::MAX\ in wave32) to \ rue\ without requiring \console_lanes\ or \WAVE_OPS.

Verified with \cargo clippy -p victory-shader --all-targets --locked -- -D warnings, \cargo test -p victory-shader --locked, \cargo xtask policy, and \ ictory translate --validate.

**@⁠bartikele** on GitHub · 2026-11-24 15:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1057) `bartikele:shader-constant-lane-mask` → `main` · +4 −0 · 1 files · 1 commits · closed without merging Lowers \Atom::Constant(0)\ to \ alse\ and all-ones constant lane masks (\u64::MAX\, or \u32::MAX\ in wave32) to \ rue\ without requiring \console_lanes\ or \WAVE_OPS\. Verified with \cargo clippy -p victory-shader --all-targets --locked -- -D warnings\, \cargo test -p victory-shader --locked\, \cargo xtask policy\, and \ ictory translate --validate\.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:38 +00:00
github-bot closed this pull request 2026-11-26 04:18:38 +00:00
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 16:09 UTC · original

This PR has no CI run yet, so I ran the CI's checks at head a793ad8 (on main ffe310e): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). Workspace tests 342 passed, 0 failed (GPU tests on the AMD device and WARP); both clippy runs (default and --all-features) clean; cargo xtask policy ok.

The change reads right to me: 0 is no lane, u64::MAX is every lane, and u32::MAX counts as every lane only for a wave32 program (!native.wave64), so a wave64 mask of just the low 32 lanes still goes through the console_lanes path.

It adds no test, though. A small one that lowers a program comparing against an all-ones mask and checks that it no longer needs console_lanes or wave ops would keep this from regressing.

**@⁠shortselow-byte** on GitHub · 2026-11-24 16:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1057#issuecomment-7137199243) This PR has no CI run yet, so I ran the CI's checks at head `a793ad8` (on `main` `ffe310e`): Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT (RDNA2). Workspace tests 342 passed, 0 failed (GPU tests on the AMD device and WARP); both clippy runs (default and `--all-features`) clean; `cargo xtask policy` ok. The change reads right to me: 0 is no lane, `u64::MAX` is every lane, and `u32::MAX` counts as every lane only for a wave32 program (`!native.wave64`), so a wave64 mask of just the low 32 lanes still goes through the `console_lanes` path. It adds no test, though. A small one that lowers a program comparing against an all-ones mask and checks that it no longer needs `console_lanes` or wave ops would keep this from regressing.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 16:30 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at a793ad8: cargo test -p victory-shader passes, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 16:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1057#issuecomment-7137764594) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at a793ad8: `cargo test -p victory-shader` passes, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-24 19:30 UTC · original

I ran a synthetic before/after check for the regression requested above. Base translator ffe310e, then the four-line lower.rs diff from a793ad8, Rust 1.98.1 on Linux.

I prepended s_mov_b32 exec_lo (wave32) or s_mov_b64 exec (wave64) with each of 0, -1, and 5 to a synthetic pixel emitter fixture. Both branches emitted byte-identical DXIL for the four zero/all-ones combinations. Both still refused the two partial-mask combinations with a constant lane mask. No title data or GPU execution.

A separate structurer test confirmed why. On both wave widths, zero becomes Bool::FALSE, all-ones requires no guard, and only the partial-mask control produces Atom::Constant(5). The PR's new terminal-value cases therefore aren't exercised by these production translation paths. A shader that reaches the actual refusal would need a nontrivial constant mask or a different constructor.

**@⁠avt0m4t48** on GitHub · 2026-11-24 19:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1057#issuecomment-7142204466) I ran a synthetic before/after check for the regression requested above. Base translator `ffe310e`, then the four-line `lower.rs` diff from `a793ad8`, Rust 1.98.1 on Linux. I prepended `s_mov_b32 exec_lo` (wave32) or `s_mov_b64 exec` (wave64) with each of `0`, `-1`, and `5` to a synthetic pixel emitter fixture. Both branches emitted byte-identical DXIL for the four zero/all-ones combinations. Both still refused the two partial-mask combinations with `a constant lane mask`. No title data or GPU execution. A separate structurer test confirmed why. On both wave widths, zero becomes `Bool::FALSE`, all-ones requires no guard, and only the partial-mask control produces `Atom::Constant(5)`. The PR's new terminal-value cases therefore aren't exercised by these production translation paths. A shader that reaches the actual refusal would need a nontrivial constant mask or a different constructor.
Author
Owner

@⁠bartikele on GitHub · 2026-11-24 20:34 UTC · original

Closing as redundant: as @⁠DoubleD17 showed, \structure.rs\ already collapses all-zero and all-one masks to \Bool::FALSE\ / \Bool::TRUE, making these \Lower::atom\ arms unreachable (also confirmed on \shaders.rpf\ by @⁠mercuryVM). Thanks to @⁠DoubleD17, @⁠catminou4, @⁠mercuryVM, and @⁠shortselow-byte for the thorough verification and review!

**@⁠bartikele** on GitHub · 2026-11-24 20:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1057#issuecomment-7143765006) Closing as redundant: as @⁠DoubleD17 showed, \structure.rs\ already collapses all-zero and all-one masks to \Bool::FALSE\ / \Bool::TRUE\, making these \Lower::atom\ arms unreachable (also confirmed on \shaders.rpf\ by @⁠mercuryVM). Thanks to @⁠DoubleD17, @⁠catminou4, @⁠mercuryVM, and @⁠shortselow-byte for the thorough verification and review!

Pull request closed

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!1057
No description provided.