Shaders: a select on a lane mask held as a number keeps the console's lanes (port of VIctory-7900XTX #308) #52

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

@⁠illuminatedfellow on GitHub · 2026-11-27 15:05 UTC · original
illuminatedfellow:port-308 → main · +36 −0 · 2 files · 1 commits · open

Port of compaccount1-coder's fix from avatarmanz/VIctory-7900XTX#308 (still open there), cherry-picked with their authorship; the commit message is theirs.

The bug, on this fork's main: a v_cndmask_b32 select on a lane mask the code holds as a number (a constant bit pattern, or one loaded from memory) is lowered to each lane's own bit of that number. That is the console's bit only with the console's lanes, but the check that sets console_lanes doesn't count such a select. A compute program whose only cross-lane code is one is lowered without them:

  • release builds: no wave size and no relabelling, so each lane takes the bit of whatever host lane it lands in;
  • debug builds: the debug_assert! in cross_lane fires.

The fix: selects_on_mask_data counts toward console_lanes, beside reads_mask_as_data.

How it was found and checked here:

  • Fuzzing this fork's translator on Linux (random and mutated GFX10 programs through ir::build, structure, resources, io and lowering, with debug assertions on): 11 of 480,000 programs hit that assertion, all from this select.
  • The test program (an every-other-lane select, wave32, 64 threads), lowered at a host of 32-lane waves: on main, debug panics on the assertion and release gives wave_size None; on this branch, Some(32) in both.
  • After the fix: 780,000 more programs, including the seeds that crashed, with 0 panics.
  • cargo test -p victory-shader: 205 passed. The test file had changed here, so the new test is written with this fork's lowered_with_wave; it is in wave64_tests.rs, which runs on Windows only, so it hasn't run yet.

Not run on an RTX card or with title shaders.

**@⁠illuminatedfellow** on GitHub · 2026-11-27 15:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/52) `illuminatedfellow:port-308` → `main` · +36 −0 · 2 files · 1 commits · open Port of compaccount1-coder's fix from avatarmanz/VIctory-7900XTX#308 (still open there), cherry-picked with their authorship; the commit message is theirs. **The bug, on this fork's main:** a `v_cndmask_b32` select on a lane mask the code holds as a number (a constant bit pattern, or one loaded from memory) is lowered to each lane's own bit of that number. That is the console's bit only with the console's lanes, but the check that sets `console_lanes` doesn't count such a select. A compute program whose only cross-lane code is one is lowered without them: - release builds: no wave size and no relabelling, so each lane takes the bit of whatever host lane it lands in; - debug builds: the `debug_assert!` in `cross_lane` fires. **The fix:** `selects_on_mask_data` counts toward `console_lanes`, beside `reads_mask_as_data`. **How it was found and checked here:** - Fuzzing this fork's translator on Linux (random and mutated GFX10 programs through `ir::build`, structure, resources, io and lowering, with debug assertions on): 11 of 480,000 programs hit that assertion, all from this select. - The test program (an every-other-lane select, wave32, 64 threads), lowered at a host of 32-lane waves: on main, debug panics on the assertion and release gives `wave_size` None; on this branch, `Some(32)` in both. - After the fix: 780,000 more programs, including the seeds that crashed, with 0 panics. - `cargo test -p victory-shader`: 205 passed. The test file had changed here, so the new test is written with this fork's `lowered_with_wave`; it is in `wave64_tests.rs`, which runs on Windows only, so it hasn't run yet. Not run on an RTX card or with title shaders.
`v_cndmask_b32` on a mask the code holds as a number (not one it tracks as
lanes: a constant bit pattern, one loaded from memory) is lowered to the
lane's own bit of it (`lane_bit`), which is the console's bit only with the
console's lanes. The check that decides `console_lanes` looked for masks read
as data, guards on constant masks and the cross-lane instructions, but not
for such a select, so a compute program whose only cross-lane code is one was
lowered without them:

- release builds: no wave size and no relabelling, so each lane took the bit
  of whatever host lane it landed in;
- debug builds: `debug_assert!(self.s.threads.is_none() || self.console_lanes)`
  in `cross_lane` fired.

`selects_on_mask_data` now counts for `console_lanes`, beside
`reads_mask_as_data`. Found by feeding random GFX10 programs through the
whole translator; the new test is the smallest form of it (an every-other-
lane select in a wave32 program of 64 threads): `wave_size` None before,
Some(32) now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2031a078504b6d49c55a5ad5dd78d6d9669a81b6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 15:08:39 +00:00
Author
Owner

@⁠1tsethan on GitHub · 2026-11-27 23:00 UTC · original

Independent Windows validation of PR #52.

Tested commit: e399f154c639fd561625c80e2b5e9259834bac33.

cargo test --locked -p victory-shader a_select_on_a_mask_held -- --nocapture --test-threads=1

Exit: 0.

  • test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 292 filtered out; finished in 0.00s

This ran the mask-select lowering regression. It does not establish shader execution/output parity on the physical RTX adapter.

Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result.

**@⁠1tsethan** on GitHub · 2026-11-27 23:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/52#issuecomment-7229798086) Independent Windows validation of PR #52. Tested commit: `e399f154c639fd561625c80e2b5e9259834bac33`. `cargo test --locked -p victory-shader a_select_on_a_mask_held -- --nocapture --test-threads=1` Exit: **0**. - test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 292 filtered out; finished in 0.00s This ran the mask-select lowering regression. It does not establish shader execution/output parity on the physical RTX adapter. Independent verification with OpenAI Codex assistance. Windows 11 Pro build 26200; Rust 1.98.1 MSVC; Windows SDK libraries from Microsoft.Windows.SDK.CPP.x64 10.0.28000.2957. Test harness used an RTX 3070 Ti / AMD integrated-GPU host; adapter identity was not captured for every test. These are focused checks on the stated PR commit, not gameplay, FPS, or a merged-main integration result. <!-- victory-native-validation-20261128 -->
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-27 23:35 UTC · original

Independent local verification of PR #52 (shader select on a lane mask held as a number keeps the console's lanes).

  • Windows, Rust 1.100.0/MSVC (Scoop rust-msvc, no rustup/clippy), cargo test --locked, synthetic inputs only.
  • Head e399f154c639fd561625c80e2b5e9259834bac33, merge base d12eb1b23da4cad2f551a3dd49e82a87e564122a, worktree-local CARGO_TARGET_DIR.
  • Command: cargo test --locked -p victory-shader --lib -- emit::wave64_tests::a_select_on_a_mask_held_as_a_number_keeps_the_consoles_lanes --exact --test-threads=1 --quiet → test result: ok. 1 passed; 0 failed; 292 filtered out, exit 0.
  • Negative control: git grep -F a_select_on_a_mask_held_as_a_number_keeps_the_consoles_lanes d12eb1b2 -- crates/victory-shader/src/emit/wave64_tests.rs → exit 1 (test absent on base).
  • git diff --check d12eb1b2 HEAD clean; diff 2 files, +36 (lower.rs + wave64_tests.rs).

Only the named test was replayed; full suite not run. GPU/driver N/A (CPU-side lowering test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.

**@⁠cloph-dsp** on GitHub · 2026-11-27 23:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/52#issuecomment-7230254160) Independent local verification of PR #52 (shader select on a lane mask held as a number keeps the console's lanes). - Windows, Rust 1.100.0/MSVC (Scoop rust-msvc, no rustup/clippy), `cargo test --locked`, synthetic inputs only. - Head `e399f154c639fd561625c80e2b5e9259834bac33`, merge base `d12eb1b23da4cad2f551a3dd49e82a87e564122a`, worktree-local `CARGO_TARGET_DIR`. - Command: `cargo test --locked -p victory-shader --lib -- emit::wave64_tests::a_select_on_a_mask_held_as_a_number_keeps_the_consoles_lanes --exact --test-threads=1 --quiet` → `test result: ok. 1 passed; 0 failed; 292 filtered out`, exit 0. - Negative control: `git grep -F a_select_on_a_mask_held_as_a_number_keeps_the_consoles_lanes d12eb1b2 -- crates/victory-shader/src/emit/wave64_tests.rs` → exit 1 (test absent on base). - `git diff --check d12eb1b2 HEAD` clean; diff 2 files, +36 (lower.rs + wave64_tests.rs). Only the named test was replayed; full suite not run. GPU/driver N/A (CPU-side lowering test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
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/52/head:github-bot/gh-52'
git switch 'github-bot/gh-52'

Merge

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