Shaders: keep scalar comparisons between lane masks uniform #1411

Open
EatCodeSleep2 wants to merge 1 commit from upstream-pr/1412 into main
EatCodeSleep2 commented 2026-11-24 17:50:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by EatCodeSleep2 on 2026-11-24T17:50:15Z.


Addresses VIC-BT-006 in #1242. When s_cmp_eq/lg compares two tracked lane-width masks, preserve its scalar SCC for branching. The existing DXIL lowering compares the ballots as scalar values. This prevents lanes that agree locally from taking a different branch from lanes that differ.

The structuring test covers eq and lg at wave32 and wave64 and fails on main because it finds a lane condition where SCC should be uniform. The two-thread wave32 readback passes on the Windows hardware adapter. WARP skipped because it does not support the requested wave size. The shader suite passed 121 tests with the pre-existing v_med3_f32 host NaN failure excluded. Shader Clippy with warnings as errors passes.

AI use: Codex wrote and tested the change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587993276 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412). Originally posted by [EatCodeSleep2](https://github.com/EatCodeSleep2) on 2026-11-24T17:50:15Z. --- Addresses VIC-BT-006 in #1242. When s_cmp_eq/lg compares two tracked lane-width masks, preserve its scalar SCC for branching. The existing DXIL lowering compares the ballots as scalar values. This prevents lanes that agree locally from taking a different branch from lanes that differ. The structuring test covers eq and lg at wave32 and wave64 and fails on main because it finds a lane condition where SCC should be uniform. The two-thread wave32 readback passes on the Windows hardware adapter. WARP skipped because it does not support the requested wave size. The shader suite passed 121 tests with the pre-existing v_med3_f32 host NaN failure excluded. Shader Clippy with warnings as errors passes. AI use: Codex wrote and tested the change.
DenRakEiw commented 2026-11-24 18:05:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T17:57:02Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-shader emit::lower: 11 passed, 0 failed
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean fix keeping scalar comparisons between lane masks uniform. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6044594995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#pullrequestreview-6044594995). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T17:57:02Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-shader emit::lower`: **11 passed, 0 failed** - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean fix keeping scalar comparisons between lane masks uniform. Approving. AI-assisted (Gemini 4 Neon).
geiyiliyabumo commented 2026-11-24 18:06:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:59:49Z.


Independent verification of \86b29fa\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): 14 passed, 0 failed (including \scalar_lane_mask_comparison_is_wave_wide)
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

Code audit: guarding the per-lane rewrite with !(a_mask && c_mask)\ cleanly keeps two-mask comparisons (\s_cmp_eq/lg_u32/u64) uniform for both wave32 and wave64.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140006400 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7140006400). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T17:59:49Z. --- Independent verification of \86b29fa\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-shader --lib valu_tests\ (real RX 9060 XT GPU execution): **14 passed, 0 failed** (including \scalar_lane_mask_comparison_is_wave_wide\) - \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok Code audit: guarding the per-lane rewrite with \!(a_mask && c_mask)\ cleanly keeps two-mask comparisons (\s_cmp_eq/lg_u32/u64\) uniform for both wave32 and wave64. *AI-assisted; synthetic tests only, no game files.*
marquezinii commented 2026-11-24 19:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:33:45Z.


NVIDIA data point next to the RDNA4 run above: RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1, head 86b29fa. cargo test -p victory-shader --lib -- --test-threads=1 --nocapture gives 122 passed, 0 failed, 1 ignored. scalar_lane_mask_comparison_is_wave_wide ran on the hardware adapter, where wave32 is NVIDIA's only wave size, and passes for both s_cmp_eq and s_cmp_lg. WARP skips it (no wave32 on warp), as your description says.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140818002 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7140818002). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T18:33:45Z. --- NVIDIA data point next to the RDNA4 run above: RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1, head `86b29fa`. `cargo test -p victory-shader --lib -- --test-threads=1 --nocapture` gives 122 passed, 0 failed, 1 ignored. `scalar_lane_mask_comparison_is_wave_wide` ran on the hardware adapter, where wave32 is NVIDIA's only wave size, and passes for both `s_cmp_eq` and `s_cmp_lg`. WARP skips it (`no wave32 on warp`), as your description says.
catminou4 commented 2026-11-24 20:02:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:24:58Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97. GPU/valu execution tests are Windows-gated and were not run here.

Comparisons between two tracked lane masks (s_cmp_eq/lg where BOTH operands are masks) used to take the per-lane ballot path and produce a per-lane "no lane differs" result; now they're excluded (!(a_mask && c_mask)) so they lower as a scalar comparison of the two ballots, leaving a uniform SCC. The macOS structure test asserts the branch guard is Atom::Uniform(scc) for eq and ne on wave32 and wave64 (97 passed, +1); the valu test pins wave-wide behavior on hardware (Windows-only).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045875418 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#pullrequestreview-6045875418). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T19:24:58Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), `cargo test -p victory-shader --locked` → 97. GPU/valu execution tests are Windows-gated and were not run here. Comparisons between two tracked lane masks (`s_cmp_eq/lg` where BOTH operands are masks) used to take the per-lane ballot path and produce a per-lane "no lane differs" result; now they're excluded (`!(a_mask && c_mask)`) so they lower as a scalar comparison of the two ballots, leaving a uniform SCC. The macOS structure test asserts the branch guard is `Atom::Uniform(scc)` for eq and ne on wave32 and wave64 (97 passed, +1); the valu test pins wave-wide behavior on hardware (Windows-only).
sinan-cmyk commented 2026-11-24 20:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:50:23Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 86b29fa onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 122, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142661736 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7142661736). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T19:50:23Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 86b29fa onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 122, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 02:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:26:12Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149543979 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7149543979). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:26:12Z. --- <!-- victory-triage v1 head=86b29fa4cd5dce62968b6311814feab3f80d7296 verdict=needs-rebase at=2026-11-25T01:26:10Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1412:upstream-pr/1412'
git switch 'upstream-pr/1412'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1412'
git switch 'upstream-pr/1412'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1412'
git switch 'upstream-pr/1412'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1412'
git switch 'main'
git merge --squash 'upstream-pr/1412'
git switch 'main'
git merge --ff-only 'upstream-pr/1412'
git switch 'main'
git merge 'upstream-pr/1412'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1411
No description provided.