GPU: indirect dispatches past 65,535 groups in x run the rest in a second execution #834
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/fxceless--victory-fork!834
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-834"
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?
@SantannaCarlos on GitHub · 2026-11-25 09:52 UTC · original
SantannaCarlos:fx/dispatch-split→main· +368 −11 · 5 files · 1 commits · openProblem
A D3D12 dispatch runs at most 65,535 thread groups in each dimension, while the console's go further in x. The README lists it under "Known and counted, not fixed yet": the clamp cuts an indirect compute record that asks for more to 65,535 in x, and the groups past it never run.
In the prologue on an RTX 4070 it is always one program,
2dc364df5d3278b8(named with a local counter of the cut executions):ExecuteIndirect.VICTORY_SHADER_OPT=0shows too.Change
indirect.rs). Behind bit 3 of the flags word, which was free, the clamp writes a second record after each dispatch record,stride * recordsbytes on in the scratch buffer.USER_GROUP_BASE(RootType::Other(0x104)), is added toSV_GroupID.xin programs that read their group id in x. Other programs come out unchanged. The translator emits noSV_DispatchThreadID; the console code builds global ids from the group-id register, so the base reaches those too.draw.rs). For an indirect dispatch whose program has the dword, the clamp runs withbound_split. After the usualExecuteIndirect, the host sets the dword to 65,535, runs the second records with the same command signature,maxand count buffer, then sets the dword back to 0. Direct dispatches and every other path see 0.VICTORY_DISPATCH_SPLIT=0turns the split off.The second execution runs exactly the groups past 65,535, so there are no surplus groups to stop.
shortcut: only programs that read their group id in x are split. A second execution for every indirect dispatch would double the indirect compute commands of a frame, so the others are still cut, which matters for one that takes its work from a counter. The one program seen asking for more in the prologue reads it.
Not covered:
Related
2cc4c197ee29e291(the reflection tiling program) run on 32-lane hosts and reports a band of blocks gone in the same shot. That program is refused in all seven runs below, with and without the split, so the difference in them is the split's. The two may each account for part of the blocks.Tested
indirect::tests::warp_split_runs_every_group_of_a_wide_dispatch_once(WARP): one record goes through the clamp and both executions, and a shader counts each group in a UAV.emit::tests::the_group_id_in_x_starts_at_the_host_base: a hand-written program that stores its group-id register is translated, validated and run with three groups. It reads 0, 1, 2 with the dword at 0, and 65,535, 65,536, 65,537 with it at 65,535.cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features: only what9376fd6already fails on (draw.rssort_unstable_by_key,indirect.rsRig::depth_written, and without the featuresplaced_filler_twins).cargo test -p victory-shader: 216 passed on the card. Under WARP 4 fail (ds_min_max_f32_order...,v_permlane16_and_x16...,whole_wave_f64_sum...,a_lane_mask_joined_with_a_number...), the same way as on9376fd6.cargo test -p victory-gpu --lib(WARP): all pass butdepth_bounds_pipeline_loads_and_filters_draws, which fails on9376fd6under WARP too.cargo xtask policy.indirecttests pass.6b82bc7d22016cb5and refused it withE_INVALIDARG; earlier runs on trees without this change refuse it the same way.The README line under "Known and counted, not fixed yet" can say "up to 131,070 groups in x run" once this is in.
@SantannaCarlos on GitHub · 2026-11-25 10:17 UTC · original
On the requests past 131,070 listed under "Not covered": they come from pipeline warm-up, not from real work. Two 10-minute runs from that save, with this change and the counter:
2dc364df5d3278b8, always one record, y = z = 1.2dc364df5d3278b8is left, at 66,000 to 71,000.So the counts are built while passes that make or clear them have no pipeline yet. No record seen asks for y or z over 1, and every program seen cut reads its group id in x.
@SantannaCarlos on GitHub · 2026-11-25 10:23 UTC · original
Heads-up for merging: #646 also adds a host-computed user-data code at
RootType::Other(0x104)(USER_DISPATCH_THREADS), the same value asUSER_GROUP_BASEhere, so the two conflict inemit/shader.rs,emit/mod.rsanddraw.rs. Whichever goes in second takes0x105and joins the imports and thehost_wordcases. The logic does not overlap: #646 limits directDispatchXdispatches with thread dimensions, and this one only splits indirect records. I can rebase this branch onto either order.@HLVM04 on GitHub · 2026-11-25 10:31 UTC · original
A/B on an RTX 5070 Ti (wave32, NVIDIA 616.64), Series S profile. Tree:
9376fd6+ #798, #783, #799, #780 (withVICTORY_INDIRECT_KEEP=1 VICTORY_INDIRECT_WINDOW=1), #770 and #827, then this PR on top. One run each, about 4.5 minutes, frame lines after the first 60 s:I didn't compare pictures for the lower-right blocks in this pair, so this only covers cost and stability on a second card and profile.
@Rezwo on GitHub · 2026-11-25 10:37 UTC · original
Turing hardware test result on unchanged PR head 4b44212d6ba571092793f44e77dc8cf60297f427.
Windows, NVIDIA GeForce RTX 2080 Ti, Windows driver version 32.0.16.2101. No game files or in-game run.
I ran the existing split-dispatch fixture in an instrumented test harness. The local change only selects hardware versus WARP, asserts the adapter type/name, replaces the fixture's silent initialization skip with an expect, and logs the cases. Production split code and the readback assertions were unchanged.
Command:
cargo test --locked -p victory-gpu --lib indirect::tests::warp_split_runs_every_group_of_a_wide_dispatch_once -- --exact --nocapture
Both runs passed (1 test each, exit 0):
All eight split cases ran: 1x1x1, 65535x1x1, 65536x1x1, 89968x1x1, 131070x1x1, 200000x1x1, 70000x2x3 and 70000x16x1. The unsplit negative control passed too. The fixture checks per-group hits, the 131070 x cap and the budget rejection for the oversized case; this is not a claim that all 200000 groups run.
The untouched baseline fixture also passed, but the adapter-logged runs above are the evidence that the instrumented fixture actually executed on each adapter. Rollback verification was not completed because the local tool rejected that command.
This supports the synthetic split logic on Turing; no conclusions about in-game visual changes or frame rate. AI-assisted (OpenAI Codex); tests executed locally.
@VibeClauding on GitHub · 2026-11-25 10:55 UTC · original
Heads-up for merging this together with #220 (cheaper indirect draws, open): the two combine without a textual conflict in the clamp shader, but the result is wrong.
askedinINDIRECT_CLAMPis a singleuintthat only mesh records set; it's 0 for dispatches. This PR's split readsasked.xin the dispatch branch (uint rest = ... ? min(asked.x - 65535u, 65535u) : 0u).asked.xis a swizzle of that scalar, so it's 0.0 - 65535wraps around, so every full-width dispatch (g.x == 65535) gets a second record of 65,535 extra groups and is charged twice.warp_split_runs_every_group_of_a_wide_dispatch_oncecatches it:asked [65535, 1, 1]: budget, 8,388,480 against 4,194,240.min(src_args.Load(src_at) - 65535u, 65535u).record_clamp_withhas to take the scratch buffer's state,(dst, before), as #220'srecord_clamp_asdoes, andbound_splitshould track it likeclamp_into:list.indirect_statebefore,list.indirect_readableafter.done_onis gone after #220. A plainINDIRECT_ARGUMENT -> COMMONtransition replaces it.indirecttests pass on8dd30ab+ #220 + this PR (+ #646 #648 #670 #705 #346).AI-assisted (Claude Code).
@SantannaCarlos on GitHub · 2026-11-25 11:03 UTC · original
Rebased onto
f85101b, which conflicted indraw.rsand changed the clamp under this branch:record_clamp_withtakes(dst, before)likerecord_clamp_as, andbound_splitgoes throughclamp_into, so the list knows the scratch is readable afterwards.src_args.Load(src_at)), as the store already did.done_onis gone from the tests; the split test drops it like the others.Checked on the rebased tree, WARP: the
indirecttests pass, including the split one (14 of 14);cargo test -p victory-gpu --all-features --lib -- --test-threads=1passes butdepth_bounds_pipeline_loads_and_filters_draws, as onf85101b; clippy with and without--all-featuresreports only whatf85101balready reports. Run in parallel on WARP,warp_budget_saturates_without_wraparound_and_preserves_draw_fieldsfails now and then onf85101btoo (2 of 3 runs there, 1 of 3 here).@SantannaCarlos on GitHub · 2026-11-25 11:14 UTC · original
@VibeClauding thanks, the same three came up in the rebase onto
f85101b(which has #220):0135c41reads the record's own x, takes(dst, before)and goes throughclamp_into, and dropsdone_on. The split test catches the first one, as you say.@NuraadGit on GitHub · 2026-11-25 11:22 UTC · original
A heads-up for when this is rebased over
f85101b(we merged both into a lab stack on an RTX 2080 and hit it).f85101brewrites the clamp shader's dispatch branch (} else if (active && kind == 2) {) asuint3 g = min(src_args.Load3(src_at), ...)and adds an outeruint asked = 0;for the mesh diagnostics. Git merges this PR's branch into it without a conflict, but the branch'suint3 asked = src_args.Load3(src_at);is gone. Sonow reads the outer scalar
asked(0):0 - 65535wraps, and every dispatch record with exactly 65,535 groups in x gets a second record of 65,535 more groups. The PR's ownwarp_split_runs_every_group_of_a_wide_dispatch_oncecatches it: for[65535, 1, 1]the budget is 8,388,480 instead of 4,194,240. Reading the record again in that branch fixes it (uint3 want = src_args.Load3(src_at);, withwant.xinrest).Two more things that need adapting on rebase:
f85101bpasses(dst, state)torecord_clamp_asand dropsdone_on, sorecord_clamp_with,bound_splitand the split test need the same state handling (list.indirect_state(&dst)before,list.indirect_readable(&dst)after).Separately, on
f85101bitself:warp_budget_saturates_without_wraparound_and_preserves_draw_fieldsasks 2^24 indices for its first draw, which is now >=MOST_DRAW(2^23), so that draw runs empty and the test's "the first two real draws fit the budget" assertion fails.@iGoldenNinja on GitHub · 2026-11-25 10:22 UTC · original · edited 2026-11-25 12:13 UTC
Independent RTX 5080 16 GB check, driver 617.14, Windows 11 Pro 25H2 (26200.9974). I applied
4b44212d6ba571092793f44e77dc8cf60297f427to PR 823aaf658a. The strict split fixture passed on both RTX 5080 and WARP, including the 89,968-group readback, the 131,070 cap, y/z coverage and the dispatch budget rejection. The translated group-ID fixture also validated and returned the expected groups with bases 0 and 65,535 on the 5080.On the identical executable and cache seed, both settings reached controllable prison and bound
2dc364df5d3278b8plus all four PR 823 compute programs. In the sampled, visually matched courtyard frames the lower-right mosaic was absent in both settings. The matched room frames after retreat were similarly dark (mean encoded luma 20.78 off, 20.60 on). One 90-second replay per setting measured 3.04 FPS / 599.79 ms P99 off and 2.93 FPS / 611.48 ms P99 on. The off run spent longer in the preceding transition. Local title telemetry verified pipeline binds, with submitted group dimensions still unmeasured. Pinned reportFollow-up on the rebase
0135c41. I added a fence-completed GPU readback of the requested and clamped records for2dc364df5d3278b8. On the RTX 5080 (617.14, Windows 11 Pro 25H2 build 26200.9974), all 46 split-off samples asked for more than 65,535 groups in X and were clipped. The largest omission was 31,313 groups. Splitting covered all 48 sampled requests in full, with Y and Z equal to one throughout. Both replays reached controllable prison.In a third launch I toggled only this shader's split while holding the camera at the prison window. The client dimensions stayed at 1735 × 911. In the initial off phase the first record carried 65,535 of 74,400–74,808 requested groups and the bottom band was visible. With splitting enabled, the second record carried the remaining 10,185–10,393 groups and most of the band cleared. Disabling again clipped the records immediately, and the band stayed mostly clear in the sampled view. That persistence is consistent with previously written tiles retaining their updated values. Stepped character edges remained. Diagnostic code and pinned report
@SantannaCarlos on GitHub · 2026-11-25 12:14 UTC · original
For whoever weighs this: myokex already split dispatches the same way in myokex/victory-amd on the 24th ("Shaders: compute programs add the number of the first group" and "GPU: ... dispatches in parts", 892d259 and 4436f8f there), and it was carried into ZSlayerHQ/victory-world-runtime and vitutu1/victory-perf. I found it only after opening this; it never came here as a pull request, and main took myokex's view guard but not this part.
Same idea and even the same names (
USER_GROUP_BASEat 0x104,bound_split), from the conventions next to them. Differences, from reading the diffs:Take whichever fits better, or the direct-dispatch part of that one on top of this. If you prefer that one, I'll close this; the measurements here apply to both.
@MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original · edited 2026-11-25 12:51 UTC
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
0135c41intomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with the errorsmainitself has on this machine (placed_filler_twins,depth_written, a sort, andmanual implementation of .is_multiple_of()atvictory-gpu/src/shadow.rs:2675; PR #841 fixes the first three), also with--all-features; this PR adds none. (Correction: my first version of this report said that theis_multiple_ofone was extra here. It is inmaintoo: my first baseline run ofmaindid not list it, and a run with--keep-goingon a cleanmaindoes.)cargo test --workspace --locked: run 1: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)); run 2: 567 passed, 0 failed, 12 ignored (mainalone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
@SantannaCarlos on GitHub · 2026-11-25 14:41 UTC · original
Follow-up on "Not covered" (requests past 131,070 groups in x). Setup: RTX 4070, 10-minute runs, this branch plus the cut counter.
pipelines/early-pipelines.txt), shader translations cold and the pipeline library deleted, as after an update: no request passes 131,070 groups on either save. The largest were 111,120 on the cell save and 112,136 on the other one, and only the lighting pass is cut, as before.pipelinesfolder empty, on one save, in the first ~2.5 minutes in the world, while 1,100 to 2,200 draws a frame waited for their pipelines. They stopped once the pipelines were made.VICTORY_DISPATCH_SPLIT=0made no difference to the warm-up: 6 frames over 1 s in the first minute against 8 with the split, worst 2.3 s against 2.2 s.@xunbreakablex on GitHub · 2026-11-25 15:20 UTC · original
Second RTX 4070 data point for the cut (AI-assisted, Claude; run on my machine): RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile. This branch (
edf762eona253706) plus a diagnostics-only frame-log counter of records over 65,535 groups in x.2dc364df5d3278b8is over the limit here too, in 278 frame-log lines of one run: 1-2 records per frame asking for 99,920-105,672 groups in x (e.g. frame 2220: "2 of 3 records over, the most asked 99920"; 2223: 105,672), all of them run with the split. WithVICTORY_SPLIT=0-style cutting (my second arm) the counter shows 92,152 and 90,872 requested and 65,535 run, i.e. about a third of the groups of that pass skipped every frame on defaultmain.@SpaghettiMaster545 on GitHub · 2026-11-25 15:37 UTC · original
More data on the same pass, from our tree (RTX 5070 Ti, NVIDIA 621.40, Windows 11).
indirect_diffuse_lighting:CS_FinalGather_0asks for 73,000 to 77,500 groups in x (y = z = 1) in the opening cutscene, about once a frame. Its last tiles are the blocky tiles along the bottom edge of the picture. We split such records into pieces of at most 65,535 groups, each with its own group base, and the tiles are gone. So whatever runs the groups past 65,535 fixes it; I am not opening a second PR for this.One trap we hit, in case a later version reads the count on the CPU: when the list is recorded, the record's title memory can still hold a value the title has not written yet. We read 4,294,903,655 once. We treat a count over 2^20 as not a count, and clamp it as before.
@FrancescoGelosoEterea on GitHub · 2026-11-25 16:12 UTC · original
Tested in game on an RTX 5070 Ti (16 GB, driver 621.24, Windows 11): this fixes the blocky "old picture" artifacts we had in the world.
Before: from a save past the prologue (a balcony over a garden and the sea), screen-aligned blocks on walls, the wooden floor, a glass railing and the sea showed pieces of an earlier view, for example trees and parked cars from where the camera had looked before. The blocks stayed put while the camera moved. A target dump of one such frame showed them already in the lit scene, before TAA.
Ruled out first, each in its own run with the artifacts unchanged:
VICTORY_QUEUE2offVICTORY_TEXTURE_GUARD=0VICTORY_LEVELS_ON_DEMANDoffVICTORY_WAVE_PAIRS=0(#854's paired form)VICTORY_INDIRECT_WINDOWoffWith this PR merged onto main
a253706(+ #854 and two local patches; the merge was clean), the artifacts are gone in the same scene:One thing worth knowing: the change to the translation invalidates the shader cache, so the first launch rebuilt about 2,600 pipelines. That was roughly 10 minutes of a mostly black picture, with missing colours and meshes. On the next launch, with the cache warm, everything was normal.
@SantannaCarlos on GitHub · 2026-11-25 16:55 UTC · original
Rebased onto
465b94f. That commit takes bit 2 of the clamp's flags word for gathered records ((has_count & 4u)), the bit this branch used for the split, so the split moves to bit 3 (8u); without that, every split dispatch would have been read as gathered. The description says bit 3 now. Thedraw.rsconflict was only the new gather path next to the split's lines; dispatches are never gathered.Checked on the rebased tree (WARP): all 16
indirecttests pass, including465b94f's gather tests and the split one;cargo test -p victory-gpu --all-features --lib -- --test-threads=1passes butdepth_bounds_pipeline_loads_and_filters_draws;victory-shader216 passed; the diagnostics build compiles; clippy reports only what465b94fitself reports.@tippythetaidum on GitHub · 2026-11-25 17:09 UTC · original
Tested in the title on an RTX 5080 16 GB (driver 621.14, Windows 11, Series X profile): the blocks along the bottom edge of the prison shots are gone.
Build: diagnostics build of
main3973179+ #24 + #927 + #823 + #606 + #956 + #1002 + #907, with this PR's earlier head0135c41on top. That's the commit before today's rebase; I haven't runb9ab1ee. It merged without conflict. The one change needed was a field in this PR's own test (half_views, from #927'sHostShader). With it,the_group_id_in_x_starts_at_the_host_baseandwarp_split_runs_every_group_of_a_wide_dispatch_oncepass on the card.The records: a local log of the dispatch records as the title wrote them showed
2dc364df5d3278b8asking for 75,128 to 98,512 groups in x in our frames, the same range as above.Picture, the same shots in runs of the same tree without and with the PR, warm caches:
Stability: no errors and no device loss in two 10-minute runs. The refused compute pipelines are the three that #823 leaves.
AI-assisted (Claude Code, Claude Opus 5.5). Counts and descriptions only, nothing from the game attached.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.