fix(shader): allow untracked scalar lane masks in v_cndmask_b32 #2790
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2792"
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 legayclightning22 on 2026-11-25T20:42:31Z.
Summary
Fixes the WARP wave-size regression where unrelated
st.otherconstants pinned the wave size when a shader selects on an untracked scalar lane mask inv_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 eachv_cndmask_b32to the masks checked forOpaque/Constantatoms. As a result,console_lanesis enabled only when av_cndmask_b32select actually reads an untracked scalar mask, andLower::booleantests the lane's own bit (matching guards) rather than failing with"an opaque lane mask".Test Plan
emit::valu_tests::v_cndmask_b32_with_untracked_mask_selects_per_lane, which fails at lowering onmainand verifies per-lane mask selection against each lane's mask bit (with expliciteprintln!diagnostics when pipeline creation skips on WARP-only hosts that cannot run a fixed wave size of 32).cargo test -p victory-shader --libcargo clippy --locked -p victory-shader --all-targets -- -D warningscargo xtask policyImported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:44:50Z.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:23:36Z.
Reviewed and tested
4d84cad9on Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).1. WARP test regression reproduced
Running
victory-shaderunder WARP (VICTORY_WARP=1) introduces a new failure that passes onmain(13f91ca):emit::synthetic_tests::a_compare_mask_joined_with_data_on_the_skip_edge_is_0_therepanics atsynthetic_tests.rs:491:17: hardware: no pipeline for a wave of 32.lower.rs:568unconditionally scans allx.st.other.values()when settingconsole_lanes. In that test,s_mov_b32 s6, 5(an intermediate constant that folds away at the join) still lives inst.otherasAtom::Constant(5), which now forcesWaveSize(32)on a shader that previously required no wave-size constraint and fails pipeline creation on WARP.console_lanes = trueforst.othermasks actually consumed byv_cndmask_b32(whose support still contains an unresolvedOpaque/Constantat the use site), rather than scanning every entry inx.st.other.values().2. Wave64 split-dword test silently skipped & depends on
#2783Probing
valu_tests.rs:1808shows that 3 of the 4(hardware/warp) × (wave64=false/true)cases—including both WARP cases and RTX 5090 Wave64—hitelse { continue; }when the adapter rejectsWaveSize(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#2792alone without#2783(Atom::Opaque(lo, hi)),lower::pair_high(s12)returnsNone, so Wave64 lanes 32–63 would reads12instead ofs13.Verification summary
cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok.v_cndmask: 2/2 passed (Wave32 executes); WARP full suite: 267 passed, 1 failed (the newa_compare_mask_joined_with_data_on_the_skip_edge_is_0_thereregression).git merge-treevs13f91caand#2783.0x80070057/ D3D12id=676):BlendOp=MAXenabled onDXGI_FORMAT_R8_UINTRT slot 2 ([mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]) #2773Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:14:29Z.
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 eachv_cndmask_b32to the masks it checks forOpaque/Constantatoms, soconsole_lanesis set only when such a select needs it. Before, a select on a mask held as a number (st.other) reachedLower::booleanwithconsole_lanesoff 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: unrelatedst.otherconstants no longer pin the wave size. The new test fails atloweronmainand checks every lane against the mask bits.Two small points:
st.otheris chained in. Please update it to the scoped form.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
Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T00:59:35Z.
Thank you both for the thorough review and testing! Updated and force-pushed (
90339e5) onto latestmainto address everything raised:@kotecompotekStructured::othertranslate-skip ("lane mask as data") bucket and the wave32 vs. emulated wave64-on-wave32 hi/lo dword distinction.@fuzeofficialThank you for catching both the WARP regression and the wave64 test behavior on
13f91ca:console_lanesregression (a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there):x.st.other.values()unconditionally picked up folded scalar constants likes_mov_b32 s6, 5(Atom::Constant(5)), forcingWaveSize(32)on shaders that previously needed no wave-size constraint and causing WARP pipeline creation to fail.console_lanesso it is only enabled forst.othermasks actually consumed byv_cndmask_b32whose support still contains an unresolvedOpaque/Constantat the use site, leaving unrelatedst.otherconstants untouched.#2783interaction (valu_tests.rs):v_cndmask_b32_with_untracked_mask_selects_per_laneso 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
main(resolving thecrates/victory-shader/src/emit/valu_tests.rsconflict).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(0 warnings) andcargo test -p victory-shader(including WARP regression checks).Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:26:51Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP,dxil.dllvalidator 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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:18:45Z.
Review: APPROVED
LGTM — clean, minimal 14-line fix threading
v_cndmask_b32opaque/constant mask atoms intoconsole_lanes(crates/victory-shader/src/emit/lower.rs:584-602) just likeguardsandwhens.Verified locally with
cargo xtask policy,cargo clippy(--all-targetsand--all-features),emit::lower::tests::v_cndmask_accepts_uniform_and_constant_masks, andemit::valu_tests::v_cndmask_b32_with_untracked_mask_selects_per_laneon both RTX 5090 and WARP (lower.rsstays under 512 KiB at521,178 B).A few small non-blocking notes for follow-up:
crates/victory-shader/src/emit/valu_tests.rs:2373has a minorrustfmt --edition 2024 --checkwrap diff, andv_cndmask_b32_with_untracked_mask_selects_per_lanecould assertran > 0so a pipeline failure on both backends doesn't silently pass.Atom::Opaquestill relies on pre-existingpair_high(v)atv's definition (so splits_mov_b32writes tolo/hiare a separate pre-existing Wave64 edge case).Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:44:17Z.
I combined your exact
90339e5with #3747 at981f8b2in9c22937. Both are direct parents. The test control merges90339e5onto current main63bcca4, and the two test trees differ only by the constant-select change inbitcode.rs.On Windows WARP with Agility 1.620.2, all 29,736 output words matched the control. The dynamic lane comparison stayed at 40 DXIL instructions. The generated 12-select case went from 50 to 34. Your
v_cndmask_b32_with_untracked_mask_selects_per_lanetest and the previously reported compare-mask join regression both passed. All 36 VALU tests, all 33 lowerer tests, the select semantic tests, strict all-feature shader Clippy and the asset policy also passed.The combined commit is available for maintainer review. Please retain the Git authors on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding my change into another commit.AI-assisted with OpenAI Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.