Shaders: mask lane selectors to the console wave width #3917

Open
faycalbaklouti wants to merge 2 commits from upstream-pr/3917 into main
faycalbaklouti commented 2026-11-30 23:01:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by faycalbaklouti on 2026-11-30T23:01:54Z.


What

Use the low five selector bits for guest Wave32 and the low six for guest Wave64 in read-lane and write-lane lowering, resource tracing, and scalar spill recovery. A write to lane 32 must overwrite lane 0 in Wave32, but not in Wave64. The new test exercises both cases using synthetic instructions.

How it was tested

Windows MSVC target under Wine: cargo xwin test --locked --target x86_64-pc-windows-msvc -p <package> --lib --no-fail-fast for each suite, adding -- --exact <name> --nocapture --test-threads=1 for the regressions. Compared 3aeb893dcd with clean base 63bcca43c6.

victory-shader library suite:
Head (exit 101):
test result: FAILED. 215 passed; 88 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.39s
Clean base (exit 101):
test result: FAILED. 214 passed; 88 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.34s
Exact test: structure::tests::constant_lane_selects_the_low_bits_of_the_guest_width
Head (exit 0):
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s
Clean base (exit 0):
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s
Base with only the test applied (exit 101):
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s

The same 88 shader tests failed by name and diagnostic on head and base: the CPU-only Wine runner has no D3D12 Shader Model 6.6 device or WARP fallback. Zero matches on the clean base are expected for newly added tests. With only the test hunks applied to base, the regression assertions failed as expected.

Both workspace Clippy modes (default and all features, with -D warnings) exited 0 on head and base. The Windows-target workspace test under Wine exited 101 on both, stopping in victory-hle: modules::net::tests::only_loopback_is_reachable hit a missing WSAConnectByList export on the isolated runner, and modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied did not observe the expected NTFS hard-link limit. Native Windows CI remains the final gate.


Radicle project hub (open-source porting and preservation history): https://radicle.network/nodes/rosa.radicle.network/rad:z3rqQw7796wMbgj8RszExtWR4wMSE
Live development stream: https://vdo.ninja/?view=gta6rtx4090live1080p60

<!-- greyfinch-sync:Marvisak/VIctory:issue:5575360674 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3917). Originally posted by [faycalbaklouti](https://github.com/faycalbaklouti) on 2026-11-30T23:01:54Z. --- ## What Use the low five selector bits for guest Wave32 and the low six for guest Wave64 in read-lane and write-lane lowering, resource tracing, and scalar spill recovery. A write to lane 32 must overwrite lane 0 in Wave32, but not in Wave64. The new test exercises both cases using synthetic instructions. ## How it was tested Windows MSVC target under Wine: `cargo xwin test --locked --target x86_64-pc-windows-msvc -p <package> --lib --no-fail-fast` for each suite, adding `-- --exact <name> --nocapture --test-threads=1` for the regressions. Compared `3aeb893dcd` with clean base `63bcca43c6`. ```text victory-shader library suite: Head (exit 101): test result: FAILED. 215 passed; 88 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.39s Clean base (exit 101): test result: FAILED. 214 passed; 88 failed; 3 ignored; 0 measured; 0 filtered out; finished in 1.34s Exact test: structure::tests::constant_lane_selects_the_low_bits_of_the_guest_width Head (exit 0): test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s Clean base (exit 0): test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s Base with only the test applied (exit 101): test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 305 filtered out; finished in 0.00s ``` The same 88 shader tests failed by name and diagnostic on head and base: the CPU-only Wine runner has no D3D12 Shader Model 6.6 device or WARP fallback. Zero matches on the clean base are expected for newly added tests. With only the test hunks applied to base, the regression assertions failed as expected. Both workspace Clippy modes (default and all features, with `-D warnings`) exited 0 on head and base. The Windows-target workspace test under Wine exited 101 on both, stopping in `victory-hle`: `modules::net::tests::only_loopback_is_reachable` hit a missing `WSAConnectByList` export on the isolated runner, and `modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied` did not observe the expected NTFS hard-link limit. Native Windows CI remains the final gate. --- **Radicle project hub (open-source porting and preservation history):** https://radicle.network/nodes/rosa.radicle.network/rad:z3rqQw7796wMbgj8RszExtWR4wMSE **Live development stream:** https://vdo.ninja/?view=gta6rtx4090live1080p60
passerbyyhx commented 2026-11-30 23:42:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-30T23:42:37Z.


Native Windows MSVC comparison of 3aeb893dcdd5cb0db10f389b95a01c8e5ddc3ac3 and parent 63bcca43c6a00a758510398fa43096ce7e4f7df0:

  • On RTX 4090 Laptop, I dispatched the same guest shader with 11 dynamic Wave32 selectors and checked every lane after both v_readlane_b32 and v_writelane_b32. The parent wrote the correct target in 4/11 cases. For 32, 33, 63, 64, 65, 0x8000001f and 0xffffffff, no lane received the marker. The head wrote exactly one correct lane in all 11. Reads were correct on both revisions on this GPU.
  • Disassembly of the DXIL supplied to the PSO showed both operations using & 31 (Wave32) or & 63 (Wave64) on the head. The parent used the raw selector. The RTX rejected fixed Wave64. Intel UHD reported 16/16 and WARP 4/4. Both rejected fixed Wave32 and Wave64 before dispatch on both revisions, so there is no native Wave64 readback in this comparison.
  • The independent CPU resource tracer selected the expected descriptor table and byte offset in 6/10 cases on the parent and 10/10 on the head, with the spill-recovery result omitted from its inputs. I sent the CPU-only regression as a test-only PR to your branch.

For the unmodified victory-shader library, all 305 common tests had the same status on the two revisions. The added structure test passed. The unfiltered process terminated on the same heap-mark test in both builds, so I restarted tests by module and accounted for every registered name:

Native stock tests Parent Head
Passed 298 299
Rust test failures 3 3
Ignored 3 3
Windows process access violation 1 1

Eleven passing tests on each revision reported skipping all or part of a check. The three common Rust failures were the two emit::stride_tests about heap-buffer stride/empty views and gathers_at_a_level_match_the_hardware. heap_direct_texture_reads_mark_their_heap_index also exited with 0xC0000005 when run by itself on both revisions. The same test was previously reported on NVIDIA main.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7295437391 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3917#issuecomment-7295437391). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-30T23:42:37Z. --- Native Windows MSVC comparison of `3aeb893dcdd5cb0db10f389b95a01c8e5ddc3ac3` and parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`: - On RTX 4090 Laptop, I dispatched the same guest shader with 11 dynamic Wave32 selectors and checked every lane after both `v_readlane_b32` and `v_writelane_b32`. The parent wrote the correct target in 4/11 cases. For 32, 33, 63, 64, 65, `0x8000001f` and `0xffffffff`, no lane received the marker. The head wrote exactly one correct lane in all 11. Reads were correct on both revisions on this GPU. - Disassembly of the DXIL supplied to the PSO showed both operations using `& 31` (Wave32) or `& 63` (Wave64) on the head. The parent used the raw selector. The RTX rejected fixed Wave64. Intel UHD reported 16/16 and WARP 4/4. Both rejected fixed Wave32 and Wave64 before dispatch on both revisions, so there is no native Wave64 readback in this comparison. - The independent CPU resource tracer selected the expected descriptor table and byte offset in 6/10 cases on the parent and 10/10 on the head, with the spill-recovery result omitted from its inputs. I sent the CPU-only regression as [a test-only PR to your branch](https://github.com/faycalbaklouti/VIctory/pull/1). For the unmodified `victory-shader` library, all 305 common tests had the same status on the two revisions. The added structure test passed. The unfiltered process terminated on the same heap-mark test in both builds, so I restarted tests by module and accounted for every registered name: | Native stock tests | Parent | Head | |---|---:|---:| | Passed | 298 | 299 | | Rust test failures | 3 | 3 | | Ignored | 3 | 3 | | Windows process access violation | 1 | 1 | Eleven passing tests on each revision reported skipping all or part of a check. The three common Rust failures were the two `emit::stride_tests` about heap-buffer stride/empty views and `gathers_at_a_level_match_the_hardware`. `heap_direct_texture_reads_mark_their_heap_index` also exited with `0xC0000005` when run by itself on both revisions. The same test was previously [reported on NVIDIA main](https://github.com/Marvisak/VIctory/issues/2220#issuecomment-7170692046).
faycalbaklouti commented 2026-12-01 00:54:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by faycalbaklouti on 2026-12-01T00:54:21Z.


Thanks, @passerbyyhx, for the native check and the tracer test. I ran your test here too (Windows MSVC target under Wine): with only the test on 63bcca43 it fails at resource.rs:2394 (wave64=false, writes=0,32, read=0), and on this branch it passes. I've pulled your commit into this PR as-is, so it keeps your authorship.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7296872982 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3917#issuecomment-7296872982). Originally posted by [faycalbaklouti](https://github.com/faycalbaklouti) on 2026-12-01T00:54:21Z. --- Thanks, @passerbyyhx, for the native check and the tracer test. I ran your test here too (Windows MSVC target under Wine): with only the test on `63bcca43` it fails at `resource.rs:2394` (`wave64=false, writes=0,32, read=0`), and on this branch it passes. I've pulled your commit into this PR as-is, so it keeps your authorship.
cloph-dsp commented 2026-12-01 13:25:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-12-01T13:25:56Z.


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

Base 63bcca43c6a00a758510398fa43096ce7e4f7df0, head ab1ad6ff34a66d956fdd4d398d3d1ad4fd6c1431. git diff --numstat → 3 files +67/-5.

Both tests are new on the base:

git grep -F spilled_table_addresses_use_the_guest_wave_width 63bcca43 -- .
git grep -F constant_lane_selects_the_low_bits_of_the_guest_width 63bcca43 -- .

→ no match, exit 1 for each.

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

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

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

Both tests build the wave/lane inputs themselves; no title data, no GPU device, GPU/driver N/A. No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7312610482 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3917#issuecomment-7312610482). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T13:25:56Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree. Base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, head `ab1ad6ff34a66d956fdd4d398d3d1ad4fd6c1431`. `git diff --numstat` → 3 files +67/-5. Both tests are new on the base: ``` git grep -F spilled_table_addresses_use_the_guest_wave_width 63bcca43 -- . git grep -F constant_lane_selects_the_low_bits_of_the_guest_width 63bcca43 -- . ``` → no match, exit 1 for each. `git diff --check "63bcca43..ab1ad6ff"` → no output, exit 0. ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3917' cargo test --locked -p victory-shader --lib -- resource::tests::spilled_table_addresses_use_the_guest_wave_width --exact --test-threads=1 --quiet cargo test --locked -p victory-shader --lib -- structure::tests::constant_lane_selects_the_low_bits_of_the_guest_width --exact --test-threads=1 --quiet ``` Result, each: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 306 filtered out`. Both tests build the wave/lane inputs themselves; no title data, no GPU 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/3917:upstream-pr/3917'
git switch 'upstream-pr/3917'

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