victory-shader: lower all-zero and all-one constant lane masks #1057
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1057"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-24T15:21:44Z.
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.
Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-24T16:26:37Z.
Review: COMMENTED
On
a793ad8, the only producer ofAtom::Constantin the current source masks its input to the wave width and returns a terminal boolean for zero or a full mask. The existing boolean lowering handles those terminals before looking up an atom, so the newLower::atombranches are unreachable through that producer.An independent classification model compared all 81 inline encodings and six boundary literals in wave32 and wave64 against bit-by-bit lane counts. All 174 cases agreed, and zero produced atoms matching the new branches. As a control,
0xFFFFFFFFclassified as true in wave32 and as a partial mask in wave64. This was source inspection and a synthetic model. The PR was not executed and emitted DXIL was not measured. A shader-level test comparingffe310ewitha793ad8would establish whether the emitted wave operations or shader requirements change.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:28:53Z.
Review: APPROVED
Tiny, sound: all-zero/all-one lane-mask constants now fold to DXIL bool constants instead of a lane_bit computation. The wave64 vs wave32 all-ones split is correct (u64::MAX vs low-32 all-ones only when !wave64), and partial masks still take the console_lanes path. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed.Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-24T16:09:03Z.
This PR has no CI run yet, so I ran the CI's checks at head
a793ad8(onmainffe310e): 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 policyok.The change reads right to me: 0 is no lane,
u64::MAXis every lane, andu32::MAXcounts as every lane only for a wave32 program (!native.wave64), so a wave64 mask of just the low 32 lanes still goes through theconsole_lanespath.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_lanesor wave ops would keep this from regressing.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:30:09Z.
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-shaderpasses, 120 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T18:50:33Z.
Review: APPROVED
Tested
a793ad8on Windows 11, RTX 5070, MSVC: builds,cargo test --workspace --no-fail-fast602 passed, 0 failed (on our fork main), with victory-shader single-threaded.console_lanesarm below them computes for the same constants. Every lane's bit of 0 is clear, and every lane's bit of an all-ones mask is set: all 64 bits in wave64, the low 32 in wave32, where no console lane is past 31. So it's correct with or without console lanes, and it stops refusing these masks when console lanes are off.victory translate shaders.rpf --list(the user's own package, counts only) is unchanged by this PR on our fork's main, so none of the package's programs depended on it. That's not a problem, just a data point.s_mov_b64 exec, -1, lowered withconsole_lanesoff, would cover the new path.Merged into our fork's main.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by avt0m4t48 on 2026-11-24T19:30:47Z.
I ran a synthetic before/after check for the regression requested above. Base translator
ffe310e, then the four-linelower.rsdiff froma793ad8, Rust 1.98.1 on Linux.I prepended
s_mov_b32 exec_lo(wave32) ors_mov_b64 exec(wave64) with each of0,-1, and5to 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 witha 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 producesAtom::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.Imported from Marvisak/VIctory. Originally posted by bartikele on 2026-11-24T20:34:51Z.
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