Shaders: wave32 EXEC moves through _b64 scalar ops keep the mask #3924

Open
kotekompotek wants to merge 1 commit from upstream-pr/3924 into main
kotekompotek commented 2026-12-01 03:24:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-12-01T03:24:02Z.


Summary

Wave32 pixel prologues save, widen to whole quads and restore EXEC with 64-bit scalar moves (s_mov_b64, s_wqm_b64) even though only EXEC's low dword holds lanes. Lanes::sop only recognized the lane-width suffix (_b32 in wave32), so the moved mask classified as Atom::Opaque — every guarded vector instruction then depended on an opaque mask and the pixel shaders that use this prologue failed to translate (an opaque lane mask is not supported).

The low dword of a 64-bit bitwise operation is the same operation on the low dwords, so in wave32 those are lane-mask operations too; their high dword has no lanes. sop now also tries _b64 when wave64 is false.

Found on the GTA VI boot path: six pixel shaders (including the glyph and loading-art shaders) hit exactly this pattern at their prologue and dropped every draw that used them.

Test plan

  • cargo test -p victory-shader structure — 14 passed including the new wave32_b64_exec_copies_carry_the_mask fixture (s_mov_b64/s_wqm_b64 EXEC save+restore keeps the vector move's guard).
  • GTA VI run on GTX 1050 (driver-standalone build): the six previously dropped pixel shaders translate and their draws execute.

AI-assisted change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5578336055 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3924). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-12-01T03:24:02Z. --- ## Summary Wave32 pixel prologues save, widen to whole quads and restore EXEC with 64-bit scalar moves (`s_mov_b64`, `s_wqm_b64`) even though only EXEC's low dword holds lanes. `Lanes::sop` only recognized the lane-width suffix (`_b32` in wave32), so the moved mask classified as `Atom::Opaque` — every guarded vector instruction then depended on an opaque mask and the pixel shaders that use this prologue failed to translate (`an opaque lane mask is not supported`). The low dword of a 64-bit bitwise operation is the same operation on the low dwords, so in wave32 those are lane-mask operations too; their high dword has no lanes. `sop` now also tries `_b64` when `wave64` is false. Found on the GTA VI boot path: six pixel shaders (including the glyph and loading-art shaders) hit exactly this pattern at their prologue and dropped every draw that used them. #### Test plan - [x] `cargo test -p victory-shader structure` — 14 passed including the new `wave32_b64_exec_copies_carry_the_mask` fixture (`s_mov_b64`/`s_wqm_b64` EXEC save+restore keeps the vector move's guard). - [x] GTA VI run on GTX 1050 (driver-standalone build): the six previously dropped pixel shaders translate and their draws execute. AI-assisted change.
passerbyyhx commented 2026-12-01 12:30:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T12:30:27Z.


Compared 37db5538 with parent 63bcca43 using a synthetic Wave32 pixel shader on an RTX 4090 Laptop GPU and WARP. A full-screen triangle covered a 4×2 RGBA32F target. The shader selected x < 2, saved EXEC, widened to whole quads and restored EXEC.

On the PR, both the b32 control and the b64 sequence produced the expected eight pixels on both adapters. In each row, every channel was 1 for the first two pixels and 0 for the last two. The parent passed the b32 control on both adapters. For b64, translation stopped at offset 32 with an opaque lane mask, before any draw was submitted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7311229471 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3924#issuecomment-7311229471). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-12-01T12:30:27Z. --- Compared `37db5538` with parent `63bcca43` using a synthetic Wave32 pixel shader on an RTX 4090 Laptop GPU and WARP. A full-screen triangle covered a 4×2 RGBA32F target. The shader selected `x < 2`, saved EXEC, widened to whole quads and restored EXEC. On the PR, both the b32 control and the b64 sequence produced the expected eight pixels on both adapters. In each row, every channel was 1 for the first two pixels and 0 for the last two. The parent passed the b32 control on both adapters. For b64, translation stopped at offset 32 with `an opaque lane mask`, before any draw was submitted.
cloph-dsp commented 2026-12-01 15:16:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-12-01T15:16:18Z.


Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree, per-worktree CARGO_TARGET_DIR.

Base 63bcca43c6a00a758510398fa43096ce7e4f7df0, head 37db5538. git diff --numstat → crates/victory-shader/src/structure.rs 54/2 (single file).

One test is added and its name is new on the base — git grep -F wave32_b64_exec_copies_carry_the_mask 63bcca43 -- . returns no match:
structure::tests::wave32_b64_exec_copies_carry_the_mask. (The data_loaded_where_a_mask_was_is_no_mask case visible in the same hunk is context, not added.)

git diff --check "63bcca43..37db5538" → no output, exit 0.

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3924'
cargo test --locked -p victory-shader --lib -- structure::tests::wave32_b64_exec_copies_carry_the_mask --exact --test-threads=1 --quiet

Result: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out.

The test builds a synthetic wave32 block with EXEC set and checks the mask survives the _b64 scalar moves; no title shader bytes, no device, GPU/driver N/A. No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7315630923 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3924#issuecomment-7315630923). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T15:16:18Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree, per-worktree CARGO_TARGET_DIR. Base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, head `37db5538`. `git diff --numstat` → crates/victory-shader/src/structure.rs 54/2 (single file). One test is added and its name is new on the base — `git grep -F wave32_b64_exec_copies_carry_the_mask 63bcca43 -- .` returns no match: `structure::tests::wave32_b64_exec_copies_carry_the_mask`. (The `data_loaded_where_a_mask_was_is_no_mask` case visible in the same hunk is context, not added.) `git diff --check "63bcca43..37db5538"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3924' cargo test --locked -p victory-shader --lib -- structure::tests::wave32_b64_exec_copies_carry_the_mask --exact --test-threads=1 --quiet ``` Result: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out`. The test builds a synthetic wave32 block with EXEC set and checks the mask survives the `_b64` scalar moves; no title shader bytes, no device, GPU/driver N/A. No game data.
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/3924:upstream-pr/3924'
git switch 'upstream-pr/3924'

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