Shaders: s_cbranch_vccz/vccnz tests raw VCC, not VCC & EXEC #2631

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

@⁠dutch2005 on GitHub · 2026-11-25 17:12 UTC · original
dutch2005:backport/raw-vcc → main · +36 −3 · 1 files · 1 commits · open

Why

Back-port of Belobug #83 onto current main (940d32f). s_cbranch_vccz / s_cbranch_vccnz were lowered as VCC & EXEC. The hardware tests raw VCC: inactive lanes can leave bits set in VCC (an earlier compare or a scalar write), and masking with EXEC flips the branch when those are the only bits set.

This was ported manually because git apply --3way of the Belobug commit does not apply to current upstream main (the trees diverged). It is the same rule as the open upstream PR #2406, with the regression test from Belobug #83.

What

  • Remove the VCC & EXEC masking in structure.rs::branch; use VCC directly for both branch directions.
  • Add cbranch_vcc_tests_raw_vcc_without_exec_masking: a narrowed EXEC plus an explicit compare, then both s_cbranch_vccnz and s_cbranch_vccz; the branch condition must support raw VCC only.

Testing

On Windows 11, AMD RX 6700 XT, Rust 1.98.1, from Marvisak/VIctory 940d32f:

  • cargo test -p victory-shader --lib cbranch_vcc_tests_raw_vcc_without_exec_masking -- --test-threads=1 — 1 passed, 0 failed.
  • Full cargo test -p victory-shader --lib -- --test-threads=1 — 248 passed, 0 failed, 3 ignored (81 s).
  • Mutation coverage of the change on Belobug: 1 mutant, unviable (no missed tests); see Belobug #83.

Notes

No game data on this machine; shader-level verification only. If #2406 is preferred, this PR can be closed in its favour — the code change is the same rule.

**@⁠dutch2005** on GitHub · 2026-11-25 17:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2631) `dutch2005:backport/raw-vcc` → `main` · +36 −3 · 1 files · 1 commits · open ## Why Back-port of Belobug #83 onto current `main` (`940d32f`). `s_cbranch_vccz` / `s_cbranch_vccnz` were lowered as `VCC & EXEC`. The hardware tests raw VCC: inactive lanes can leave bits set in VCC (an earlier compare or a scalar write), and masking with EXEC flips the branch when those are the only bits set. This was ported manually because `git apply --3way` of the Belobug commit does not apply to current upstream `main` (the trees diverged). It is the same rule as the open upstream PR #2406, with the regression test from Belobug #83. ## What - Remove the `VCC & EXEC` masking in `structure.rs::branch`; use VCC directly for both branch directions. - Add `cbranch_vcc_tests_raw_vcc_without_exec_masking`: a narrowed EXEC plus an explicit compare, then both `s_cbranch_vccnz` and `s_cbranch_vccz`; the branch condition must support raw VCC only. ## Testing On Windows 11, AMD RX 6700 XT, Rust 1.98.1, from `Marvisak/VIctory` `940d32f`: - `cargo test -p victory-shader --lib cbranch_vcc_tests_raw_vcc_without_exec_masking -- --test-threads=1` — 1 passed, 0 failed. - Full `cargo test -p victory-shader --lib -- --test-threads=1` — **248 passed, 0 failed, 3 ignored** (81 s). - Mutation coverage of the change on Belobug: 1 mutant, unviable (no missed tests); see Belobug #83. ## Notes No game data on this machine; shader-level verification only. If #2406 is preferred, this PR can be closed in its favour — the code change is the same rule.
Back-port from Belobug #83 (same rule as upstream #2406). Hardware tests raw VCC; masking with EXEC flips a branch when only inactive-lane bits are set. Regression test included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:45 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 17:38 UTC · original

Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5).

  • Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), VICTORY_D3D12_WARP=1 and VICTORY_WARP=1 (software WARP only).
  • origin/main = 13f91caee2
  • PR head: 1c5464146d (83 commits behind origin/main; merges cleanly, and I tested the merge too)

Results

  • cargo test -p victory-shader --lib --locked structure:: on the head: 12 passed, 0 failed, 1 ignored, including cbranch_vcc_tests_raw_vcc_without_exec_masking.
  • Full lib on the head: 246 passed, 2 failed, 3 ignored (both failures are WARP wave-size cross-lane tests that also fail on origin/main). Full lib on origin/main + this PR merged (not committed): 268 passed, 3 failed, 3 ignored, against 267 / 3 / 3 on origin/main alone (+1 pass, same 3 failures).
  • cargo clippy -p victory-shader --all-targets --locked: no warnings.

Finding: the new test does not discriminate. With the fix reverted by hand (vcc & exec restored), cbranch_vcc_tests_raw_vcc_without_exec_masking still passes. A debug print in Lanes::branch shows exec is the constant Bool::TRUE at both branches in the test's program, so vcc & exec and vcc build the identical node; the v_cmpx before the branch is not what self.exec(inst) returns there. The test therefore cannot catch a regression to the masked form. A program where EXEC at the branch is a lane atom (e.g. a divergent s_and_saveexec region before the s_cbranch_vcc*) would.

Review: the code change matches the stated hardware behaviour (s_cbranch_vccz/nz test raw VCC; compilers add the EXEC mask explicitly with s_and). No issue with the change itself, only with its test.

Not tested: physical GPU, any retail title.

**@⁠oni-swr** on GitHub · 2026-11-25 17:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7169784178) Independent verification (no physical GPU, no game files, no competing PR). AI-assisted: Claude Code (Claude Sonnet 5.5). - Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0), `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1` (software WARP only). - `origin/main` = 13f91caee25f2fdf2c062be5f7a27f058e51cbca - PR head: 1c5464146d5a9c4777e0fc926b90a31c79c6ec8a (83 commits behind `origin/main`; merges cleanly, and I tested the merge too) **Results** - `cargo test -p victory-shader --lib --locked structure::` on the head: 12 passed, 0 failed, 1 ignored, including `cbranch_vcc_tests_raw_vcc_without_exec_masking`. - Full lib on the head: 246 passed, 2 failed, 3 ignored (both failures are WARP wave-size cross-lane tests that also fail on `origin/main`). Full lib on `origin/main` + this PR merged (not committed): 268 passed, 3 failed, 3 ignored, against 267 / 3 / 3 on `origin/main` alone (+1 pass, same 3 failures). - `cargo clippy -p victory-shader --all-targets --locked`: no warnings. **Finding: the new test does not discriminate.** With the fix reverted by hand (`vcc & exec` restored), `cbranch_vcc_tests_raw_vcc_without_exec_masking` still passes. A debug print in `Lanes::branch` shows `exec` is the constant `Bool::TRUE` at both branches in the test's program, so `vcc & exec` and `vcc` build the identical node; the `v_cmpx` before the branch is not what `self.exec(inst)` returns there. The test therefore cannot catch a regression to the masked form. A program where EXEC at the branch is a lane atom (e.g. a divergent `s_and_saveexec` region before the `s_cbranch_vcc*`) would. **Review**: the code change matches the stated hardware behaviour (`s_cbranch_vccz/nz` test raw VCC; compilers add the EXEC mask explicitly with `s_and`). No issue with the change itself, only with its test. **Not tested**: physical GPU, any retail title.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:52 UTC · original

Reviewed: the change is semantically right — raw VCC without EXEC masking, with inactive lanes' stale VCC bits correctly driving the branch (matches the hardware evidence in #2406/#2405). Note this is the third PR for the same fix after #2405 — identical semantics, both with tests; whichever lands first closes the other. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7170127770) Reviewed: the change is semantically right — raw VCC without EXEC masking, with inactive lanes' stale VCC bits correctly driving the branch (matches the hardware evidence in #2406/#2405). Note this is the third PR for the same fix after **#2405** — identical semantics, both with tests; whichever lands first closes the other. CI green.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:21 UTC · original

Automated triage for the maintainers.

Proposed close (no change in behaviour; duplicate of #2406 / #2405). This is the same edit as #2406, which this run's triage already proposed closing for the same reason. In crates/victory-shader/src/structure.rs, Lanes::exec returns Bool::TRUE for an instruction that does not read EXEC, and crates/victory-shader/src/ir.rs gives s_cbranch_vccz / s_cbranch_vccnz only a VCC read, so on main and(vcc, exec) already reduces to vcc. Dropping the and changes nothing; an offline comparison over the title's shaders reported on #2406 found 0 programs gained or lost. The new test cbranch_vcc_tests_raw_vcc_without_exec_masking therefore passes on main as well, and the added comment describes a behaviour change the diff does not make. What is actually wrong, per the readbacks on #2405 / #2406, is that the branch is decided per lane instead of once for the wave from VCC != 0. A PR fixing that, with a test that fails on main, would be welcome.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7176255756) <!-- victory-triage v1 head=1c5464146d5a9c4777e0fc926b90a31c79c6ec8a verdict=proposed-close at=2026-11-25T22:21:45Z --> Automated triage for the maintainers. **Proposed close (no change in behaviour; duplicate of #2406 / #2405).** This is the same edit as #2406, which this run's triage already proposed closing for the same reason. In `crates/victory-shader/src/structure.rs`, `Lanes::exec` returns `Bool::TRUE` for an instruction that does not read EXEC, and `crates/victory-shader/src/ir.rs` gives `s_cbranch_vccz` / `s_cbranch_vccnz` only a VCC read, so on `main` `and(vcc, exec)` already reduces to `vcc`. Dropping the `and` changes nothing; an offline comparison over the title's shaders reported on #2406 found 0 programs gained or lost. The new test `cbranch_vcc_tests_raw_vcc_without_exec_masking` therefore passes on `main` as well, and the added comment describes a behaviour change the diff does not make. What is actually wrong, per the readbacks on #2405 / #2406, is that the branch is decided per lane instead of once for the wave from `VCC != 0`. A PR fixing that, with a test that fails on `main`, would be welcome. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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