victory-shader: support multi-wave and LDS Wave64 compute shaders on … #221
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!221
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-221"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@spook40 on GitHub · 2026-11-26 02:57 UTC · original
spook40:fix/wave64-lds-multiwave-149→main· +94 −21 · 3 files · 1 commits · openCloses #149
Summary
Enables Wave64 compute shaders that use LDS (
s.lds_dwords > 0) and/or span multiple console waves per threadgroup (> 64threads) to translate and run on 32-lane NVIDIA hardware viaconsole_cf.Root Cause
On 32-lane targets (
!target.runs(64)),victory-shaderpreviously restrictedconsole_cfto single-wave threadgroups (<= 64threads) with zero LDS (s.lds_dwords == 0). Any Wave64 compute shader combining cross-lane operations with LDS—or dispatching 128+ threads per group—fell back tos.wave_size = Some(64)and failed pipeline creation withUnsupported, dropping ~17 compute dispatches per frame in the prison prologue.Changes
crates/victory-shader/src/emit/lower.rs:exchange()to allocatethreads.div_ceil(64) * 2shared-memory dwords and index each console wave's exchange pair via(flat_tid >> 6) * 2 + half, allowing multi-wave threadgroups (> 64threads) to exchange half-wave values without colliding.wants_console_flowto route Wave64 compute shaders with LDS (s.lds_dwords > 0) and multi-wave threadgroups throughconsole_cfon 32-lane targets, emitting group memory barriers around LDS reads/writes to preserve intra-wave memory ordering across split 32-lane warps.crates/victory-shader/src/emit/split_tests.rs&mod.rs:console_cfisolation and combined cross-lane exchange + LDS (ds_write_b32/ds_read_b32).Testing
cargo test -p victory-shader split_tests -- --test-threads=1(12/12 passed on NVIDIA GeForce RTX 3060 Ti)cargo test -p victory-shader each_adapter_gets_what_it_runs(passed on NVIDIA GeForce RTX 3060 Ti)@adrianmjim on GitHub · 2026-11-26 19:54 UTC · original
Tested natively on Windows 11 with an RX 7900 XT (RDNA3, driver 32.0.32029.2010), head
b81546bagainst base4f62c2a. Other jobs were running on the machine at the same time. I have no NVIDIA card, so I could not test the RTX 3050 from #149. This GPU runs both wave sizes, so to test the 32-lane path I translated for a forced 32-32 target and ran the WaveSize(32) output here.Archive (shaders.rpf,
translate --validate --list)xchgis added on top.lds_wave64has no group-size limit, so they now take the console flow as WaveSize(32). The barrier calls in their DXIL go from 407 to 11143 in total (median +56.5 per program, max +295).--pipelinesat 32-32 on the 7900 XT: all 2574 compute pipelines are created, including the 4 that fail validation.Tests
--lib, single-threaded: 277 passed on base. On head 278 passed and 1 failed:emit::tests::console_lanes_translate_only_for_hosts_with_that_wave_size(mod.rs:1129). It still expects a 128-thread wave64 program to be refused for a 32-32 target. It does not use the GPU, so it should fail on any machine. It is not in the test commands listed in the PR description.console_flow_supports_multiple_console_waves_per_groupfails.multi_wave_console_flow_isolates_per_wave_exchangeandconsole_flow_with_lds_preserves_shared_memoryalso pass on base here. They usehost.target(), which is 32-64 on this GPU, so they run as wave64 and never reach the new path. They only exercise it on an adapter without 64-lane waves.Hand-written wave64 programs at a forced 32-32 target, run as WaveSize(32)
This is a local test, not for merge. The reference is the same program at 32-64 on the same GPU, which was right in every case.
v_readlaneof lane 40 in 1-D groups of 128 and 256, and in 16x8, 8x16 and 8x8 groupsv_readlaneinside a branch that only one console wave of a 128-thread group takesds_writeas well, this case was right.s_barrier, and reads the other wave's data.v_readlanein the loop instead of the LDS write.v_readlane, every lane.console_flat(#216). In these two shapes at WaveSize(32) on this GPU, two host waves get the same rounded id, so the halves meet in the wrongxchgslots.With other branches
7eaaadf): merges cleanly. The 32-32 counts are the same. 23 programs differ from this PR alone, all from #206's own changes. CS_MergeQuads is still refused.Possible changes (only checked with the cases above)
xchg, so the two hit_detection programs keep validating.For comparison, from reading only:
rx9070xt(81ebb7b) also runs these programs in host waves of 32 (lower.rs:1428-1477). It puts a group barrier before every LDS access, writes included (lower.rs:5305-5315), so the write-after-read case should not happen there. But it also counts blocks behind scalar branches as run by every lane (lower.rs:490-491), and it has no group-size limit (lower.rs:1473). So console waves that reach different numbers of barriers look possible there too. I did not test that branch.Not tested: NVIDIA, the game, and the GPU time of the extra barriers.
@Aniseto on GitHub · 2026-11-26 20:46 UTC · original
Ran the Wave64-on-32-lane tests at
b81546bon a physical NVIDIA Blackwell desktop part:System
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env)VICTORY_D3D12_ADAPTER=NVIDIAResults
cargo test -p victory-shader split_tests -- --test-threads=1: 12 passed, 0 failed, 0 ignored (273 filtered out, exit 0)cargo test -p victory-shader each_adapter_gets_what_it_runs -- --test-threads=1: 1 passed, 0 failed, 0 ignored (284 filtered out, exit 0)cargo test -p victory-shader --lib emit::tests::console_lanes_translate_only_for_hosts_with_that_wave_size -- --exact --test-threads=1: 0 passed, 1 failed, 0 ignored (284 filtered out, exit 101). The assertion now getsOk(HostShader)where it expectsErr(Unsupported { what: "console wave64 lanes on a host without 64-lane waves" }).What this adds
The only report in the thread is on an RX 7900 XT, where the 32-lane path had to be forced; this adapter genuinely has no 64-lane waves, so the new
console_cfpath is taken without forcing. The twelvesplit_testsand the adapter test pass here. The last test fails on this host as well: adrianmjim saw the same failure on a forced 32-32 target on RDNA3 and noted it is not in the commands listed in the PR description. This is a measured result, not a review verdict.Not tested
The hand-written wave64 shaders from that comment (write-after-read LDS, differing barrier counts, 32x2/32x4 groups), the title's shaders and GPU time, the full workspace suite, a paired smoke run, 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.