Shaders: console wave64 compute on 32-lane hosts (split waves) #1890
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1890
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1890"
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?
@beamdotdev on GitHub · 2026-11-25 00:11 UTC · original
beamdotdev:shader/split-wave64→main· +2653 −1336 · 19 files · 4 commits · openProblem
A compute program that depends on its lane layout (cross-lane reads, lane masks read as numbers, LDS shared within one wave) declares the console's wave size. On a device without 64-lane waves (NVIDIA:
WaveLaneCountMin = Max = 32), every wave64 one is refused byCreateComputePipelineStatewithE_INVALIDARG("Shader wants wave lane count of 64 but maximum wave lane count for device is 32"), and its dispatches are dropped.What this does
Such a program now runs split: it declares
WaveSize(32), and each console wave runs as two host waves, its low and high half (console lanes 0-31 and 32-63). Thread ids, lane numbers and masks stay the console's.ds_swizzleandv_permlanex16stay within 32 lanes;v_mbcnt,v_writelaneand lane bits of masks use the console lane.v_readlane,v_readfirstlaneof a varying value, and whole-wave reductions and prefix sums combine the two halves' parts through a few group-shared dwords between two thread-group barriers. A barrier needs the whole group, so this happens only in blocks no lane branch decides whether (or how often) a lane reaches (emit::split::convergent, a post-dominator pass): with one console wave per group, outside any lane branch's region; with several waves, before the first branch.MaskData::Host). This is right for what that code mostly does (wave-aggregated atomics, scalarization loops) and wrong where the code needs one value for all 64 lanes; it is markedshortcut:inlower.rs.v_readfirstlaneof a value that is the same in every lane (scalar arithmetic in VGPRs) needs no exchange, so it works in divergent code too.ds_bpermute_b32(both would need the other half's lanes), and programs whose LDS leaves no room for the exchange dwords in 32 KiB.The device's width reaches the translator when
victory-gpucreates the device (a run now creates it before its first translation), and when the offlinevictory translate --pipelinesand the warm-uptranslate --cachedo (both printhost waves up to N lanesfirst). The shader cache keys on it and now opens on its first translation, after the device: before, it opened at start-up with the width still unset, so its key always said 64, and the warm-up cached WaveSize(64) translations that a run on a 32-lane host then took from the cache (found by a second session testing the warm-up: 395 pipelines still refused).VICTORY_HOST_WAVE_MAX=32translates split on any device. Devices with 64-lane waves translate exactly as before.Measured
Windows 11, RTX 3070 (32-lane waves only), Series X 1.0.2.1 files,
victory translate --pipelines(before the port onto currentmain; the shader code is the same):Every compute program that translates gets a pipeline. The same files on a 64-lane host translate 1,441 compute programs; the 2 not translated split are
vfx_triangleClipprograms with no group-shared memory left for the exchange. Without this change, all ~320 programs that need 64-lane waves are refused on the 3070.The title ran with it on the 3070 to the first mission's title card ("Vice City, two years ago") at about 1 fps, then the host device was removed after a 7 s submission (the world hang the README describes, also seen on AMD). That submission held about 8 split programs among 69 pipelines, so this run does not show whether they are involved; a run with them skipped is the next check.
Tests
emit::split_tests(new, GPU): a wave64 program of one console wave checking per lane a mask count across both halves (s_bcnt1_i32_b64), the lane index (v_mbcnt), a read of high-half lane 45 (v_readlane),v_readfirstlane, ands_ff1_i32_b64of a high-lanes-only mask, built for 64-lane and for 32-lane hosts; and av_readlaneinside a lane branch, which reads within its half. Both pass on the RTX 3070 (the 64-lane build is skipped there, and WARP, at 4 lanes, skips both).emit::split::tests: post-dominators of an if and a loop.cargo clippy --workspace --all-targets --locked -- -D warningsand with--all-features: clean.cargo test --workspace --locked --no-fail-fast: 474 passed, 5 failed, 7 ignored. The 5 failures (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views, twostride_tests,gathers_at_a_level_match_the_hardware) fail onmainwithout this change on the same machine.Relation to #189 / #1589 / #1638
#189 (bundled in #1589 and #1638) solves the same problem with the same layout (two 32-lane waves per console wave, group-shared memory between barriers) and more besides: a barrier-free path for groups of 32 threads or fewer, an
Emulatemode without a declared wave size, which also covers WARP, and SGPR spills to lanes 32 and up. Those bundles are stacked on other open pull requests. This is a smaller change written against currentmain; if #189 is taken instead, the GPU tests here can check it.The wave-wide loop exit (
Atom::WaveAny) is not onmain; when it lands, a split program needs it exchanged as well.AI-assisted (Claude Code); no game data is used or committed.
🤖 Generated with Claude Code
@upipibi on GitHub · 2026-11-25 00:29 UTC · original
Ran on the kind of device this is for: RTX 3070 (Ampere,
WaveLaneCountMin = Max = 32), driver 616.56, Windows 11, debug, atd047e12.cargo test -p victory-shader --locked: 209 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA failures onmain. Both new split tests run and pass here:a_split_wave64_gives_the_consoles_lanes_masks_and_readsanda_split_lane_read_in_a_lane_branch_reads_within_its_half.cargo test -p victory-gpu --locked: 76 passed, with the two NVIDIA heap-cap failuresmainalso has.Not run: a title.
AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 01:37 UTC · original · edited 2026-11-25 03:18 UTC
Automated triage for the maintainers.
The current head (
73ee4dd) still conflicts withmain, incrates/victory-gpu/src/shader_cache.rs,crates/victory-shader/src/emit/host.rs,lower.rs,mod.rsand several*_tests.rsfiles undercrates/victory-shader/src/emit/. It will be reviewed once it is rebased onto currentmain.Generated by Claude Code
@KainanP on GitHub · 2026-11-25 18:17 UTC · original
On a 16-lane Intel iGPU (UHD
8086:a78b,WaveLaneCount16..16),host_wave_max= 16 still splits and declaresWaveSize(32), which that driver refuses at pipeline creation.a_split_wave64_gives_the_consoles_lanes_masks_and_readsthen fails withno device ran the program; it fails the same way withVICTORY_WARP=1. On the RTX 4060 both split tests pass. Details and table: #2220AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
@steven-seagull27 on GitHub · 2026-11-26 02:21 UTC · original
I found a first-lane mismatch in a converged 64-thread workgroup on
73ee4dd. The guest computesv5 = 100 + tid, narrows EXEC with a vector compare ands_and_saveexec_b64, readsv_readfirstlane_b32 s14, v5, restores EXEC, and writes s14 to all 64 outputs. The whole shader is one basic block. The five masks select first lane 0, 7, 39, 63, or no lanes (which should return lane 0's value, 100).¹ For the middle column I ported only the physical-wave ballot/election from #2830 onto this head. That fixes lane 7. For lane 39, each split Wave32 dispatch still returned 100 in all 64 outputs, where 139 was expected. EXEC's entire low word is zero in this case. Built-in WARP advertises only Wave4 here, so neither pipeline ran.
Commit 6cfdabb adds the regression and elects across halves with the existing two-dword exchange. Each half supplies its value and whether it has a participating lane. When both are empty, the lower half supplies lane zero. The three split tests passed on the RTX and the shader crate passed Clippy with warnings denied. The commit is based directly on this PR head for use during the rebase.
@luciano-repetti on GitHub · 2026-11-26 13:30 UTC · original
Tested on two GPUs this PR hasn't been run on yet, both with 32-lane waves at most: NVIDIA RTX 3050 6GB Laptop (Ampere, driver 566.07) and Intel Arc iGPU (Meteor Lake, Core Ultra 9 185H, driver 32.0.101.6127). Windows 11 26200, MSVC 2022, Rust 1.98.1 (pinned), debug,
cargo test -p victory-shader --locked, PR head73ee4ddagainst its base70564ae. No game files, so only the unit and GPU tests. Each GPU was made the default adapter for the test executable through the Windows per-app GPU preference.70564ae73ee4ddemit::split_tests(both tests) pass on both GPUs on the 32-lane path; the 64-lane builds are refused there and skipped, as expected.v_readfirstlane_b32mismatch reported above, which these tests don't cover; I haven't run that case.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.semantics_tests::arithmetic_matches_the_hardware:v_mad_f32/v_mac_f32mismatch the model on 102 of 14,440 inputs (WARP 0), e.g. in[00800000, 80800000, 00000000]want00000000got80000000(sign of a zero from an underflowing product).bvh_tests::intersections_*(3 tests): hit distance off by 1 ULP (1118671093vs1118671094).valu_tests::fspx_programs_run_with_the_hardwares_dot_products:2147483504vs2147483312.valu_tests::image_atomics_of_64_bitsandstride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros:E_INVALIDARGcreating the pipeline / dispatching.AI-assisted.
@catminou4 on GitHub · 2026-11-25 00:32 UTC · original · reviewed
Mixed PR: shader/formats parts are macOS-tested in the batch; GPU/HLE parts are Windows-only statics.
Console wave64 compute on 32-lane hosts (split waves): apps+docs+gpu+shader mixed — the wave64 split is the riskiest shader change this wave; shader part tested in batch, GPU part Windows-only.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:16 UTC · original
I resolved the conflicts between
73ee4ddand currentmain(63bcca4) inab0d7e8. It keeps both parents, including the current view-mark and shader-cache paths.e400c3fadds @steven-seagull27's first-lane fix and regression with his Git authorship intact. The integration passes guest EXEC to source-lane election and keeps the scalar write unconditional.On D3D12 Agility 1.620.2 / WARP 1.0.22 with DXIL validation, I ran the same five masks through split Wave32 and native Wave64 three times. The merge alone returned 384 wrong dwords out of 640 each time. With the fix all 640/640 matched each time. All three split tests passed. The full shader suite was 302 passed, 4 failed, 3 ignored. The same four tests failed on
mainin this WARP setup. Strict all-feature workspace Clippy and the repository asset-policy check passed.@beamdotdev, the integration branch can fast-forward the current PR head. A run of the new regression on a physical 32-lane adapter would complement the WARP results. The Intel 16-lane case reported above and the game were outside this run.
Please retain the Git authors when picking up the branch. If folding my integration into another commit, use
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@Venom2054 on GitHub · 2026-11-26 14:24 UTC · original
Confirmed the integration on a physical RTX 5070 Ti. D3D12 reports 32 lanes for both the minimum and maximum. I ran the five masks from
converged_first_lane_respects_both_exec_wordsthree times per revision, with Windows SDK DXIL validation and GPU readback.ab0d7e8e400c3fThe parent returned 100 where the three affected masks expected 107, 139, and 163. The full and empty masks returned the expected 100 on both revisions. Each run counts five 64-dword readbacks. The driver declined native Wave64 as expected on this adapter. This was a synthetic shader test.
@beamdotdev on GitHub · 2026-11-26 15:15 UTC · original
Thanks @andrewpozdnakov7-jpg. I fast-forwarded the PR branch to your integration branch, so the head is now
e400c3f(from73ee4dd). Nothing was rewritten: you stay the author of the mergeab0d7e8, and @steven-seagull27 stays the author of the first-lane fix. If this is squash-merged, GitHub will addCo-authored-bylines for both of you.Before pushing I ran the split tests on a physical 32-lane adapter (RTX 4060) at
e400c3f. All three passed, including the new regression:I didn't run the full shader suite this time. The 16-lane Intel case is still open.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
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.