Shaders: keep scalar comparisons between lane masks uniform #1412

Open
github-bot wants to merge 1 commit from github-bot/gh-1412 into main AGit
Owner

@⁠EatCodeSleep2 on GitHub · 2026-11-24 17:50 UTC · original
EatCodeSleep2:fix/uniform-scalar-mask-compare-1242 → main · +91 −4 · 2 files · 1 commits · open

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.

**@⁠EatCodeSleep2** on GitHub · 2026-11-24 17:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1412) `EatCodeSleep2:fix/uniform-scalar-mask-compare-1242` → `main` · +91 −4 · 2 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:49 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:59 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7140006400) 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.*
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 18:33 UTC · original

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.

**@⁠marquezinii** on GitHub · 2026-11-24 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7140818002) 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.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7142661736) ### 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:26 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1412#issuecomment-7149543979) <!-- 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 has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1412/head:github-bot/gh-1412'
git switch 'github-bot/gh-1412'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1412'
git switch 'github-bot/gh-1412'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1412'
git switch 'github-bot/gh-1412'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1412'
git switch 'main'
git merge --squash 'github-bot/gh-1412'
git switch 'main'
git merge --ff-only 'github-bot/gh-1412'
git switch 'main'
git merge 'github-bot/gh-1412'
git push origin 'main'
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!1412
No description provided.