Shaders: the SCC of a lane-mask operation, read as data, is whether the mask is not zero #3401

Open
Lyrnc wants to merge 2 commits from upstream-pr/3401 into main
Lyrnc commented 2026-11-26 22:25:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T22:25:16Z.


What was refused

Four compute programs of the title's FidelityFX upscaler DLL (amd_fidelityfx_upscaler_xbox.dll) stop with
emit: a lane mask read as data: 8e614708143ef917 (wave32), 17af85f170e66f30, 477b52e73ddeb6f2,
8b437ab61d8008fe (wave64). They are four of the six untranslated passes of the title's own upscaler that the
README lists under Series S.

Each waits in a bounded poll loop whose exit test reads the SCC of a lane-mask operation as data. The shape,
as this PR's test writes it:

loop:
    s_add_u32       s22, s22, 1
    v_cmp_gt_u32    vcc_lo, s22, v4       ; the lanes done
    s_and_b32       s20, vcc_lo, exec_lo  ; a lane mask; SCC = (s20 != 0)
    s_cselect_b32   s21, 0, -1            ; reads that SCC as data: -1 if no lane is done
    s_cmp_ge_u32    s22, 64
    s_cselect_b32   s23, -1, 0            ; -1 at the iteration limit
    s_orn2_b32      s23, s23, s21         ; SCC = limit reached or some lane done
    s_cbranch_scc0  loop

sop() refuses every SALU instruction that writes a lane mask, and the refusal marks all it writes, its SCC
too, as a lane mask read as data. A branch on such an SCC already lowers (it is the lane's own bit,
structure's scc_lane), but nothing resolved an SCC that another instruction reads as data, so the
s_cselect carried the refusal on to the loop's branch.

What changed

emit/lower.rs:

  • mask_sccs_read_as_data finds the SCC values of bitwise operations (s_and/or/xor/andn2/orn2/nand/nor/xnor/not,
    32 and 64 bit) that write a lane mask and no EXEC, read by an instruction other than an s_cbranch.
  • In sop(), such an operation in a compute program (MaskData::Console: host lane n is console lane n) sets
    its SCC to the mask's number tested for zero (mask_nonzero: mask_dword's ballot, or its exact number for a
    mask holding lanes elsewhere such as a complement; both dwords in wave64), taken where the operation runs. The
    mask itself stays a mask, read as a number where it is read, as before. Vertex, pixel and mesh programs keep
    the refusal (their ballots are over the host's wave).
  • A program with such a read declares the console's wave size, as programs reading a mask as a number already do.

The ISA rule (SCC = D != 0 over the whole register, the lanes outside EXEC included) was checked on RDNA2
hardware (below).

Tests

emit/crosslane_tests.rs, hand-encoded words:

  • mask_operation_scc_read_as_data_is_the_waves_any_on_gpu (wave32, 32 lanes, hardware adapter; skipped where
    32-lane waves are not available): s_and_b32 of a compare with some lanes set / none set; s_not_b32 of a
    mask set in every running lane under a branch on the even lanes (the odd lanes' bits make it not zero);
    s_andn2_b32 of EXEC and that mask (zero); and a poll loop of the shape above that must leave at the same
    count in every lane. Each s_cselect result is checked in all 32 lanes, so a lowering that used the lane's
    own bit fails.
  • wave64_mask_operation_scc_reads_both_dwords: a wave64 program whose mask is set only in the high dword (and
    one with no lane set); lowered and validated everywhere, run where the host has 64-lane waves.

Results:

  • RTX 5080 (the default adapter): both pass; the wave32 test runs all five cases, the wave64 one is lowered and
    validated (no 64-lane waves on NVIDIA).
  • AMD Radeon iGPU (RDNA2 gfx1036, picked with a local adapter filter that is not part of this PR): both pass,
    the wave64 program dispatched on 64-lane waves.
  • Against main's lowering (this PR's tests, lower.rs from main) both fail at lowering with
    a lane mask read as data.
  • RDNA2 hardware (gfx1036 through a hardware oracle running hand-written GFX10 assembly, 64 rows): the same
    sequences (s_and_b32 of a compare with and without lanes set, s_not_b32 and s_andn2_b32 under a
    narrowed EXEC, the poll loop; wave64 s_and_b64 with only high-dword lanes set, none set, low-dword lanes
    set) read through s_cselect_b32: 0 differences from SCC = (result != 0) over the whole register.
  • cargo clippy -p victory-shader --lib --tests -- -D warnings: clean. cargo xtask policy: 191 files ok.
  • cargo test -p victory-shader --lib -- --test-threads=1 on the RTX 5080, skipping
    heap_direct_texture_reads_mark_their_heap_index (it kills the test process on this machine, as #2571 reports):
    300 passed, 3 failed, 3 ignored. The three (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,
    stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,
    synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on main 63bcca4 here.

Census (offline, the title's shader pack, exe and DLLs)

translate --list --validate over shaders.rpf, the executable, XboxBvhBuilder.dll and
amd_fidelityfx_upscaler_xbox.dll, validator dxc 1.9.2609 dxil.dll, main 63bcca4 against this branch,
compared program by program:

main 63bcca4 this branch
compute programs emitted / validated 2,733 / 1,985 2,734 / 1,986
all programs validated 24,937 24,938
  • 8e614708143ef917 (wave32) now validates.
  • 17af85f170e66f30, 477b52e73ddeb6f2, 8b437ab61d8008fe (wave64) get past this refusal and stop at the next
    one, a whole-wave section step the simulation does not follow: their wave OR reduction finishes in the high
    half and is read at lane 63 after the section. #3402
    handles that; with both, all four validate (24,937 -> 24,941 programs validated, compute 1,985 -> 1,989, nothing else changes).
  • No other program changes outcome, and no other emitted program changes by a byte (every emitted program's
    DXIL compared by hash).

This touches the same lines of sop() as #3016 (the SCC of a waterfall loop's s_andn2_wrexec), which fixes
the other four a lane mask read as data programs of the pack (827b309e779552d7, 82a2ad6d07417d36,
90a0692af4320129, 9ffcaff533995118); the two changes are independent and combine by hand.

Not tested

  • No live run: the title's own upscaler runs only in Series S mode without VICTORY_FIDELITYFX_DIR, and the
    game was not started.
  • The wave64 programs need a host with 64-lane waves; NVIDIA hosts refuse a WaveSize(64) compute pipeline
    whatever this change does.

AI use: Claude Code (Claude Opus 5.5) found the refusal in the offline census, wrote the change, the tests and
this text, and ran the checks on our machine; Lyrnc reviews what goes out. No game data is included (hashes,
counts and error text only; the snippet above is the test's, written by hand).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5517977666 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-26T22:25:16Z. --- ## What was refused Four compute programs of the title's FidelityFX upscaler DLL (`amd_fidelityfx_upscaler_xbox.dll`) stop with `emit: a lane mask read as data`: `8e614708143ef917` (wave32), `17af85f170e66f30`, `477b52e73ddeb6f2`, `8b437ab61d8008fe` (wave64). They are four of the six untranslated passes of the title's own upscaler that the README lists under Series S. Each waits in a bounded poll loop whose exit test reads the SCC of a lane-mask operation as data. The shape, as this PR's test writes it: ``` loop: s_add_u32 s22, s22, 1 v_cmp_gt_u32 vcc_lo, s22, v4 ; the lanes done s_and_b32 s20, vcc_lo, exec_lo ; a lane mask; SCC = (s20 != 0) s_cselect_b32 s21, 0, -1 ; reads that SCC as data: -1 if no lane is done s_cmp_ge_u32 s22, 64 s_cselect_b32 s23, -1, 0 ; -1 at the iteration limit s_orn2_b32 s23, s23, s21 ; SCC = limit reached or some lane done s_cbranch_scc0 loop ``` `sop()` refuses every SALU instruction that writes a lane mask, and the refusal marks all it writes, its SCC too, as `a lane mask read as data`. A branch on such an SCC already lowers (it is the lane's own bit, `structure`'s `scc_lane`), but nothing resolved an SCC that another instruction reads as data, so the `s_cselect` carried the refusal on to the loop's branch. ## What changed `emit/lower.rs`: - `mask_sccs_read_as_data` finds the SCC values of bitwise operations (`s_and/or/xor/andn2/orn2/nand/nor/xnor/not`, 32 and 64 bit) that write a lane mask and no EXEC, read by an instruction other than an `s_cbranch`. - In `sop()`, such an operation in a compute program (`MaskData::Console`: host lane n is console lane n) sets its SCC to the mask's number tested for zero (`mask_nonzero`: `mask_dword`'s ballot, or its exact number for a mask holding lanes elsewhere such as a complement; both dwords in wave64), taken where the operation runs. The mask itself stays a mask, read as a number where it is read, as before. Vertex, pixel and mesh programs keep the refusal (their ballots are over the host's wave). - A program with such a read declares the console's wave size, as programs reading a mask as a number already do. The ISA rule (`SCC = D != 0` over the whole register, the lanes outside EXEC included) was checked on RDNA2 hardware (below). ## Tests `emit/crosslane_tests.rs`, hand-encoded words: - `mask_operation_scc_read_as_data_is_the_waves_any_on_gpu` (wave32, 32 lanes, hardware adapter; skipped where 32-lane waves are not available): `s_and_b32` of a compare with some lanes set / none set; `s_not_b32` of a mask set in every running lane under a branch on the even lanes (the odd lanes' bits make it not zero); `s_andn2_b32` of EXEC and that mask (zero); and a poll loop of the shape above that must leave at the same count in every lane. Each `s_cselect` result is checked in all 32 lanes, so a lowering that used the lane's own bit fails. - `wave64_mask_operation_scc_reads_both_dwords`: a wave64 program whose mask is set only in the high dword (and one with no lane set); lowered and validated everywhere, run where the host has 64-lane waves. Results: - RTX 5080 (the default adapter): both pass; the wave32 test runs all five cases, the wave64 one is lowered and validated (no 64-lane waves on NVIDIA). - AMD Radeon iGPU (RDNA2 gfx1036, picked with a local adapter filter that is not part of this PR): both pass, the wave64 program dispatched on 64-lane waves. - Against main's lowering (this PR's tests, `lower.rs` from main) both fail at lowering with `a lane mask read as data`. - RDNA2 hardware (gfx1036 through a hardware oracle running hand-written GFX10 assembly, 64 rows): the same sequences (`s_and_b32` of a compare with and without lanes set, `s_not_b32` and `s_andn2_b32` under a narrowed EXEC, the poll loop; wave64 `s_and_b64` with only high-dword lanes set, none set, low-dword lanes set) read through `s_cselect_b32`: 0 differences from SCC = (result != 0) over the whole register. - `cargo clippy -p victory-shader --lib --tests -- -D warnings`: clean. `cargo xtask policy`: 191 files ok. - `cargo test -p victory-shader --lib -- --test-threads=1` on the RTX 5080, skipping `heap_direct_texture_reads_mark_their_heap_index` (it kills the test process on this machine, as #2571 reports): 300 passed, 3 failed, 3 ignored. The three (`stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`) fail the same way on main `63bcca4` here. ## Census (offline, the title's shader pack, exe and DLLs) `translate --list --validate` over `shaders.rpf`, the executable, `XboxBvhBuilder.dll` and `amd_fidelityfx_upscaler_xbox.dll`, validator dxc 1.9.2609 `dxil.dll`, main `63bcca4` against this branch, compared program by program: | | main `63bcca4` | this branch | |---|---:|---:| | compute programs emitted / validated | 2,733 / 1,985 | 2,734 / 1,986 | | all programs validated | 24,937 | 24,938 | - `8e614708143ef917` (wave32) now validates. - `17af85f170e66f30`, `477b52e73ddeb6f2`, `8b437ab61d8008fe` (wave64) get past this refusal and stop at the next one, `a whole-wave section step the simulation does not follow`: their wave OR reduction finishes in the high half and is read at lane 63 after the section. #3402 handles that; with both, all four validate (24,937 -> 24,941 programs validated, compute 1,985 -> 1,989, nothing else changes). - No other program changes outcome, and no other emitted program changes by a byte (every emitted program's DXIL compared by hash). This touches the same lines of `sop()` as #3016 (the SCC of a waterfall loop's `s_andn2_wrexec`), which fixes the other four `a lane mask read as data` programs of the pack (`827b309e779552d7`, `82a2ad6d07417d36`, `90a0692af4320129`, `9ffcaff533995118`); the two changes are independent and combine by hand. ## Not tested - No live run: the title's own upscaler runs only in Series S mode without `VICTORY_FIDELITYFX_DIR`, and the game was not started. - The wave64 programs need a host with 64-lane waves; NVIDIA hosts refuse a `WaveSize(64)` compute pipeline whatever this change does. AI use: Claude Code (Claude Opus 5.5) found the refusal in the offline census, wrote the change, the tests and this text, and ran the checks on our machine; Lyrnc reviews what goes out. No game data is included (hashes, counts and error text only; the snippet above is the test's, written by hand). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dukestar69 commented 2026-11-26 22:27:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:27:57Z.

Review: APPROVED


LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Lowering SCC from a lane-mask operation read as data to wave-any non-zero (across both dwords for wave64) passes cleanly on both RTX 5090 and WARP.
  • cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 7 passed, 0 failed on RTX 5090 and 7 passed, 0 failed on VICTORY_WARP=1 (mask_operation_scc_read_as_data_is_the_waves_any_on_gpu and wave64_mask_operation_scc_reads_both_dwords).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081122813 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#pullrequestreview-6081122813). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:27:57Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 and `VICTORY_WARP=1` (Windows / D3D12) against `origin/main` (`63bcca4`). - Lowering SCC from a lane-mask operation read as data to wave-any non-zero (across both dwords for wave64) passes cleanly on both RTX 5090 and WARP. - `cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1`: 7 passed, 0 failed on RTX 5090 and 7 passed, 0 failed on `VICTORY_WARP=1` (`mask_operation_scc_read_as_data_is_the_waves_any_on_gpu` and `wave64_mask_operation_scc_reads_both_dwords`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Aniseto commented 2026-11-26 22:39:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-26T22:39:50Z.


Ran the wave32 mask-SCC test at d9ed313 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

cargo test -p victory-shader --lib mask_operation_scc_read_as_data_is_the_waves_any_on_gpu -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 306 filtered out      (exit 0)

The test passes on the real adapter with native 32-lane waves. The PR also adds wave64_mask_operation_scc_reads_both_dwords, which I did not run here: this card cannot dispatch a WaveSize(64) pipeline. The thread has no comments yet; the author ran the same test on an RTX 5080, so this adds a second NVIDIA part with driver 32.0.16.2124.

Not tested: the wave64 GPU path, the title's FidelityFX shaders, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204877362 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7204877362). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-26T22:39:50Z. --- Ran the wave32 mask-SCC test at `d9ed313` on an NVIDIA Blackwell desktop part: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build. ``` cargo test -p victory-shader --lib mask_operation_scc_read_as_data_is_the_waves_any_on_gpu -- --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 306 filtered out (exit 0) ``` The test passes on the real adapter with native 32-lane waves. The PR also adds `wave64_mask_operation_scc_reads_both_dwords`, which I did not run here: this card cannot dispatch a `WaveSize(64)` pipeline. The thread has no comments yet; the author ran the same test on an RTX 5080, so this adds a second NVIDIA part with driver 32.0.16.2124. Not tested: the wave64 GPU path, the title's FidelityFX shaders, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
fuzeofficlal commented 2026-11-26 22:47:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:47:14Z.

Review: CHANGES_REQUESTED


Good catch on s_cselect / scalar polling loops using the SCC of bitwise lane-mask instructions. The existing test suite passes (40/40 on both RTX 5090 and WARP, with all 5 Wave32 cases running on RTX 5090 and the Wave64 case passing DXIL validation), and crates/victory-shader/src/emit/lower.rs stays under the 512 KiB ceiling at 523,600 bytes.

However, there are two P1 semantic bugs where newly accepted shaders silently diverge from RDNA2 ISA (previously rejected with Err(LANE_MASK)):

  1. Partial-wave dispatch + bitwise complement/negation flips SCC from 1 to 0:
    In crates/victory-shader/src/structure.rs:703-710, entry EXEC is modeled as Bool::TRUE. Because implies(m, Bool::TRUE) is always true at structure.rs:1198, an operation like s_not_b32 s20, vcc_lo in the entry block marks s20 in self.active. On a partial wave (e.g., 16 threads in Wave32 or 32 in Wave64) where every running lane sets vcc, native s20 is 0xFFFF_0000 (SCC = 1), yet lower.rs:1874 skips mask_number because s20 is in active and runs waveActiveBallot(!vcc) over only the active host lanes, returning 0 and turning SCC into 0.
  2. Same SCC read both as data and by s_cbranch_scc* disagrees across lanes:
    If s_and_b32 s20, vcc_lo, exec_lo (say only lane 0 set under full EXEC) has its SCC read by s_cselect_b32 s21, 1, 2 and then branched on by s_cbranch_scc1 on the same SSA SCC value, lower.rs:454 + lower.rs:3648 give s_cselect the wave-wide bit (1 in all lanes), while structure.rs:1204 / structure.rs:1368 and lower.rs:10248 still branch per-lane using scc_lane (taking the branch only in lane 0 instead of the whole wave). (The loop test at crosslane_tests.rs:1122-1142 missed this because the branch and s_cselect consume different SCC definitions.)

Please address both cases (ensure s_cbranch_scc* on an SCC in mask_sccs is consistent—unified as wave-wide nonzero or rejected rather than silently splitting the wave—and handle partial waves / active classification cleanly for complements). Non-blocking P2 notes: phi joins before an SCC data read, s_wqm_b32/b64 / *saveexec producers, and SCC escaping a whole-wave section are also not yet handled.

<!-- greyfinch-sync:Marvisak/VIctory:review:6081236920 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#pullrequestreview-6081236920). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T22:47:14Z. **Review:** CHANGES_REQUESTED --- Good catch on `s_cselect` / scalar polling loops using the SCC of bitwise lane-mask instructions. The existing test suite passes (40/40 on both RTX 5090 and WARP, with all 5 Wave32 cases running on RTX 5090 and the Wave64 case passing DXIL validation), and `crates/victory-shader/src/emit/lower.rs` stays under the 512 KiB ceiling at `523,600` bytes. However, there are two P1 semantic bugs where newly accepted shaders silently diverge from RDNA2 ISA (previously rejected with `Err(LANE_MASK)`): 1. **Partial-wave dispatch + bitwise complement/negation flips `SCC` from `1` to `0`:** In `crates/victory-shader/src/structure.rs:703-710`, entry `EXEC` is modeled as `Bool::TRUE`. Because `implies(m, Bool::TRUE)` is always true at `structure.rs:1198`, an operation like `s_not_b32 s20, vcc_lo` in the entry block marks `s20` in `self.active`. On a partial wave (e.g., 16 threads in Wave32 or 32 in Wave64) where every running lane sets `vcc`, native `s20` is `0xFFFF_0000` (`SCC = 1`), yet `lower.rs:1874` skips `mask_number` because `s20` is in `active` and runs `waveActiveBallot(!vcc)` over only the active host lanes, returning `0` and turning `SCC` into `0`. 2. **Same `SCC` read both as data and by `s_cbranch_scc*` disagrees across lanes:** If `s_and_b32 s20, vcc_lo, exec_lo` (say only lane 0 set under full `EXEC`) has its `SCC` read by `s_cselect_b32 s21, 1, 2` and then branched on by `s_cbranch_scc1` on the same SSA `SCC` value, `lower.rs:454` + `lower.rs:3648` give `s_cselect` the wave-wide bit (`1` in all lanes), while `structure.rs:1204` / `structure.rs:1368` and `lower.rs:10248` still branch per-lane using `scc_lane` (taking the branch only in lane 0 instead of the whole wave). (The loop test at `crosslane_tests.rs:1122-1142` missed this because the branch and `s_cselect` consume different `SCC` definitions.) Please address both cases (ensure `s_cbranch_scc*` on an `SCC` in `mask_sccs` is consistent—unified as wave-wide `nonzero` or rejected rather than silently splitting the wave—and handle partial waves / `active` classification cleanly for complements). Non-blocking P2 notes: phi joins before an `SCC` data read, `s_wqm_b32/b64` / `*saveexec` producers, and `SCC` escaping a whole-wave section are also not yet handled.
zzm1234560621-prog commented 2026-11-27 00:16:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zzm1234560621-prog on 2026-11-27T00:16:12Z.


Hardware verification on Intel (Xe-LPG), d9ed313 on top of 63bcca4:

cargo test -p victory-shader --lib -- crosslane --nocapture
[SUMMARY] mask operation SCC: 5 passed, 0 failed, 0 skipped
[SUMMARY] DPP8/DPP8FI: 5 passed, 0 failed, 0 skipped
[SUMMARY] ds_swizzle_b32: 6 passed, 0 failed, 0 skipped
[SUMMARY] DPP16: 18 passed, 0 failed, 0 skipped
test result: ok. 7 passed; 0 failed; 0 ignored

Full suite on the same head: 297 passed, 7 failed, 3 ignored — and every one of the seven is the set this adapter already fails on unmodified 63bcca4 (documented in #3196: three BVH tests one ULP off from this driver's reassociation, arithmetic_matches_the_hardware and the MAD signed zero which #3212 fixes, image_atomics_of_64_bits and the view-heap test which #3203 and #3178 cover, and fspx_…dot_products). So the PR adds no failure here, and the two extra passes over the 295 the baseline has are its own tests.

cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.

On the shape itself: reading the SCC of a mask-producing scalar op as data is a good catch, and it is a different question from the one I assumed on #3253 — there the missing value was the mask (s_and_b32/s_cmp writing EXEC/SCC) and I argued for materialising at the use site; here the SCC is a scalar "any lane", so it belongs at the write, where you put it. I have said so on #3253 so the two do not get confused.

No game files. AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206319590 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7206319590). Originally posted by [zzm1234560621-prog](https://github.com/zzm1234560621-prog) on 2026-11-27T00:16:12Z. --- Hardware verification on Intel (Xe-LPG), `d9ed313` on top of `63bcca4`: ``` cargo test -p victory-shader --lib -- crosslane --nocapture [SUMMARY] mask operation SCC: 5 passed, 0 failed, 0 skipped [SUMMARY] DPP8/DPP8FI: 5 passed, 0 failed, 0 skipped [SUMMARY] ds_swizzle_b32: 6 passed, 0 failed, 0 skipped [SUMMARY] DPP16: 18 passed, 0 failed, 0 skipped test result: ok. 7 passed; 0 failed; 0 ignored ``` Full suite on the same head: **297 passed, 7 failed, 3 ignored** — and every one of the seven is the set this adapter already fails on unmodified `63bcca4` (documented in #3196: three BVH tests one ULP off from this driver's reassociation, `arithmetic_matches_the_hardware` and the MAD signed zero which #3212 fixes, `image_atomics_of_64_bits` and the view-heap test which #3203 and #3178 cover, and `fspx_…dot_products`). So the PR adds **no** failure here, and the two extra passes over the 295 the baseline has are its own tests. `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. On the shape itself: reading the SCC of a mask-producing scalar op as data is a good catch, and it is a different question from the one I assumed on #3253 — there the missing value was the *mask* (`s_and_b32`/`s_cmp` writing EXEC/SCC) and I argued for materialising at the use site; here the SCC is a scalar "any lane", so it belongs at the write, where you put it. I have said so on #3253 so the two do not get confused. _No game files. AI-assisted (Claude)._
andrewpozdnakov7-jpg commented 2026-11-27 00:20:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T00:20:09Z.


I combined this exact head d9ed313 with #3402 at d1158c9 and published the tested merge and Wave64 regression.

The regression runs the two patterns in a single synthetic shader. The first true comparison is in lane 63 on iteration 2 of a bounded poll. The shader then performs the whole-wave OR and reads lane 63 after restoring EXEC. Readback must contain 0x55555557 in the 32 participating lanes and the original sentinel 7 in the other 32.

With the identical fixture, #3402 alone stops at a lane mask read as data and #3401 alone stops at a whole-wave section step the simulation does not follow. The combined branch validated and dispatched the Wave64 shader in three fresh WARP 1.0.22 processes, with all 64 words matching each time. The cross-lane and wave suites reported 18 passed. This WARP runtime skipped Wave32 dispatches. Strict clippy with default and all features and the 192-file asset-policy check passed.

The merge retains both parent commits and both sets of tests. It moves the mask-SCC helpers to keep lower.rs below the size limit. Maintainers can use the composition when ordering the two PRs. If folding the new regression into another commit, please retain the Git author or add Co-authored-by: andrewpozdnakov7-jpg.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206374420 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7206374420). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T00:20:09Z. --- I combined this exact head `d9ed313` with #3402 at `d1158c9` and published the [tested merge and Wave64 regression](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/ff810291b3c4baf339200de62988e6bc0a1c865b). The regression runs the two patterns in a single synthetic shader. The first true comparison is in lane 63 on iteration 2 of a bounded poll. The shader then performs the whole-wave OR and reads lane 63 after restoring EXEC. Readback must contain `0x55555557` in the 32 participating lanes and the original sentinel 7 in the other 32. With the identical fixture, #3402 alone stops at `a lane mask read as data` and #3401 alone stops at `a whole-wave section step the simulation does not follow`. The combined branch validated and dispatched the Wave64 shader in three fresh WARP 1.0.22 processes, with all 64 words matching each time. The cross-lane and wave suites reported 18 passed. This WARP runtime skipped Wave32 dispatches. Strict clippy with default and all features and the 192-file asset-policy check passed. The merge retains both parent commits and both sets of tests. It moves the mask-SCC helpers to keep `lower.rs` below the size limit. Maintainers can use the composition when ordering the two PRs. If folding the new regression into another commit, please retain the Git author or add `Co-authored-by: andrewpozdnakov7-jpg`.
andrewpozdnakov7-jpg commented 2026-11-27 06:56:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T06:56:49Z.


@Lyrnc 15057a5 is a follow-up directly on d9ed313 for the two blocking SCC observations.

With a 16-thread group in Wave32, the original produced SCC=0 in all 16 results after complementing VCC. The patch reconstructs the numeric mask on a partial wave and all 16 results show SCC=1. It also rejects the case where the same mask SCC is consumed as scalar data and as a branch condition, so the same SSA value cannot take different meanings. Both focused regressions and strict shader Clippy (default and all features) passed.

If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic shaders only.

I also resolved the test-file overlap and the shader file-size limit in c75cc68, which combines the two reviewed follow-ups. Both SCC regressions and both section-lane tests passed in the combined app-local WARP build.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7211994762 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7211994762). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T06:56:49Z. --- @Lyrnc [15057a5](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/15057a5b47c689bb586cab62a04d2109859f316c) is a follow-up directly on `d9ed313` for the two blocking SCC observations. With a 16-thread group in Wave32, the original produced SCC=0 in all 16 results after complementing VCC. The patch reconstructs the numeric mask on a partial wave and all 16 results show SCC=1. It also rejects the case where the same mask SCC is consumed as scalar data and as a branch condition, so the same SSA value cannot take different meanings. Both focused regressions and strict shader Clippy (default and all features) passed. If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic shaders only. I also resolved the test-file overlap and the shader file-size limit in [c75cc68](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/c75cc689ddec4bd86f94e179dfd6e540c09dc27a), which combines the two reviewed follow-ups. Both SCC regressions and both section-lane tests passed in the combined app-local WARP build.
Lyrnc commented 2026-11-27 13:01:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-27T13:01:17Z.


@andrewpozdnakov7-jpg thanks, taken as is: 15057a5 is now on this branch with your authorship, as a fast-forward of d9ed313. On an RTX 5080 (610.88), both mask-SCC tests pass (mask_operation_scc_read_as_data_is_the_waves_any_on_gpu and wave64_mask_operation_scc_reads_both_dwords), and cargo clippy -p victory-shader --lib --tests -- -D warnings is clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218959335 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7218959335). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-27T13:01:17Z. --- @andrewpozdnakov7-jpg thanks, taken as is: `15057a5` is now on this branch with your authorship, as a fast-forward of `d9ed313`. On an RTX 5080 (610.88), both mask-SCC tests pass (`mask_operation_scc_read_as_data_is_the_waves_any_on_gpu` and `wave64_mask_operation_scc_reads_both_dwords`), and `cargo clippy -p victory-shader --lib --tests -- -D warnings` is clean.
ColorMeBoom commented 2026-11-27 13:33:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T13:33:23Z.


AMD run: RX 5700 XT (RDNA1, 32–64 lanes, so the 64-lane cases run instead of being "lowered and validated only"), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Each tree was merged onto main 63bcca4 and run on the native adapter (VICTORY_WARP unset), no game files. Head 15057a5.

  • wave64_mask_operation_scc_reads_both_dwords dispatched and passed on 64-lane hardware, both cases (lanes above 40 and above 63, which put the mask in the high dword). The RTX 5080 run above is 32-lane only, so this is the first time it ran rather than only being validated.
  • mask_operation_scc_read_as_data_is_the_waves_any_on_gpu: 5 passed, 0 failed. complement_sets_mask_scc_even_in_a_partial_wave and a_mask_scc_used_as_data_and_branch_is_rejected pass.
  • crosslane: 9 passed, 0 failed. DPP16 18/18, DPP8/DPP8FI 5/5, ds_swizzle_b32 6/6.
  • Full victory-shader suite (--features host): 306 passed, 0 failed, 3 ignored. cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.
  • With #3402: @andrewpozdnakov7-jpg's merge ff81029 (this PR at d9ed313 + #3402 at d1158c9) passes too: 308 passed, 0 failed, and both 64-lane tests dispatch. Results are on #3402.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7219634476 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7219634476). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-27T13:33:23Z. --- **AMD run: RX 5700 XT** (RDNA1, 32–64 lanes, so the 64-lane cases run instead of being "lowered and validated only"), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Each tree was merged onto `main` `63bcca4` and run on the native adapter (`VICTORY_WARP` unset), no game files. Head `15057a5`. - `wave64_mask_operation_scc_reads_both_dwords` **dispatched and passed on 64-lane hardware**, both cases (lanes above 40 and above 63, which put the mask in the high dword). The RTX 5080 run above is 32-lane only, so this is the first time it ran rather than only being validated. - `mask_operation_scc_read_as_data_is_the_waves_any_on_gpu`: **5 passed, 0 failed**. `complement_sets_mask_scc_even_in_a_partial_wave` and `a_mask_scc_used_as_data_and_branch_is_rejected` pass. - `crosslane`: **9 passed, 0 failed**. DPP16 18/18, DPP8/DPP8FI 5/5, `ds_swizzle_b32` 6/6. - Full `victory-shader` suite (`--features host`): **306 passed, 0 failed, 3 ignored**. `cargo clippy -p victory-shader --all-targets --features host -- -D warnings`: clean. - With #3402: @andrewpozdnakov7-jpg's merge `ff81029` (this PR at `d9ed313` + #3402 at `d1158c9`) passes too: **308 passed, 0 failed**, and both 64-lane tests dispatch. Results are on #3402. AI use: Claude Code (Claude Opus 5.5).
kilolimaVI commented 2026-11-28 22:12:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T22:12:26Z.


Verified on AMD Radeon 780M (RDNA3, wave32 + wave64, Windows 11) at 15057a5, before/after with this PR's four new tests:

test main 63bcca4 + this PR's tests 15057a5
mask_operation_scc_read_as_data_is_the_waves_any_on_gpu refused: "a lane mask read as data" pass (5/5 cases)
wave64_mask_operation_scc_reads_both_dwords refused: "a lane mask read as data" pass, dispatched on 64-lane host waves
complement_sets_mask_scc_even_in_a_partial_wave refused: "a lane mask read as data" pass (16-thread group)
a_mask_scc_used_as_data_and_branch_is_rejected fails (different refusal) pass

So 4/4 wrong → 0, and all 9 emit::crosslane_tests pass. The wave64 case was only lowered and validated on the RTX 5090; here it ran natively on 64 lanes and both dwords gave the right SCC (lanes above 40 → 1, above 63 → 2). Both of fuzeofficlal's P1 cases are covered on AMD: the partial-wave complement keeps SCC = 1, and an SCC read as both data and branch is refused instead of splitting the wave.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246571129 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7246571129). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T22:12:26Z. --- Verified on AMD Radeon 780M (RDNA3, wave32 + wave64, Windows 11) at `15057a5`, before/after with this PR's four new tests: | test | main `63bcca4` + this PR's tests | `15057a5` | |---|---|---| | `mask_operation_scc_read_as_data_is_the_waves_any_on_gpu` | refused: "a lane mask read as data" | pass (5/5 cases) | | `wave64_mask_operation_scc_reads_both_dwords` | refused: "a lane mask read as data" | pass, dispatched on 64-lane host waves | | `complement_sets_mask_scc_even_in_a_partial_wave` | refused: "a lane mask read as data" | pass (16-thread group) | | `a_mask_scc_used_as_data_and_branch_is_rejected` | fails (different refusal) | pass | So 4/4 wrong → 0, and all 9 `emit::crosslane_tests` pass. The wave64 case was only lowered and validated on the RTX 5090; here it ran natively on 64 lanes and both dwords gave the right SCC (lanes above 40 → 1, above 63 → 2). Both of fuzeofficlal's P1 cases are covered on AMD: the partial-wave complement keeps SCC = 1, and an SCC read as both data and branch is refused instead of splitting the wave. AI-assisted (Claude).
kilolimaVI commented 2026-11-29 13:35:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T13:35:05Z.


Follow-up to my 780M run above: this PR and #385 both change the console-lanes decision in Lower::new, so they conflict. #385 moves the condition into phi::mask_uses_console_lanes, this PR adds console_lanes |= !mask_sccs.is_empty() after it. Resolved by keeping #385's call and adding this PR's line right after it, plus both let lines above (rows from #2398, mask_sccs from here).

Branch kilolimaVI/VIctory integration/shader-10 (9dd3e7c) = main + #3097, #2999, #3617, #3717, #1315, #3716, #2398, #385, #1262 and this. On the Radeon 780M:

  • this PR's mask-SCC tests: 5/5 (wave64 case on 64-lane hardware waves)
  • #385's phi tests: 6/6 (three of them skip on WARP, run on hardware here)
  • all 9 emit::crosslane_tests, whole victory-shader lib 354 passed / 0 failed / 3 ignored, victory-gpu (diagnostics) 246 passed, rest of the workspace, both clippy configurations and the asset policy pass

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7256648237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7256648237). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-29T13:35:05Z. --- Follow-up to my 780M run above: this PR and #385 both change the console-lanes decision in `Lower::new`, so they conflict. #385 moves the condition into `phi::mask_uses_console_lanes`, this PR adds `console_lanes |= !mask_sccs.is_empty()` after it. Resolved by keeping #385's call and adding this PR's line right after it, plus both `let` lines above (`rows` from #2398, `mask_sccs` from here). Branch `kilolimaVI/VIctory` `integration/shader-10` (`9dd3e7c`) = main + #3097, #2999, #3617, #3717, #1315, #3716, #2398, #385, #1262 and this. On the Radeon 780M: - this PR's mask-SCC tests: 5/5 (wave64 case on 64-lane hardware waves) - #385's phi tests: 6/6 (three of them skip on WARP, run on hardware here) - all 9 `emit::crosslane_tests`, whole victory-shader lib 354 passed / 0 failed / 3 ignored, victory-gpu (diagnostics) 246 passed, rest of the workspace, both clippy configurations and the asset policy pass AI-assisted (Claude).
fiestorra commented 2026-11-29 14:12:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-29T14:12:23Z.


A corpus measurement for this PR: the four "a lane mask read as data" refusals are unchanged with it applied

I reran the shader census on kilolimaVI/VIctory integration/shader-10 (9dd3e7c3), which has this PR in it, with the same command and counting rule I posted in #201:

victory translate <shaders.rpf> --validate --list --jobs 10
main 63bcca43 integration/shader-10
a lane mask read as data 4 4

Same four programs, same offsets:

0xbe5c0f9 bvh_skinning:CSComputeSkinningPedBlendShapes_1c34db0a_Wrapped
0xbe646f6 bvh_skinning:CSComputeSkinningPedBlendShapesSecMotion_1c34db0a_Wrapped
0xbe8bb1f bvh_skinning:CSComputeSkinningPedBlendShapesVelocity_1c34db0a_Wrapped
0xbe95c7b bvh_skinning:CSComputeSkinningPedBlendShapesSecMotionVelocity_1c34db0a_Wrapped

So the SCC-of-a-lane-mask-operation shape this PR fixes is not the shape these four hit: they consume the mask itself as data. That is said as information, not as a complaint about the PR — it just means these four are still on the table for someone, and picking this PR expecting them to go is not going to work.

What it does not say: anything about the 780M, wave32, wave64 or the tests. My number is a translation census on one machine.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7257122953 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7257122953). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-29T14:12:23Z. --- **A corpus measurement for this PR: the four "a lane mask read as data" refusals are unchanged with it applied** I reran the shader census on `kilolimaVI/VIctory` `integration/shader-10` (`9dd3e7c3`), which has this PR in it, with the same command and counting rule I posted in #201: ``` victory translate <shaders.rpf> --validate --list --jobs 10 ``` | | `main` `63bcca43` | `integration/shader-10` | |---|---|---| | a lane mask read as data | 4 | **4** | Same four programs, same offsets: ``` 0xbe5c0f9 bvh_skinning:CSComputeSkinningPedBlendShapes_1c34db0a_Wrapped 0xbe646f6 bvh_skinning:CSComputeSkinningPedBlendShapesSecMotion_1c34db0a_Wrapped 0xbe8bb1f bvh_skinning:CSComputeSkinningPedBlendShapesVelocity_1c34db0a_Wrapped 0xbe95c7b bvh_skinning:CSComputeSkinningPedBlendShapesSecMotionVelocity_1c34db0a_Wrapped ``` So the SCC-of-a-lane-mask-operation shape this PR fixes is not the shape these four hit: they consume the mask itself as data. That is said as information, not as a complaint about the PR — it just means these four are still on the table for someone, and picking this PR expecting them to go is not going to work. What it does not say: anything about the 780M, wave32, wave64 or the tests. My number is a translation census on one machine. Written with an AI assistant.
ColorMeBoom commented 2026-11-29 18:48:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-29T18:48:22Z.


@kilolimaVI RDNA1 row for integration/shader-10 (9dd3e7c): RX 5700 XT (Navi 10, wave32 + wave64, driver 32.0.21045.29003), Windows 11 26200.

  • Whole victory-shader --lib --features host: 354 passed, 0 failed, 3 ignored. That's the same count as on your 780M, and no GPU test was skipped for a missing wave size, since this card runs both.
  • I couldn't get a clean run of the rest of the workspace here. Windows' Application Control blocked a build helper (tracing_attributes) partway through, so those numbers would be incomplete, not failures.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7260772656 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3401#issuecomment-7260772656). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-29T18:48:22Z. --- @kilolimaVI RDNA1 row for `integration/shader-10` (`9dd3e7c`): RX 5700 XT (Navi 10, wave32 + wave64, driver 32.0.21045.29003), Windows 11 26200. - Whole `victory-shader --lib --features host`: **354 passed, 0 failed, 3 ignored**. That's the same count as on your 780M, and no GPU test was skipped for a missing wave size, since this card runs both. - I couldn't get a clean run of the rest of the workspace here. Windows' Application Control blocked a build helper (`tracing_attributes`) partway through, so those numbers would be incomplete, not failures. AI use: Claude Code (Claude Opus 5.5).
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/3401:upstream-pr/3401'
git switch 'upstream-pr/3401'

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