AGC: splitting a dispatch over maxComputeWorkGroupCount with vkCmdDispatchBase uses a base at or past the limit #7375

Closed
opened 2026-10-18 03:22:03 +00:00 by milescoviello · 0 comments
milescoviello commented 2026-10-18 03:22:03 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T03:22:03Z.


What

VulkanDevice splits a compute dispatch whose group count exceeds maxComputeWorkGroupCount into vkCmdDispatchBase chunks (288ee89d2d, #3212). Each chunk after the first starts at a base equal to a multiple of the limit, for example baseGroupX = 65535 on a device whose limit is 65535. The spec doesn't allow that:

  • VUID-vkCmdDispatchBase-baseGroupX-00421: baseGroupX must be less than maxComputeWorkGroupCount[0].
  • The count rules that follow it: groupCountX must be at most maxComputeWorkGroupCount[0] minus baseGroupX.

The same rules apply to Y and Z. Together they keep base + count within the limit, so vkCmdDispatchBase cannot reach a group id at or past maxComputeWorkGroupCount in any dimension. A dispatch over the limit can't be split validly this way at all.

Evidence

agc_driver_oversized_dispatch under the Khronos validation layer 1.3.275 on lavapipe (ANYPS5_GPU=llvmpipe, limit 65535), main b39d90bf14:

VUID-vkCmdDispatchBase-baseGroupX-00421 ... vkCmdDispatchBase(): baseGroupX (65535) equals or exceeds device limit maxComputeWorkGroupCount[0] (65535).

The test passes, so lavapipe tolerates the invalid call. That is the only vkCmdDispatchBase error in a validation-layer run of all 691 ^agc_ tests there.

The split throws on NVIDIA because, as 288ee89d2d measured, the driver "drops the first workgroups of a vkCmdDispatchBase dispatch with a nonzero base". On NVIDIA the X limit is 2^31 - 1 and the Y and Z limits are 65535, so a split happens only in Y or Z, and its second chunk starts at a base of 65535. That is the invalid case above. I haven't checked whether the dropped workgroups are this undefined behaviour or something else; NVIDIA may also behave that way for a valid nonzero base.

A possible direction

A split that stays valid on every driver would dispatch each chunk with vkCmdDispatch from group 0, and have the shader add the chunk's offset to WorkgroupId and GlobalInvocationId. The offset could come from a push constant or shader data dword, as DispatchThreadLimit is read today. The device-memory LDS case, which throws today, would also need the total group counts rather than the chunk's NumWorkgroups. This is only a sketch and not implemented.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5905721523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7375). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T03:22:03Z. --- ### What `VulkanDevice` splits a compute dispatch whose group count exceeds `maxComputeWorkGroupCount` into `vkCmdDispatchBase` chunks (288ee89d2d, #3212). Each chunk after the first starts at a base equal to a multiple of the limit, for example `baseGroupX = 65535` on a device whose limit is 65535. The spec doesn't allow that: - `VUID-vkCmdDispatchBase-baseGroupX-00421`: `baseGroupX` must be less than `maxComputeWorkGroupCount[0]`. - The count rules that follow it: `groupCountX` must be at most `maxComputeWorkGroupCount[0]` minus `baseGroupX`. The same rules apply to Y and Z. Together they keep `base + count` within the limit, so `vkCmdDispatchBase` cannot reach a group id at or past `maxComputeWorkGroupCount` in any dimension. A dispatch over the limit can't be split validly this way at all. ### Evidence `agc_driver_oversized_dispatch` under the Khronos validation layer 1.3.275 on lavapipe (`ANYPS5_GPU=llvmpipe`, limit 65535), `main` b39d90bf14: ``` VUID-vkCmdDispatchBase-baseGroupX-00421 ... vkCmdDispatchBase(): baseGroupX (65535) equals or exceeds device limit maxComputeWorkGroupCount[0] (65535). ``` The test passes, so lavapipe tolerates the invalid call. That is the only `vkCmdDispatchBase` error in a validation-layer run of all 691 `^agc_` tests there. ### Possibly related The split throws on NVIDIA because, as 288ee89d2d measured, the driver "drops the first workgroups of a vkCmdDispatchBase dispatch with a nonzero base". On NVIDIA the X limit is 2^31 - 1 and the Y and Z limits are 65535, so a split happens only in Y or Z, and its second chunk starts at a base of 65535. That is the invalid case above. I haven't checked whether the dropped workgroups are this undefined behaviour or something else; NVIDIA may also behave that way for a valid nonzero base. ### A possible direction A split that stays valid on every driver would dispatch each chunk with `vkCmdDispatch` from group 0, and have the shader add the chunk's offset to `WorkgroupId` and `GlobalInvocationId`. The offset could come from a push constant or shader data dword, as `DispatchThreadLimit` is read today. The device-memory LDS case, which throws today, would also need the total group counts rather than the chunk's `NumWorkgroups`. This is only a sketch and not implemented. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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
boykopovar/AnyPS5#7375
No description provided.