Shaders: console flow for groups of several console waves on 32-lane hosts #1432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1433"
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 anasssssssss1 on 2026-11-24T17:58:11Z.
Stacked on #439 (and so #320 and #233): one commit on top of it, in
emit/lower.rs, with tests.What
On a host without 64-lane waves, a wave64 program that needs its whole wave runs in the console flow only in groups of one console wave. Bigger groups stop with
console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves. This lifts that for groups of whole console waves (64 to 1024 threads).Why it was refused, and how it is done
The halves of a console wave meet at group barriers (the exchange). In a group of several console waves, those waves branch and loop differently, so they reach different barriers, and a group barrier that pairs them by place would hang or pair the wrong halves.
Here group barriers are paired by count, not by place:
s_barrierbecomes a wait: the half stamps its arrival (barrier count mod 4, and the phase it arrived in), then keeps passing group barriers until every half has arrived at this barrier (or the next one) or ended.LOOP_LIMITabort path does the same.pis stored asp + 1and counts once a thread has passed that barrier, so every thread deciding after the same barrier sees the same thing. Each check is one wave operation (host laneitests halfi, at most 32 halves).Groups that are not a whole number of console waves, or whose LDS plus this state (
threads + 3 × halvesdwords) would pass 32 KiB, keep the old refusal.Tests
New GPU tests in
split_tests.rs, run on an RTX 4050 Laptop (split, two 32-lane waves per console wave) and an AMD Radeon 680M iGPU (native wave64), all exact:console_flow_runs_groups_of_several_console_waves:v_readlanelane 40 in groups of 128 and 256 (each console wave reads its own lane 40).console_waves_of_a_group_branch_differently: only console wave 0 enters a branch with a lane read inside; 256 threads.console_waves_of_a_group_loop_differently: lanetloopsttimes reading lane 40, so wave 1 loops twice as long as wave 0; 128 threads.program_barriers_order_lds_between_console_waves: waves take different branches, write LDS,s_barrier, then read the other console wave's dwords; 128 threads.The tests that expected the refusal now expect a translation (
console_lanes_translate_only_for_hosts_with_that_wave_sizekeeps a refusal check for a 96-thread group;each_adapter_gets_what_it_runsmakes the 128-thread pipeline on every adapter).cargo test -p victory-shader: 163 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings, with and without--all-features: clean.In the title
RTX 4050 Laptop (6 GB), Series S, on r4tedx's
integration/testersupdate 9 (94e0ea5) with this change: compute programs refused in the world went from 112 to 1 (against the same tree at update 8 without it, so part of the drop is update 9's own changes), and none are refused for this reason. I have not checked the fourInstanceCullinghashes from #71 by name. The world picture is still black on this machine; whether this is enough for the scene is open (pipelines were still being compiled when the runs were stopped).No game data in this PR.
Imported from Marvisak/VIctory. Originally posted by matheusfermiano-source on 2026-11-24T18:21:34Z.
An AMD run under Proton on Linux: Radeon 660M (RDNA2, RADV Mesa 26.3.1, waves 32..64), head
b3efa1c.cae8353): the wholevictory-shadersuite gives 162 passed, 1 failed, 1 ignored. Bothlane_read_loop_testsare exact in wave32 and wave64. The failure isemit::tests::stub_pipeline_is_created, which fails onmainhere too: vkd3d-proton accepts a zeroed DXIL hash (see #1218).cae2e003):lane_read_loop_with_a_joined_exec_back_edgekills the test process with no test result. dxil-spirv logsFailed to find a common merge point, thenvkCreateComputePipelinesfaults inside RADV (0xc0000005). #439's head28aca3b, which has the same test, does the same. With 3.2.0 both pass, so this is the vkd3d-proton structurizer problem discussed in #144, not this PR. For anyone testing these branches on Linux: use vkd3d-proton 3.2, or the run stops at this test.Built on Linux with llvm-mingw for
x86_64-pc-windows-gnullvm(Rust 1.98.1);dxil.dllfrom DXC 1.9.2609 was loaded. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.Imported from Marvisak/VIctory. Originally posted by Zmirzz on 2026-11-24T19:41:09Z.
Whole-corpus translate with pipeline creation on a 32-lane host, for this PR's head
b3efa1c(so with #439, #320, #233 and #223 under it).Host: NVIDIA GeForce RTX 5060, Windows 11 (
host waves 32-32 lanes).Input: all 26,503
shaders.rpfcontainers of my own copy (614 duplicates skipped, 2,582 compute programs),victory translate <dir> --pipelines, release build.mainatffe310eThe parameter is incorrect., i.e.WaveSize(64))b3efa1cVertex/pixel (12,231) and mesh (8,214) pipelines are the same on both.
On
mainthe 320 refused programs include passes that matter for the world's lighting:tiled_lighting(MaterialTiles,ShadowRevealTiles,ClusterLightsWorldSpace),shadowmask(GenerateShadowMasks*,DenoiseShadowMask*),cascadeshadows_rendering/_classify/_processing,depth_pyramid,deferred_tiled_CS_DepthProcessing*,ambient_map_CS_AmbientMapSky*, TAA resolves and theim_CS_Texture2D*Mipmap*generators. With this PR none of them fails for a wave reason. Among those families, what still fails here is not wave-related:resources: an address not from a root parameter(TraceShadowRays_*,sr_tracing_CS_RaytraceVBuffer_*),a descriptor read only as data,an LDS write of bytes or halves(DenoiseShadowMaskLDS*,TAA2_PrepareFrameStats),v_permlanex16_b32(deferred_tiled_CS_WaterTransmittanceOpticalDepthProcessing).Remaining wave-related failures over the whole corpus: 4 ×
a whole-wave section of a wave64 on a host without 64-lane waves, 2 ×console wave64 lanes in a group of more than 64 threads on a host without 64-lane waves.Not validated with
dxil.dll(no--validatein this run), and no title run yet; I'll report back if I get one.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:43:58Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: +12 programs over
main, 0 lost.Offline. I merged head
b3efa1contomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,736 with this PR.mainOf the 12, 5 are among the programs that #1402 gains and 7 are new. It also moves 658 programs that keep failing on to later reasons: 220 from "a lane mask holding lanes elsewhere read as data" and 205 from "a select on an untracked mask" go on to "a descriptor read only as data", which #1067 (inside #1402) handles. #1423 showed the same pattern and gained +214 on top of #1402, so I'm measuring this PR stacked on #1402 too.
Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 163, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:27:59Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:apps/victory/src/main.rs,apps/victory/src/translate.rs,crates/victory-gpu/src/host.rs,crates/victory-gpu/src/pipeline.rs,crates/victory-gpu/src/shader_cache.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T05:45:09Z.
@anasssssssss1, I read this against the multi-wave branch on our fork (
shader/wave-per-group, stacked on #439 too), since both take the groups #439 stops withconsole wave64 lanes in a group of more than 64 threads. One structural problem first, then the numbers.Group barriers in group-divergent control flow. Pairing barriers by count keeps every half of a console wave on the same branches, but the console waves of one group branch independently, and both the exchange barriers and the drain loop then sit on different paths for different threads of the same host group. A minimal case, a 128-thread wave64 group (two console waves) for a 32-lane host:
Words:
7D880094 BF860006 D7600009 00015100 BF8A0000 BF8A0000 7E040209 BF820001 BF810000, throughemit::split_tests'sprogram(body, 128)andTarget { lanes_min: 32, lanes_max: 32 }atb3efa1c. The module validates withdxil.dll. In it, the branch on console wave 0's ballot (br i1 %45, label %175, label %46) leads one way to fivedx.op.barrier(80, 11)call sites (the exchange and the two waits) and the other way to a loop around a differentdx.op.barriercall (the drain). So within one thread group, threads of wave 0 and wave 1 execute barrier calls at different places in the program at the same time.GroupMemoryBarrierWithGroupSyncis defined only in control flow that is uniform across the thread group; the validator does not check that dynamically. The hardware barriers underneath count arrivals, which is what the scheme relies on, and that may well work on a given card, but nothing in D3D12 promises it, and a driver compiler is entitled to assume the barrier is reached uniformly (move it, merge it, or treat the code around it as convergent). Two more points from reading it: each wait loop exits onwaveAllTrueper host wave (wait_for_halves), so different waves of one group can leave it after different numbers of barrier calls; the drain and the waits have no iteration bound of their own (the 2^20 loop guard sends a long loop into the same unbounded drain), and the arrival stamp shares bits with the count from phase 2^30. I have not run it on a GPU: the 32-lane card here is off limits for barrier-heavy tests after a hard freeze, so I can say it is undefined, not that it hangs.The form on our branch avoids the question for groups that share no LDS and have no
s_barrier: each host group is one console wave (64 threads, the dispatch's x multiplied by the waves per group, indirect dispatches through a list-owned rewrite of the records), so the console flow's barriers stay uniform within each host group. It cannot take groups whose waves meet ats_barrieror share LDS; that is the part this PR is aiming at.Coverage, offline (local title data, CPU only, counts and hashes only;
translate --host-lanes 32-32 --validateover the shader pack, against #439 at the same translator):c734600b3efa1cNo program that validated on #439 is lost with either. So this PR takes 18 more programs, all with LDS and
s_barrier, and those are exactly the ones whose barriers the problem above affects.What I would suggest. Keep the one-host-group-per-console-wave form for groups without LDS and barriers (it needs no cross-wave synchronisation at all), and use count-paired barriers only for groups that need them, once every barrier call sits where the whole group reaches it: for example, every thread of the group running every block that any console wave of the group enters, with each wave's effects guarded by whether that wave is really there (the "group-wide form" in
docs/wave64-on-wave32.mdon #439), so the exchanges and waits are the same calls for all threads. Then exact readbacks against independently computed results for early ends, repeated barriers, unequal loops and LDS visibility across waves, and runs on several 32-lane drivers under occupancy pressure. I am glad to compare that on the same pack.The counts and the module above come from an AI agent's offline run (Codex), checked by me; the disassembly is reproducible from the words above. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by anasssssssss1 on 2026-11-25T07:51:31Z.
@r4tedx, thanks. The structural point is right. Count-paired barriers keep the two halves of a console wave together, but two console waves of one group can still reach
dx.op.barrierfrom different call sites. D3D12 leaves that undefined, even if it works on the cards it was tried on (the RTX 5060 run above and my 4050). I'm marking this as a draft until it's reworked.The rework follows what you suggest:
s_barrieruse the one-host-group-per-console-wave form, so no cross-wave synchronisation is needed.dx.op.barrierthen sits on a group-uniform path, and the drain loop goes away. A wave that has ended stays "absent" untils_endpgm, so the barrier count is the same for every thread by construction, not by counting.waveAllTrueexits and the arrival stamps go away with this form. That fixes the bit-sharing from phase 2^30 and the unbounded loops along with them.For tests, I'll add readbacks checked against independently computed results for your case (words above), early ends, repeated barriers, unequal loop counts and LDS visibility across waves. I'll also rebase onto current
main. Once it's up, I'll ask for the comparison on the pack.Imported from Marvisak/VIctory. Originally posted by anasssssssss1 on 2026-11-25T08:04:31Z.
Moved to #2214 (same commit, now from my other account, shawshanker18). The review above is carried over there, and the rework will land on #2214.
Pull request closed