Shaders: fix whole-wave EXEC inline constant sign-extension and prefix lane validation (port of VIctory#646) #191

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

@⁠lcg007xd-c on GitHub · 2026-11-25 20:25 UTC · original
lcg007xd-c:port/vic-646 → main · +294 −22 · 1 files · 1 commits · open

Port of Marvisak/VIctory#646 by nathanbzrr. It is cherry-picked with -x, so the commit keeps its author and its upstream hash. This fork's main (000ffdd) does not have it, and it is not in #142.

What it fixes

Whole-wave EXEC inline constants were not sign-extended (e.g. exec = -2 must mask only lane 0), and the prefix-lane validation accepted unsound prefixes.

Tested (Linux, Rust 1.98.1)

  • 4 of the 11 wave tests fail on this fork's main and pass with the port: constant_decodes_width_and_inline_kinds, exec_minus_two_masks_lane_zero_and_enforces_dpp_guard, wave32_mov_b64_all_lanes_keeps_exec_masked_for_dpp, per_lane_prefix_soundness. Upstream's helper was renamed build_ended so it does not clash with the fork's build.
  • cargo test -p victory-shader --lib on this branch alone: no failures.
  • It applies to main without conflicts, and does not depend on the other open ports.

Not run here: Windows/GPU tests, since I have no Windows machine.

🤖 Generated with Claude Code

**@⁠lcg007xd-c** on GitHub · 2026-11-25 20:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/191) `lcg007xd-c:port/vic-646` → `main` · +294 −22 · 1 files · 1 commits · open Port of [Marvisak/VIctory#646](https://github.com/Marvisak/VIctory/pull/646) by nathanbzrr. It is cherry-picked with `-x`, so the commit keeps its author and its upstream hash. This fork's `main` (000ffdd) does not have it, and it is not in #142. ## What it fixes Whole-wave EXEC inline constants were not sign-extended (e.g. `exec = -2` must mask only lane 0), and the prefix-lane validation accepted unsound prefixes. ## Tested (Linux, Rust 1.98.1) - 4 of the 11 wave tests fail on this fork's main and pass with the port: `constant_decodes_width_and_inline_kinds`, `exec_minus_two_masks_lane_zero_and_enforces_dpp_guard`, `wave32_mov_b64_all_lanes_keeps_exec_masked_for_dpp`, `per_lane_prefix_soundness`. Upstream's helper was renamed `build_ended` so it does not clash with the fork's `build`. - `cargo test -p victory-shader --lib` on this branch alone: no failures. - It applies to `main` without conflicts, and does not depend on the other open ports. **Not run here:** Windows/GPU tests, since I have no Windows machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
(cherry picked from commit 12eba495039d8018eb6959be95fcc10e387b7e33)

Conflict resolved against the fork's whole-wave section tests: both test sets kept; upstream's test helper that appends s_endpgm is named build_ended beside the fork's build.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:38 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 05:00 UTC · original

RDNA2 data point. This PR (660b49c) merged on main 4f62c2a, cargo test --release -p victory-shader --lib on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1):

  • main: 275 passed, 2 failed.
  • This PR: 279 passed, 2 failed, in 2 runs out of 2. The 4 new tests pass.

The 2 failures are the same as on main: the RDNA2 wave-size tests scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops, fixed by #110 and #204. No regression here. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 05:00 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/191#issuecomment-7183091673) RDNA2 data point. This PR (`660b49c`) merged on `main` `4f62c2a`, `cargo test --release -p victory-shader --lib` on an RX 6950 XT (Windows 11 build 26300, Rust 1.98.1): - `main`: 275 passed, 2 failed. - This PR: 279 passed, 2 failed, in 2 runs out of 2. The 4 new tests pass. The 2 failures are the same as on `main`: the RDNA2 wave-size tests `scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops`, fixed by #110 and #204. No regression here. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:44 UTC · original

Tested on Windows 11 (build 26300) with an RX 7900 XT, Rust 1.98.1. I took the head 660b49c and applied its diff on top of main 4f62c2a. The branch is based on 000ffdd, but wave.rs is the same in both and the merge is clean.

  • cargo test -p victory-shader --lib -- --test-threads=1: 281 passed, 0 failed, 6 ignored. Main gives 277, so the 4 extra are the new tests.
  • With only the new tests applied to 4f62c2a, the same 4 fail: constant_decodes_width_and_inline_kinds, exec_minus_two_masks_lane_zero_and_enforces_dpp_guard, wave32_mov_b64_all_lanes_keeps_exec_masked_for_dpp, per_lane_prefix_soundness. The other 7 wave tests pass.
  • I translated the title's full shaders.rpf with translate --validate --host-lanes 32-64. All 25,623 emitted DXIL programs are byte-identical to main. The translated, validated and refused counts are unchanged, and so is the IR instruction total.

I also counted every s_mov to EXEC in the archive (exec, exec_lo, exec_hi). Each one has one of these sources:

  • an SGPR (or vcc)
  • -1
  • 0 (only in exec_lo)
  • a 32-bit literal (only in exec_lo/exec_hi)

None uses a negative inline constant other than -1, a float inline constant, or null. So the old and new constant() give the same value for every one of them. The EXEC masking in simulate() and the stricter per_lane() checks also left every output unchanged. I did not trace why for those two.

Not tested: anything on the GPU beyond validation. No pipelines were created and the title was not run. The unit tests are CPU-only. I only ran host lanes 32-64, with the default shader clean-up passes on.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:44 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/191#issuecomment-7201915876) Tested on Windows 11 (build 26300) with an RX 7900 XT, Rust 1.98.1. I took the head 660b49c and applied its diff on top of main 4f62c2a. The branch is based on 000ffdd, but wave.rs is the same in both and the merge is clean. - `cargo test -p victory-shader --lib -- --test-threads=1`: 281 passed, 0 failed, 6 ignored. Main gives 277, so the 4 extra are the new tests. - With only the new tests applied to 4f62c2a, the same 4 fail: `constant_decodes_width_and_inline_kinds`, `exec_minus_two_masks_lane_zero_and_enforces_dpp_guard`, `wave32_mov_b64_all_lanes_keeps_exec_masked_for_dpp`, `per_lane_prefix_soundness`. The other 7 wave tests pass. - I translated the title's full shaders.rpf with `translate --validate --host-lanes 32-64`. All 25,623 emitted DXIL programs are byte-identical to main. The translated, validated and refused counts are unchanged, and so is the IR instruction total. I also counted every `s_mov` to EXEC in the archive (`exec`, `exec_lo`, `exec_hi`). Each one has one of these sources: - an SGPR (or vcc) - `-1` - `0` (only in `exec_lo`) - a 32-bit literal (only in `exec_lo`/`exec_hi`) None uses a negative inline constant other than -1, a float inline constant, or `null`. So the old and new `constant()` give the same value for every one of them. The EXEC masking in `simulate()` and the stricter `per_lane()` checks also left every output unchanged. I did not trace why for those two. Not tested: anything on the GPU beyond validation. No pipelines were created and the title was not run. The unit tests are CPU-only. I only ran host lanes 32-64, with the default shader clean-up passes on.
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/191/head:github-bot/gh-191'
git switch 'github-bot/gh-191'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-191'
git switch 'github-bot/gh-191'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-191'
git switch 'github-bot/gh-191'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-191'
git switch 'main'
git merge --squash 'github-bot/gh-191'
git switch 'main'
git merge --ff-only 'github-bot/gh-191'
git switch 'main'
git merge 'github-bot/gh-191'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.