GPU: DispatchMesh with no groups in a dimension runs nothing, and its group counts are not multiplied #2298

Closed
denkencar-sketch wants to merge 1 commit from upstream-pr/2300 into main
denkencar-sketch commented 2026-11-25 10:05:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:37Z.


Summary

DispatchMesh multiplied its group counts, which overflowed u32 for large counts, and a zero y or z still dispatched x groups. A dispatch with no groups in a dimension now runs nothing and the counts are not multiplied.

Testing

Test mesh_dispatches_with_overflowing_or_zero_groups_do_nothing fails on main (overflow abort) and passes with this change. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not covered by an assertion: the zero-group early return ((16,0,1) and (0,1,1) also pass on main). Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601985712 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2300). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:37Z. --- ## Summary `DispatchMesh` multiplied its group counts, which overflowed `u32` for large counts, and a zero y or z still dispatched x groups. A dispatch with no groups in a dimension now runs nothing and the counts are not multiplied. ## Testing Test `mesh_dispatches_with_overflowing_or_zero_groups_do_nothing` fails on `main` (overflow abort) and passes with this change. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not covered by an assertion: the zero-group early return (`(16,0,1)` and `(0,1,1)` also pass on `main`). Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 11:04:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:16Z.

Review: COMMENTED


DispatchMesh with a zero group dimension runs nothing; product-overflow case covered by test. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055713325 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2300#pullrequestreview-6055713325). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:16Z. **Review:** COMMENTED --- DispatchMesh with a zero group dimension runs nothing; product-overflow case covered by test. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Marvisak commented 2026-11-25 16:09:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:20:58Z.


Automated triage for the maintainers.

Merge candidate (worth a look). In crates/victory-gpu/src/list.rs, state::dispatch_mesh used to warn only when y * z != 1 and then always called State::dispatch_mesh(list, x), which records DispatchMesh(x, 1, 1), so a title call with y or z set to 0 still ran x groups. D3D12 documents that a 0 in any dimension dispatches nothing, and this PR now returns early in that case; it also drops the y * z product, which aborts in a checked build when it overflows. I checked that the early return comes before any host state is touched, that count_draw still counts the call, and that DispatchMeshX is unaffected.

Small note: the new test only catches the overflow abort; as the description says, the zero-group calls also pass on main, so the early return itself is not tested. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166701620 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2300#issuecomment-7166701620). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:20:58Z. --- <!-- victory-triage v1 head=3c6fe2e95ece0ff3302817570b6312d1f1adc422 verdict=merge-candidate at=2026-11-25T15:28:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** In `crates/victory-gpu/src/list.rs`, `state::dispatch_mesh` used to warn only when `y * z != 1` and then always called `State::dispatch_mesh(list, x)`, which records `DispatchMesh(x, 1, 1)`, so a title call with y or z set to 0 still ran x groups. D3D12 documents that a 0 in any dimension dispatches nothing, and this PR now returns early in that case; it also drops the `y * z` product, which aborts in a checked build when it overflows. I checked that the early return comes before any host state is touched, that `count_draw` still counts the call, and that `DispatchMeshX` is unaffected. Small note: the new test only catches the overflow abort; as the description says, the zero-group calls also pass on `main`, so the early return itself is not tested. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 23:04:12 +00:00
Marvisak commented 2026-11-25 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:08:09Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing as a duplicate of #2014, which makes the same change to the same function and tests the zero-dimension cases as well as the overflow. The change itself is right.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175980606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2300#issuecomment-7175980606). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:08:09Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing as a duplicate of #2014, which makes the same change to the same function and tests the zero-dimension cases as well as the overflow. The change itself is right. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

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
Marvisak/VIctory!2298
No description provided.