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

Closed
github-bot wants to merge 1 commit from gh-pr/83/head into gh-pr/83/base
Owner

@⁠dutch2005 on GitHub · 2026-11-25 13:38 UTC · original
fix/shader-raw-vcc → main · +55 −6 · 1 files · 1 commits · closed without merging

Why

s_cbranch_vccz and s_cbranch_vccnz were lowered as VCC & EXEC. The hardware tests the raw VCC register. Inactive lanes can leave bits set in VCC (an earlier compare, or a scalar write), so masking with EXEC could flip the branch when those were the only bits set. The fix is ported from the open upstream PR Marvisak/VIctory#2406 (by makmatvey); this tree still has the masked form.

What

  • s_cbranch_vccz / s_cbranch_vccnz test VCC without EXEC.
  • s_cbranch_execz / s_cbranch_execnz compute EXEC only in their own arms.
  • Adds the upstream regression test: a narrowed EXEC, an explicit scalar write to vcc_lo, then both branch directions.

Testing

  • cargo test -p victory-shader cbranch_vcc_tests_raw_vcc_without_exec_masking — 1 passed, 0 failed.

Notes

No default behaviour change outside these branch instructions; a shader that never sets VCC outside EXEC sees the same result.

**@⁠dutch2005** on GitHub · 2026-11-25 13:38 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/83) `fix/shader-raw-vcc` → `main` · +55 −6 · 1 files · 1 commits · closed without merging ## Why `s_cbranch_vccz` and `s_cbranch_vccnz` were lowered as `VCC & EXEC`. The hardware tests the raw VCC register. Inactive lanes can leave bits set in VCC (an earlier compare, or a scalar write), so masking with EXEC could flip the branch when those were the only bits set. The fix is ported from the open upstream PR Marvisak/VIctory#2406 (by makmatvey); this tree still has the masked form. ## What - `s_cbranch_vccz` / `s_cbranch_vccnz` test VCC without EXEC. - `s_cbranch_execz` / `s_cbranch_execnz` compute EXEC only in their own arms. - Adds the upstream regression test: a narrowed EXEC, an explicit scalar write to `vcc_lo`, then both branch directions. ## Testing - `cargo test -p victory-shader cbranch_vcc_tests_raw_vcc_without_exec_masking` — 1 passed, 0 failed. ## Notes No default behaviour change outside these branch instructions; a shader that never sets VCC outside EXEC sees the same result.
Hardware tests the VCC register itself; inactive lanes can leave bits in it from an earlier compare or a scalar write. Masking with EXEC flipped the branch when those were the only bits set. exec is now computed only for s_cbranch_execz/execnz.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:14 +00:00
github-bot closed this pull request 2026-11-26 03:35:14 +00:00
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:36 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at 803b19b: cargo test -p victory-shader --lib --locked: 267 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). Two runs, with #140 applied on top. Without it, parallel victory-shader runs here sometimes crash inside WARP (d3d10warp.dll, STATUS_ACCESS_VIOLATION). main does that too, so it has nothing to do with this PR, but it made the first run of this PR look broken. Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:36 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/83#issuecomment-7168241420) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `803b19b`: `cargo test -p victory-shader --lib --locked`: **267 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Two runs, with #140 applied on top. Without it, parallel `victory-shader` runs here sometimes crash inside WARP (`d3d10warp.dll`, STATUS_ACCESS_VIOLATION). `main` does that too, so it has nothing to do with this PR, but it made the first run of this PR look broken. Workspace tests only; not run in the title.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:47 UTC · original

Checked against the game's shaders.rpf on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (803b19b) applied to 01aadd1 and its own target dir. victory translate --validate --list --host-lanes 32-64 with a hash of every emitted program's DXIL (a local, uncommitted patch): all 25,623 emitted programs are byte for byte the same as on 01aadd1, so no program in the title's archive changes with this fix, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of 01aadd1 give the same hashes, so the comparison is deterministic. cargo test -p victory-shader --lib -- --test-threads=1: 267 passed, 0 failed, 6 ignored. Not run in the game.

**@⁠adrianmjim** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/83#issuecomment-7170002893) Checked against the game's `shaders.rpf` on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (`803b19b`) applied to `01aadd1` and its own target dir. `victory translate --validate --list --host-lanes 32-64` with a hash of every emitted program's DXIL (a local, uncommitted patch): **all 25,623 emitted programs are byte for byte the same as on `01aadd1`**, so no program in the title's archive changes with this fix, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of `01aadd1` give the same hashes, so the comparison is deterministic. `cargo test -p victory-shader --lib -- --test-threads=1`: 267 passed, 0 failed, 6 ignored. Not run in the game.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.