GPU: the indirect argument clamp cuts dispatches of more than 65,535 groups in x (spread over z instead) #2256
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#2256
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Coderlord on GitHub · 2026-11-25 09:01 UTC · original
What happens. The indirect argument clamp (
crates/victory-gpu/src/indirect.rs) bounds every dimension of a dispatch record to 65,535 (min(asked, 65535)), because D3D12 runs at most 65,535 groups per dimension. The console runs far more, and the title's own compute passes ask for more. Counted in the clamp on a fork, records ask for:The groups past 65,535 never run.
Evidence (RTX 5080, same build, only spreading toggled, runs at the same moment):
Because the darkening is global, not only in the rows the cut dropped, I suspect a value reduced over the whole pass that the cut never let finish (an exposure, or a step that only the last group to finish runs). I haven't confirmed whether the dark room is the title's intended look or a later pass reading that value wrong, so on the fork the fix is behind a switch for now.
The fix (tested on a fork). D3D12 has no base group for a dispatch, so the translated program has to help. It is built on fxceless's branch, which has host-computed user-data dwords:
The translated program. A compute program that reads its group id (the TGID SGPRs) asks the host for two more user-data dwords: the groups of one row (0 means not spread) and the groups asked for in x. When the row is not 0, the program:
x + z * rowin x and 0 in z;One pitfall here: branch out of the entry block only after the program's inputs are loaded. Some input code (thread ids numbered by console lane) makes a value in the current block and uses it in the entry block. Done before the inputs, this made 936 of the title's programs fail in the bitcode writer ("forward reference outside a phi").
The clamp, for such a pipeline. It writes each dispatch record as
[row, asked x, gx, gy, gz](20 bytes). A record of more than 65,535 groups in x and 1 in z goes out asceil(x / rows)byybyrows, whererows = ceil(x / 65535). So fewer thanrowsgroups are surplus.The command signature. Those pipelines' indirect dispatches use a command signature of two
D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANTarguments and the dispatch. The constants go into the user-data root constants at those two dwords' places. The signature is created with the pipeline's root signature, once per pipeline. (The next draw or dispatch sets all user data again, so the values the signature leaves behind don't matter.)Direct dispatches. A direct
Dispatchwith more than 65,535 groups in x is spread the same way on the CPU.Checks.
No existing issue or pull request seems to cover the cut. #956 adds command signatures with root constants for the title's own multi-argument signatures, which may share code with this.
RTX 5080 (driver 621.24), Windows 11.
Found, written and tested with Claude Code.
@Ingenioeren on GitHub · 2026-11-25 09:34 UTC · original
One additional test case for spreading is a shader whose original code never reads its group ID. It can still have a side effect for every group.
On
940d32f, I fed the existing indirect clamp two synthetic records on WARP:(65535, 2, 1)and(65537, 2, 1). The x field read back as 65,535 in both. I then dispatched a native SM 6.6 shader that only increments a UAV counter once per group. The RX 6750 XT and WARP returned identical counts. Current indirect clamp(65535, 2, 1)(32769, 2, 2), original shaderx + z * 32769 >= 65537guardThat makes the tail guard a correctness requirement even if the guest shader never consumes TGID. If the first implementation spreads only pipelines that already read TGID, this case can establish the current limit and guard against enabling spreading for side-effect-only pipelines without injecting the guard.
AI-assisted. Two synthetic checks passed. No title or fork patch was run.
@Calvix2k on GitHub · 2026-11-25 09:48 UTC · original
I looked at taking this upstream on
mainand want to state the shape before writing it, because the fork you built it on has a piece this tree does not.The spread needs the translated program's help, and on
maina compute program reads its group id throughdx.op.groupId(the SGPR "TGID" inputs are modelled as that), so there is nothing the host can offset alone. The upstream-sized change is:lower.rs: for a program that readsgroupId, add two host-provided user-data dwords (row width, asked x) and, when the row width is non-zero, compute the console group asx + z * rowand return before the console code when it is at or past the ask. The branch has to come after the program's input loads — your note about the 936 "forward reference outside a phi" failures is the constraint here.host/draw: reserve those two dwords per dispatch, fill them for direct dispatches, and dispatchceil(x / 65535)rows by re-dispatching with the row constant.indirect.rs+ command signature: the clamp shader rewrites a record to(row, asked, ceil(x/row), y, rows)and those pipelines' indirect dispatch uses a signature with two CONSTANT arguments feeding the same user-data dwords.That is a day-scale change in the translator and submission path, and two things make me want a maintainer's yes before starting:
I can start with (1) and (2) behind a switch, which is testable without the command signature and gives the translator work a landing place; is that wanted, or would the maintainers rather keep this on the fork until the darkening is understood?
@SantannaCarlos on GitHub · 2026-11-25 09:53 UTC · original
A data point on the darkening, from fxceless/victory-fork#834, which runs the groups past 65,535 in x of an indirect record as a second execution (a host-set base added to the group id in x, up to 131,070, indirect only) instead of spreading over z.
On an RTX 4070, default mode, from the cell save: the cut program there is
2dc364df5d3278b8, one record a frame of 85,000 to 115,200 groups in x. With all of its groups running, the room did not get darker. Mean luma of the whole picture from +200 to +1100 frames after the first world frame was 33.5, 33.3 and 47.7 in three runs with the split, and 38.3, 33.5, 35.9 and 49.9 in four without it. The two lightest runs without the split are the ones that kept the stale lower-right blocks. So on this card, running that pass in full does not change the exposure. If the room darkens with spreading, the difference is more likely in the spreading path (the other programs it covers, the direct dispatches, or the command signature's constants) than in the pass completing.The split also has no surplus groups: the second execution asks for exactly the groups past 65,535, so the side-effect case above only applies to the spreading form.
@Coderlord on GitHub · 2026-11-25 09:56 UTC · original
Thanks, all three of these help.
@SantannaCarlos, that settles where to look. On your card the pass runs in full and the room keeps its brightness, so the darkening I saw most likely comes from my spreading path, not from the pass completing. My path differs from fxceless/victory-fork#834 in two ways:
I'll A/B those on the RTX 5080 (spreading only through a second execution, as in #834) and post what I find.
@Ingenioeren, the fork spreads only pipelines whose program reads its group id: the prologue that guards the surplus is emitted only there. Every other pipeline is still cut, so your side-effect case can't run surplus groups there, though those dispatches also still lose their tail. Your counter test is a good one to add for whichever form lands.
@Calvix2k, #834's form looks like the better shape for
mainthan the one in this issue:Found, written and tested with Claude Code.
@Coderlord on GitHub · 2026-11-25 10:32 UTC · original
A follow-up with a measurement. In the RTX 5080 runs below, the darkening comes from the cut groups running, whichever way they run, not from the spreading path.
I took the spread over z out of the fork and cherry-picked fxceless/victory-fork#834 as it is (thanks @SantannaCarlos). Then I ran the same build with and without its split, from a new game into the first gameplay shot (the cell window). The runs were 7 minutes each at 1080p, with the same scripted presses and a warm cache:
VICTORY_DISPATCH_SPLIT=0)On this card the room darkens in both forms, and only when the cut groups run. In C the window also turned grainy and the fence disappeared, which A did not show. Your RTX 4070 runs started from the cell save rather than a new game, so the scene's state may differ. That would explain the difference better than the spreading path does.
So the open question is the pass itself, or whatever reads its outputs, on this card. Your description says that pass writes five 2560x1440 views and one 1280x720 view. Next, I'll compare its outputs with and without the split at the same frame to see which one darkens the room. Meanwhile the fork keeps #834's code with the split off by default.
Found, written and tested with Claude Code.
@Coderlord on GitHub · 2026-11-25 11:46 UTC · original
A correction to my last comment: the darkening is not caused by running the cut groups.
Two more runs of the same #834 build, at the same frame (frame 2400, about 75 s into the first gameplay shot), with a warm cache:
VICTORY_DISPATCH_SPLIT=1)A third warm run with the split on (G) saved frames 2200 and 2600: also lit (whole-frame luma 45.2 and 46.4), with a clean bottom edge. Along the bottom-right edge where the blocks show, the luma is 3.3 to 3.4 with the split on and 25.8 with it off.
Run E shows what #834 is for: the blocks are gone and the room looks as it does with the cut. The two dark runs in my table (A and C) were both the first run after a translator change. The driver was still compiling pipelines through the opening cutscene, and draws and dispatches waited or were dropped meanwhile. A warm run with every group running (E) is lit, so the darkening goes with that cold start, not with the split or the spread. Sorry for the noise. Your RTX 4070 numbers fit this.
I'm turning the split on by default in the fork.
Found, written and tested with Claude Code.
@Xvania7 on GitHub · 2026-11-25 11:49 UTC · original
Opened #2312 (eat/spread-large-dispatches) addressing this on main: direct dispatches with x > 65,535 && z == 1 and indirect dispatches bound via indirect::bound_spread spread the grid across z (remapping group IDs in the compute shader prologue via a hidden root constant). All CI checks passed and verified against
940d32f.@Coderlord on GitHub · 2026-11-25 12:15 UTC · original
One more data point, so my last comment doesn't overclaim. I ran #834's build with the split on and the pipeline library moved aside, so every pipeline was made during the run as in runs A and C. The room was lit. So a cold pipeline start alone doesn't bring the dark room back.
Tally on the RTX 5080, from a new game:
victory translate --warm. The three lit runs came after.I can't explain it yet. It may be intermittent, but nothing I've measured ties it to the split.
Found, written and tested with Claude Code.
@iGoldenNinja on GitHub · 2026-11-25 12:18 UTC · original
One same-launch RTX 5080 follow-up on the NVIDIA fork's PR 834 (
0135c41), driver 617.14 and Windows 11 Pro 25H2 build 26200.9974. I toggled only the diffuse-lighting dispatch split while the camera stayed at the prison window at 1735 × 911. Most of the band cleared after the second record restored the missing groups. Turning the split off again immediately clipped the GPU arguments, and the cleared region persisted in both sampled frames at that view. This is consistent with earlier writes persisting in the affected tiles. Pinned diagnostic and numbersTesting and reporting assisted by OpenAI Codex.
@Marvisak on GitHub · 2026-11-25 15:52 UTC · original · edited 2026-11-26 00:50 UTC
Automated triage for the maintainers.
Confirmed on main (
63bcca4). The indirect argument clamp shader incrates/victory-gpu/src/indirect.rsstill doesmin(args.Load3(at), uint3(65535, 65535, 65535)), so groups past 65,535 in a dimension never run. Main has no base-group or spreading path. Open PR #2312 spreads such dispatches across z with a group-id remap in the compute prologue. It needs a rebase. The thread's later measurements (warm runs) tie the dark room seen in some runs to something other than running the cut groups, so it is not an argument against fixing the cut.New since the last triage: on an RTX 3080 Ti (driver 621.24), raising only the clamp's x bound let a 67,440-group indirect dispatch run whole, and the blocky band in the prison-cell scene went away. D3D12 documents 65,535 as the limit, so that relies on driver behaviour on one card and is not a portable fix. Spreading (#2312) or a second execution with a host-set base, as discussed above, stays within the limit.
The thread also asks whether a smaller, switch-gated upstream form is wanted; that is a decision for the maintainers.
Generated by Claude Code
@Machad3x on GitHub · 2026-11-25 23:26 UTC · original
A data point for NVIDIA without spreading: on an RTX 3080 Ti (driver 621.24, Windows 11) an indirect dispatch of 67,440 x 1 x 1 groups runs whole. Raising only the clamp's x bound to 2^20 (the expression follows avatarmanz/VIctory-7900XTX
84eae352, which does this for AMD cards), a test on the card counts every group once, the highest group id 67,439; with the 65,535 clamp it counts 65,535.In the title: one 7-minute run with that change, Series X mode, the blocky band along the bottom of the window scene in the prison cell was gone in the screenshots (present in the run before, same build otherwise), no device removal. The cell walls were dark in both runs, so this says nothing about the darkening discussed above.
D3D12 documents 65,535 as the limit and does not validate indirect counts, so this is driver behaviour, not a guarantee; one card and driver tested.
Ran with AI assistance (Claude Code).