Dispatches past the host's group limit run in pieces, each told where its groups start #974

Closed
MoscaLosca wants to merge 1 commit from upstream-pr/976 into main
MoscaLosca commented 2026-11-25 14:30:14 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MoscaLosca on 2026-11-25T14:30:14Z.


What

A dispatch that asks for more thread groups in x than the host runs in one
dispatch (65,535) used to lose its tail, or hand the whole count to the driver.
Now:

  • Dispatch, DispatchX and DispatchMesh run as pieces of at most 65,535
    groups. The translated program adds the piece's first group to its group id
    (SV_DispatchThreadID and the mesh stage's group are built from the same op,
    so all of them move with it). The dword is one the host computes
    (USER_GROUP_BASE, an Other root kind after USER_VIEW_BIAS): bound to 0
    by every bind, set again before each piece from the second on.
  • A dispatch past the limit whose program reads no group id is clamped to
    65,535 with a note, instead of the whole count going to the driver.
  • The indirect light pass's compute record (the counted one, run 200, about
    77,500 groups in x) is not fixed: its count arrives in GPU memory, and
    splitting it would need the host to read each record's count, or a per-record
    group base the argument buffer does not carry. The clamp now counts these too
    (budget words 12 and 16, beside the mesh notes at 4 and 8), and the frame
    line reports the largest group count asked for, so the next run measures what
    the cut-off costs and whether the indirect split is worth building.

VICTORY_GROUP_SPLIT=0 restores the old behavior.

Status

  • Unit-tested: a program that reads its group id is checked to read the base
    with the split on and not with it off (victory-shader, 172 passed;
    victory-formats 25).
  • Clippy clean (Windows target, blake3/pure, also with diagnostics).
  • Not yet seen in a run of the title. The shader cache key includes the
    translator sources (build.rs), so nothing to clear by hand.
  • Watch for in the log: a dispatch asks for more groups in x than the host runs: it runs in pieces (the fix working, with the number of pieces),
    ... and its program reads no group id (an over-limit dispatch not
    recoverable), and the frame line's
    indirect compute dispatches: the largest group count asked for ....

README and docs/fork-ray-tracing.md updated, including the honest status.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6606814535 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/976). Originally posted by [MoscaLosca](https://github.com/MoscaLosca) on 2026-11-25T14:30:14Z. --- ## What A dispatch that asks for more thread groups in `x` than the host runs in one dispatch (65,535) used to lose its tail, or hand the whole count to the driver. Now: - `Dispatch`, `DispatchX` and `DispatchMesh` run as pieces of at most 65,535 groups. The translated program adds the piece's first group to its group id (`SV_DispatchThreadID` and the mesh stage's group are built from the same op, so all of them move with it). The dword is one the host computes (`USER_GROUP_BASE`, an `Other` root kind after `USER_VIEW_BIAS`): bound to 0 by every `bind`, set again before each piece from the second on. - A dispatch past the limit whose program reads no group id is clamped to 65,535 with a note, instead of the whole count going to the driver. - The indirect light pass's compute record (the counted one, run 200, about 77,500 groups in `x`) is **not** fixed: its count arrives in GPU memory, and splitting it would need the host to read each record's count, or a per-record group base the argument buffer does not carry. The clamp now counts these too (budget words 12 and 16, beside the mesh notes at 4 and 8), and the frame line reports the largest group count asked for, so the next run measures what the cut-off costs and whether the indirect split is worth building. `VICTORY_GROUP_SPLIT=0` restores the old behavior. ## Status - Unit-tested: a program that reads its group id is checked to read the base with the split on and not with it off (`victory-shader`, 172 passed; `victory-formats` 25). - Clippy clean (Windows target, `blake3/pure`, also with `diagnostics`). - **Not yet seen in a run of the title.** The shader cache key includes the translator sources (build.rs), so nothing to clear by hand. - Watch for in the log: `a dispatch asks for more groups in x than the host runs: it runs in pieces` (the fix working, with the number of pieces), `... and its program reads no group id` (an over-limit dispatch not recoverable), and the frame line's `indirect compute dispatches: the largest group count asked for ...`. README and `docs/fork-ray-tracing.md` updated, including the honest status.
SantannaCarlos commented 2026-11-25 15:08:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SantannaCarlos on 2026-11-25T14:33:53Z.


This and #834 are two halves of the same mechanism: #834 runs the indirect compute records past 65,535 groups in x as a second execution, this one splits direct and mesh dispatches. Both add a host-set dword, USER_GROUP_BASE at 0x104, to the group id in x where a program reads it, and both leave it at 0 everywhere else.

So if both go in, they should keep one constant and one lowering: resolving the conflict by keeping both lowering blocks would add the base twice. With one lowering, the host side of each is unchanged (this one sets the dword per piece of a direct or mesh dispatch, #834 sets it around the second indirect execution). I can rebase #834 onto this one if it lands first.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7165471096 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/976#issuecomment-7165471096). Originally posted by [SantannaCarlos](https://github.com/SantannaCarlos) on 2026-11-25T14:33:53Z. --- This and #834 are two halves of the same mechanism: #834 runs the indirect compute records past 65,535 groups in x as a second execution, this one splits direct and mesh dispatches. Both add a host-set dword, `USER_GROUP_BASE` at `0x104`, to the group id in x where a program reads it, and both leave it at 0 everywhere else. So if both go in, they should keep one constant and one lowering: resolving the conflict by keeping both lowering blocks would add the base twice. With one lowering, the host side of each is unchanged (this one sets the dword per piece of a direct or mesh dispatch, #834 sets it around the second indirect execution). I can rebase #834 onto this one if it lands first.
avt0m4t48 commented 2026-11-25 15:08:34 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-25T14:59:00Z.


I reproduced a local-ID regression on 23affc7. compute_id adds USER_GROUP_BASE to the X component of both groupId and threadIdInGroup. The synthetic shader writes both values to fixed output offsets. WARP returns the expected [0, 0] at base 0. At base 65,535 it returns [65535, 65535] instead of [0, 65535]. Derived indices and local groupshared indexing can then use a shifted local ID.

Restricting the addition to DXIL groupId fixes both readbacks. A shader that only reads its local ID also stops gaining group-base metadata. The fixture sets the piece base directly and exercises shader lowering and GPU readback. The host's command loop was checked separately in source, including piece boundaries, root indices, and the following zero-base bind. I did not run a retail dispatch.

The README's coverage sentence should also reflect the host fallback. The current host truncates an oversized dispatch when the shader lacks group-base metadata. A shader that reads no group X can still need every group to run, for example to contribute to an atomic counter.

WARP reproduction · Corrected Windows suite · Small candidate patch

AI-assisted using Codex.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7166118751 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/976#issuecomment-7166118751). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-25T14:59:00Z. --- I reproduced a local-ID regression on `23affc7`. `compute_id` adds `USER_GROUP_BASE` to the X component of both `groupId` and `threadIdInGroup`. The synthetic shader writes both values to fixed output offsets. WARP returns the expected `[0, 0]` at base 0. At base 65,535 it returns `[65535, 65535]` instead of `[0, 65535]`. Derived indices and local groupshared indexing can then use a shifted local ID. Restricting the addition to DXIL `groupId` fixes both readbacks. A shader that only reads its local ID also stops gaining group-base metadata. The fixture sets the piece base directly and exercises shader lowering and GPU readback. The host's command loop was checked separately in source, including piece boundaries, root indices, and the following zero-base bind. I did not run a retail dispatch. The README's coverage sentence should also reflect the host fallback. The current host truncates an oversized dispatch when the shader lacks group-base metadata. A shader that reads no group X can still need every group to run, for example to contribute to an atomic counter. [WARP reproduction](https://github.com/avt0m4t48/victory-fork/actions/runs/45638763121) · [Corrected Windows suite](https://github.com/avt0m4t48/victory-fork/actions/runs/45639378336) · [Small candidate patch](https://github.com/avt0m4t48/victory-fork/commit/1ae3e333b686547137dc7320b267e7093d886f3d) AI-assisted using Codex.
upstream-sync closed this pull request 2026-11-26 13:05:48 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!974
No description provided.