Shaders: console flow for groups of several console waves on 32-lane hosts #1433
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!1433
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1433/head"
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?
@anasssssssss1 on GitHub · 2026-11-24 17:58 UTC · original
anasssssssss1:fix-console-flow-multi-wave→main· +3544 −118 · 16 files · 47 commits · closed without mergingStacked 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.
A console wave64 program that reads masks whole or lanes of the other half now runs on a host without 64-lane waves when its group is one console wave (64 threads or fewer, no LDS). It runs as the console does ("console flow"): - `structure::structure_console` never resolves mask joins from what the lanes arriving know (every lane arrives); `Structured::execs` gives each vector instruction's EXEC bit. - Vector instructions are guarded by EXEC. Branches are the console's s_cbranch_*: EXEC, VCC and mask-operation SCC tests are the console wave's, from both halves' ballots exchanged through group-shared memory between group barriers, which every thread reaches since both halves branch alike. - Masks read whole are the exchanged ballots. v_readlane and v_readfirstlane read the owning half; v_writelane, v_mbcnt and mask bit tests use the console lane. The per-lane form is tried first; a program that needs the console flow is lowered again from the console structure. GPU tests on an RTX 5070 are exact against the console: s_bcnt1 over both halves (64, 48 and 32 threads), v_readlane 40, an exchange inside a branch only the lower half takes, and a loop the halves leave at different iterations with a lane read in each. The last one shows that the per-lane form, which hosts with 64-lane waves get, is wrong for it (on a Radeon iGPU): noted in docs/wave64-on-wave32.md, not changed. Co-Authored-By: Claude Opus 5.5 <[email protected]>The validator's message for an operation the stage or the entry's properties do not allow ("Entry function performs some operation that is incompatible with the shader stage or other entry properties") names neither the operation nor the property, and it is the only message when the call is in the entry function itself. `victory translate --validate` now adds to each validator failure what our own module declares and calls: its thread-group size, its wave size and its dx.op operations (`emit::last_module_summary`, kept per thread when a module is finished). Nothing of the console program is in it, so a report of counts per reason is enough to see what the refused modules have in common. Prompted by a report on #233: modules that fail validation with that message and still create pipelines, 20 of them new with #320, which I cannot reproduce with hand-assembled programs. Co-Authored-By: Claude Fable 5.2 <[email protected]>1a8a3ed) 3c961b5ea0e4246fd) 1e17e572a0b623fd3) bf13a276c5cbcef55) bf0f9511c541369c9) 28aca3b718@matheusfermiano-source on GitHub · 2026-11-24 18:21 UTC · original
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.@Zmirzz on GitHub · 2026-11-24 19:41 UTC · original
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.@sinan-cmyk on GitHub · 2026-11-24 20:43 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 01:27 UTC · original
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
@r4tedx on GitHub · 2026-11-25 05:45 UTC · original
@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).
@anasssssssss1 on GitHub · 2026-11-25 07:51 UTC · original
@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.@anasssssssss1 on GitHub · 2026-11-25 08:04 UTC · original
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