Shaders: groups of several console wave64s run in the console flow on 32-lane hosts (pair meetings) #3683
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3683"
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?
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T06:16:14Z.
Draft, stacked on #439 (
e2d3cfd). Only the last commit is new; please review that one. I'll rebase once #439 lands.Problem
On a host without 64-lane waves (NVIDIA), #439's console flow runs a console wave64 as two 32-lane host waves ("halves"). The halves meet at group barriers to exchange lane masks and data. A thread group holding several console waves is refused ("console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves"): its console waves branch and loop differently, so no group barrier is reached by every thread. On the title's shader pack that refusal stops 44 compute programs on a 32-lane host. Among them are 19 tiled cascade and hair shadow programs, and 5 stages of the ray-tracing structure builder.
Change: pair meetings (
emit/lower/pairs.rs)The two halves of each console wave meet on their own, without a group barrier:
v_readlane,v_readfirstlane,v_mbcnt,s_bcnt1of ballots), wave-wide branch decisions (execz/vccz/scc), and the order of the console wave's own LDS accesses (a meeting before each).s_barrierstays a group barrier. A program is refused unless every block holding one runs exactly once on every path (in no cycle, and post-dominating the entry). That keeps every barrier call in group-uniform control flow.bitcode::defs_dominate_uses).VICTORY_BVH_HALVES=0(ortranslate --no-pair-meetings) turns it off, and the shader cache keys the two apart. Only programs that were refused before change (census below).Why it's exact, and its limits
s_barrier, as on the console.LOOP_LIMITon the same iteration, because the loop decision is exchanged [inference from the construction]. If it ever triggered, the results would be inexact. The testbuilder_meetings_end_far_below_the_poll_limitruns with the limit cut to 2^10 and is still exact. That bounds the waits; it doesn't instrument a give-up.e2d3cfdbelow.Measured
Offline census. Whole shader pack,
victory translate <pack> --list --validate --host-lanes 32-32, this branch against #439e2d3cfd:--no-pair-meetingsevery program's outcome matches the base.Builder. On #439's current head the five builder stages that this PR otherwise translates are still refused, by
e2d3cfd's title-memory limit (question for #439 below). With that limit lifted locally, the builder dll gives 52 of 52 stages emitted and validated for a 32-lane host, against 47 of 52 without this change.In the title, on our integration tree, not on this branch. Setup: RTX 5090 (32-lane waves), Linux, Wine 11 with GE-Proton11-14's vkd3d-proton. The tree is our
perf/bvh-halvesbranch (an older #439 withoute2d3cfd, #2118, and an earlier version of this change): one adjacent pair of the same exe,VICTORY_BVH_HALVES1 against 0, both with a warm pipeline library. (Edited 2026-11-29: this said forkmain, and left the frame cost out.) Results:Those runs also contain other unmerged changes, so they show that the mechanism holds up in the title; they don't measure this PR alone.
Tests
In
emit::pair_meeting_tests(GPU tests skip unless the hardware adapter runs 32-lane waves only):several_console_waves_translate_with_pair_meetings(CPU). Without pair meetings a 256-thread group is refused, as before. With them it translates, unless the program's LDS fills 32 KiB. A 32..64 target gives identical output either way. Fails on #439 (refused).a_lane_read_in_a_loop_each_console_wave_leaves_on_its_own(GPU). Hand-written GFX10, no title code. Groups of four console waves ([256,1] at lanes 5 and 40, [16,16], [8,16], [8,32]) run a loop each console wave leaves after a different count, withv_readlaneacross the halves inside it. Every lane is checked word for word against a CPU reference.builder_programs_equal_the_consoleandbuilder_meetings_end_far_below_the_poll_limit(GPU). The title's five builder stages, loaded from the local disk (VICTORY_BVH_PROGRAMS, a directory of<hash>.dxbcfiles, never committed). They're compared against CPU references for a block scan, a digit histogram, and a block sort and scatter. Without the variable these tests skip; on #439's current head they also skip, with the title-memory reason.split_tests,select_testsandeach_adapter_gets_what_it_runsnow expect groups of whole console waves to translate. A 96-thread group is still refused.Results on RTX 5090, Wine with vkd3d-proton:
pair_meeting_tests: 4 passed.e2d3cfd's limit lifted locally, the five builder stages match word for word (8 seeds; 4 seeds at a 2^10 poll limit).victory-shaderlib: 348 passed, 4 failed, 3 ignored. #439e2d3cfdgives 344 passed with the same 4 failures (hosts_that_do_not_fuse_are_named,rounding_matches_the_hardware,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,stub_pipeline_is_created).cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features, is clean, andcargo xtask policyis clean.Not tested
Overlap
s_barriermust be met once on every path. On the tests here both are exact. I ran #2214b3efa1con #439's head with our synthetic test and the builder stages, and this branch with #2214's four multi-wave tests, all on the same RTX 5090. So these tests can't tell the two apart. I'm happy to measure #2214's reworked version on the same programs and setup so maintainers can choose.0x887A0006), and that PR holds the builder back. This PR exchanges both halves' words instead.e2d3cfd's title-memory limit keeps the builder stages refused (see the question on #439).+0x23cf683) as soon as the builder ran on our tree. A fix for that interaction is in our integration tree; it isn't part of this PR, and it matters if #385 merges.Credit: the idea of half-wave pair meetings comes from trustno1-coder/VIctory-NVIDIA (fork PR #12;
with_pair_meetings,Lower::meet,exchange_first; 2-D relabelling afterwave_base, Vice-Tay c125c0c). It's re-implemented here on #439's console flow. That fork'sFIRSTLANE_OWNshortcut (the host wave's own first lane taken as the console wave's) is not used; values are exchanged instead.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-28T07:50:39Z.
Ran the pair-meeting tests at
82f99f7(draft, stacked on #439) on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.All four tests pass on a genuine 32-lane host, including several console waves translating with pair meetings and the builder meetings staying below the poll limit. They are translation-level tests; I did not run the title's 44 affected programs or a dispatch. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.
Not tested: the title's shadow/builder shaders, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, 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.
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T07:52:34Z.
@Aniseto thanks, the first run on another card. Two notes on what the four tests cover:
a_lane_read_in_a_loop_each_console_wave_leaves_on_its_owndoes dispatch: whenHost::newfinds an SM 6.6 NVIDIA adapter, it runs on the GPU and compares against the expected values. If it can't find one, it printsskippedand passes.-- --nocaptureshows which of the two happened on your 5070 Ti.VICTORY_BVH_PROGRAMS). Without them they printVICTORY_BVH_PROGRAMS not set; skipped, which is the right call with no game data.A gap I found since opening this, which affects this PR and #439's console flow. Meetings and console-flow barriers fence group-shared memory only. A UAV write by one half of a console wave isn't ordered before a later read of the same address by the other half, though on the console that's plain program order. I wrote a synthetic test: lane 5 stores, then lane 40 loads the same dword, and the reverse. It ran 1024 groups × 16 dispatches per shape on an RTX 5090:
The fix finds each UAV access that conflicts with an earlier one with no barrier between them, on any path. Before each such access the halves now meet with a group-scope UAV fence. Programs that don't write UAVs stay byte-identical. Over the whole pack: 0 programs lost, 308 compute programs change, and the rest are byte-identical. A switch
VICTORY_UAV_ORDER=rawkeeps only the read-after-write meetings (167 programs) as a cheaper second arm. The builder's programs read before they write, so the results above for them stand.Branch (on my fork's integration, which carries #439 and these meetings): https://github.com/neonbyte1/VIctory/tree/suggest/console-flow-uav-order, commits
7797c99d9and5df170e23. I haven't measured its in-game cost yet. I'll fold it into this PR after an A/B, and report it on #439 too.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T14:40:46Z.
In-game cost of the UAV-order fix I reported earlier. RTX 5090, Wine 11.22 + vkd3d-proton, A-B-A-B with 420 s per run on a quiet machine, same exe, switched with
VICTORY_UAV_ORDER:So
allcosts about 3 ms a frame (1.4 %), andrawcosts no measurable time. Pictures and refusals were the same in every run.Since then, the fix also covers the per-lane form and plain split halves. Both were exposed too: before the fix, 536 to 22,732 stale reads per shape in the synthetic test; after, 0. Programs with a conflict go to the console flow where it's allowed (about 460), and a small address analysis drops conflicts that provably can't alias. Over the pack: 0 programs lost, 785 compute programs change.
Branch: https://github.com/neonbyte1/VIctory/tree/suggest/uav-order-all-forms (its 3 commits on top of my fork's
main).AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-29T08:00:35Z.
A correction to this body, and where the measurement now lives.
perf/bvh-halvesbranch (the body said forkmain): RTX 5090, Linux/Wine 11.22, vkd3d-proton of GE-Proton11-14, same exe,VICTORY_BVH_HALVES1 against 0, both runs with a warm pipeline library. With the builder running (0 to about 345 dispatches a frame) 341 fewer draws are dropped a frame, and the frame costs 76 ms more: 188.5 to 264.5 ms (preparing +51, on the GPU +16, copying back +9). The pair compares the builder running against held back, so the 76 ms holds the builder's dispatches and what the ray-traced passes then do, not the meetings alone. I edited the body.e2d3cfdthe builder stages stay refused, so there is nothing for it to change in the title there), the 26 newly translating programs dispatched in the title, and a second pair.Fork issue with the evidence table: https://github.com/neonbyte1/VIctory/issues/179 (
RESULT: https://github.com/neonbyte1/VIctory/issues/179#issuecomment-7252785665). We now hold our own PRs to a rule there: a hardware test with an adjacent control before a PR leaves draft. This one does not meet it yet and stays a draft.AI-assisted (Claude); measured on my machine, no game data shared.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.