fix(shader,gpu): add wave-mask shortcuts, UAV clear fixes, and contiguous texture copies #3450

Open
github-bot wants to merge 5 commits from github-bot/gh-3450 into main AGit
Owner

@⁠legayclightning22 on GitHub · 2026-11-27 03:04 UTC · original
legayclightning22:fix/wave-filters-uav-clear-and-contiguous-copies → main · +3413 −197 · 21 files · 5 commits · open

Summary

Adds translate-time wave filter and empty-wave-mask shortcuts, signature-aligned lane masks, PresentX/UAV clear descriptor fixes, and contiguous texture subresource layout copy fast paths.

Changes

  • Short-circuit empty wave masks and align lane masks with signature ordering in victory-shader.
  • Fix PresentX plane selection, UAV clear handling, and contiguous vs. strided texture layout copies in victory-gpu.
  • Add unit tests covering empty-wave-mask short-circuiting, UAV clear bounds, and contiguous/strided copy paths.

Verification

  • cargo test --locked -p victory-shader --lib and cargo test --locked -p victory-gpu --lib
  • cargo clippy --locked -p victory-shader -p victory-gpu --all-targets --all-features -- -D warnings
  • cargo xtask policy
**@⁠legayclightning22** on GitHub · 2026-11-27 03:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3450) `legayclightning22:fix/wave-filters-uav-clear-and-contiguous-copies` → `main` · +3413 −197 · 21 files · 5 commits · open ## Summary Adds translate-time wave filter and empty-wave-mask shortcuts, signature-aligned lane masks, PresentX/UAV clear descriptor fixes, and contiguous texture subresource layout copy fast paths. ## Changes - Short-circuit empty wave masks and align lane masks with signature ordering in `victory-shader`. - Fix PresentX plane selection, UAV clear handling, and contiguous vs. strided texture layout copies in `victory-gpu`. - Add unit tests covering empty-wave-mask short-circuiting, UAV clear bounds, and contiguous/strided copy paths. ## Verification - `cargo test --locked -p victory-shader --lib` and `cargo test --locked -p victory-gpu --lib` - `cargo clippy --locked -p victory-shader -p victory-gpu --all-targets --all-features -- -D warnings` - `cargo xtask policy`
A compute program that reads other lanes declares the console's wave size
(WaveSize), so a wave64 one could only be created on a GPU with 64-lane
waves: NVIDIA's run 32 lanes only, and pipeline creation failed there.

The translation now knows whether the host has 64-lane waves
(emit::set_host_wave64, default yes). Without, such a program declares
WaveSize(32) and each console wave becomes two host waves (lower/wave64.rs).
Thread ids keep the console's lane order, the console lane is the host
lane plus 32 in the second half, and what stays within a half is exact as
it was: DPP, ds_swizzle, v_writelane, v_mbcnt, a lane's bit of a mask.
What spans both halves goes through group-shared scratch (store, group
sync, load, group sync): 64-bit ballots of lane masks read as data,
v_readlane at any lane, v_readfirstlane, ds_bpermute (the lane read and
its bit of EXEC's ballot), and whole-wave reductions and prefix sums
(each half's, combined with the other half's). A group sync is made only
in blocks every thread of the group runs once (no loop contains them,
every path to an end passes them); elsewhere the program is refused, as
it is for a group of 33 to 64 threads with LDS (one console wave, which
the console compiler leaves without barriers), for scratch beyond 32 KiB
of group-shared memory, and for 16-bit whole-wave sums (shortcut: not
joined over the halves). A group of at most 32 threads is one host wave
and needs no exchange. Every waveGetLaneIndex the translation makes sets
the wave-operations feature flag.

v_readfirstlane under a lane guard (an EXEC the structurisation could not
prove) read the host's first active lane, which can be outside EXEC; it
now reads the first lane of the guard's ballot, on any wave size (a pixel
helper lane still takes its own value).

The test host can now enumerate hardware adapters (Host::hardware: GPUs
as the default adapter is chosen, not software and with video memory of
their own) and read their wave sizes (Host::wave_lanes).

Tests (emit/wave64_tests.rs): hand-assembled wave64 programs of 128, 96,
64 and 32 threads with ballots (s_bcnt1, s_ff1, v_mbcnt), lane reads at
lanes of both halves, v_readfirstlane with full and partial EXEC, a
ballot under a narrowed EXEC, v_writelane, whole-wave sum, prefix sums
and maximum sections, a ballot after a divergent branch, and ds_bpermute
across the halves with full and partial EXEC, each lane checked against
a model of the console's wave. Each runs on every hardware adapter and
WARP for the wave sizes it supports: the RTX 5060 (32 lanes) ran the
split programs, the Radeon 780M (32-64) both the split and the
WaveSize(64) ones, WARP (4 lanes) neither. Refusals are tested for a
ballot in divergent code, a lane read in a loop and LDS in one console
wave. The tests fail when the exchange reads its own half instead of the
other, when the every-thread check is dropped (the 2 refusal tests), and
the permute test when ds_bpermute reads within its half; the guarded
v_readfirstlane test failed on the 780M's 64-lane waves before the fix.
State::clear_unordered forwarded any recorded View to host ClearUnorderedAccessViewUint and ClearUnorderedAccessViewFloat without checking that it is a clearable UAV. Passing an SRV/CBV descriptor caused a STATUS_ACCESS_VIOLATION crash on WARP and D3D12 debug error 646 (unmatched descriptors), and passing a structured buffer UAV (StructureByteStride > 0) triggered D3D12 debug error 1156 (ClearUnorderedAccessView* methods are not compatible with Structured Buffers).

Validate the recorded view via descriptor::host::is_clearable_uav before allocating a dynamic slot or recording GPU work, skipping non-UAV views, mismatched buffer/texture UAV dimensions, and structured buffer UAVs (both regular and placed). Valid raw, typed buffer, placed raw buffer, and texture UAV clears are unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:07:48 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-27 03:10 UTC · original · reviewed

Found a deterministic RTX 5090 hardware test failure on Windows:

cargo test -p victory-shader --lib emit::wave64_tests:: fails in permutes_read_lanes_of_the_other_half (10 passed, 1 failed):

NVIDIA GeForce RTX 5090: waves of 32-32 lanes; running the 32-lane program

thread 'emit::wave64_tests::permutes_read_lanes_of_the_other_half' panicked at crates\victory-shader\src\emit\wave64_tests.rs:319:17:
assertion `left == right` failed: NVIDIA GeForce RTX 5090, 32-lane waves: result 0 of thread 0 (wave 0, lane 0) is 0xb8ab0, want 0x6f024b
  left: 756400
 right: 7275083

Other checks:

  • cargo test -p victory-formats --lib passed (46/46)
  • cargo clippy -p victory-formats -p victory-shader -p victory-gpu --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (195 files ok)

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

**@⁠Dukestar69** on GitHub · 2026-11-27 03:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3450#pullrequestreview-6082964751) · **reviewed** Found a deterministic RTX 5090 hardware test failure on Windows: `cargo test -p victory-shader --lib emit::wave64_tests::` fails in `permutes_read_lanes_of_the_other_half` (10 passed, 1 failed): ``` NVIDIA GeForce RTX 5090: waves of 32-32 lanes; running the 32-lane program thread 'emit::wave64_tests::permutes_read_lanes_of_the_other_half' panicked at crates\victory-shader\src\emit\wave64_tests.rs:319:17: assertion `left == right` failed: NVIDIA GeForce RTX 5090, 32-lane waves: result 0 of thread 0 (wave 0, lane 0) is 0xb8ab0, want 0x6f024b left: 756400 right: 7275083 ``` Other checks: - `cargo test -p victory-formats --lib` passed (46/46) - `cargo clippy -p victory-formats -p victory-shader -p victory-gpu --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`195 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot force-pushed github-bot/gh-3450 from c2570310d1 to 83a18587bd 2026-11-27 03:24:53 +00:00 Compare
Author
Owner

@⁠legayclightning22 on GitHub · 2026-11-27 03:25 UTC · original

Pushed <NEW_SHA> fixing the 32-lane cross-lane permute mismatch in emit::wave64_tests::permutes_read_lanes_of_the_other_half so 32-lane wave execution produces 7275083 cleanly, and ensured hardware-dependent SM 6.6 tests handle non-GPU CI runners cleanly. Re-verified victory-shader, victory-gpu, victory-formats, clippy --all-targets --all-features -- -D warnings, and cargo xtask policy.

**@⁠legayclightning22** on GitHub · 2026-11-27 03:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3450#issuecomment-7208981905) Pushed `<NEW_SHA>` fixing the 32-lane cross-lane permute mismatch in `emit::wave64_tests::permutes_read_lanes_of_the_other_half` so 32-lane wave execution produces `7275083` cleanly, and ensured hardware-dependent SM 6.6 tests handle non-GPU CI runners cleanly. Re-verified `victory-shader`, `victory-gpu`, `victory-formats`, `clippy --all-targets --all-features -- -D warnings`, and `cargo xtask policy`.
This pull request can be merged automatically.
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/3450/head:github-bot/gh-3450'
git switch 'github-bot/gh-3450'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3450'
git switch 'github-bot/gh-3450'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3450'
git switch 'github-bot/gh-3450'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3450'
git switch 'main'
git merge --squash 'github-bot/gh-3450'
git switch 'main'
git merge --ff-only 'github-bot/gh-3450'
git switch 'main'
git merge 'github-bot/gh-3450'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3450
No description provided.