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

Open
dutch2005 wants to merge 1 commit from upstream-pr/2631 into main
dutch2005 commented 2026-11-25 17:12:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dutch2005 on 2026-11-25T17:12:45Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5495796762 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2631). Originally posted by [dutch2005](https://github.com/dutch2005) on 2026-11-25T17:12:45Z. --- ## 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.
oni-swr commented 2026-11-25 18:02:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T17:38:08Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169784178 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7169784178). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T17:38:08Z. --- 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.
kotekompotek commented 2026-11-25 18:02:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:52:48Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170127770 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7170127770). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:52:48Z. --- 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.
Marvisak commented 2026-11-25 23:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:21:13Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176255756 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7176255756). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:21:13Z. --- <!-- 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)_
cloph-dsp commented 2026-11-27 00:58:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T00:58:34Z.


Independent local verification of PR #2631 (Shaders: s_cbranch_vccz/nz tests raw VCC, not VCC & EXEC).

Windows, rustc/cargo 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR=D:\Victory-Contrib\target-2631-watch, CARGO_BUILD_JOBS=2, cargo test --locked, synthetic instruction words only, no game data.

  • Command: cargo test --locked -p victory-shader --lib -- structure::tests::cbranch_vcc_tests_raw_vcc_without_exec_masking --exact --test-threads=1 --quiet -> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 250 filtered out, exit 0.
  • git diff --check 940d32f HEAD (merge base) clean; diff is 1 file (+36/-3), crates/victory-shader/src/structure.rs.
  • Negative control: cbranch_vcc_tests_raw_vcc_without_exec_masking is absent from merge base 940d32f via git grep.
  • Note: diffing against current tip origin/main (63bcca4) flags an unrelated blank line at EOF in crates/victory-formats/src/xma/tables.rs; this is not from this PR.
  • GPU/driver: N/A for this CPU-only lowering test. AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7206906499 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2631#issuecomment-7206906499). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T00:58:34Z. --- Independent local verification of PR #2631 (Shaders: `s_cbranch_vccz/nz` tests raw VCC, not VCC & EXEC). Windows, rustc/cargo 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR=D:\Victory-Contrib\target-2631-watch`, `CARGO_BUILD_JOBS=2`, `cargo test --locked`, synthetic instruction words only, no game data. - Command: `cargo test --locked -p victory-shader --lib -- structure::tests::cbranch_vcc_tests_raw_vcc_without_exec_masking --exact --test-threads=1 --quiet` -> `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 250 filtered out`, exit 0. - `git diff --check 940d32f HEAD` (merge base) clean; diff is 1 file (+36/-3), `crates/victory-shader/src/structure.rs`. - Negative control: `cbranch_vcc_tests_raw_vcc_without_exec_masking` is absent from merge base 940d32f via `git grep`. - Note: diffing against current tip `origin/main` (63bcca4) flags an unrelated blank line at EOF in `crates/victory-formats/src/xma/tables.rs`; this is not from this PR. - GPU/driver: N/A for this CPU-only lowering test. AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
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/2631:upstream-pr/2631'
git switch 'upstream-pr/2631'

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/2631'
git switch 'upstream-pr/2631'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2631'
git switch 'upstream-pr/2631'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2631'
git switch 'main'
git merge --squash 'upstream-pr/2631'
git switch 'main'
git merge --ff-only 'upstream-pr/2631'
git switch 'main'
git merge 'upstream-pr/2631'
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!2629
No description provided.