GPU: skip empty direct draw calls #2937

Closed
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/2939 into main
andrewpozdnakov7-jpg commented 2026-11-26 00:56:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T00:56:10Z.


A direct DrawInstanced or DrawIndexedInstanced with zero vertices, indices, or instances still requests a pending graphics pipeline today. Return before preparation when either count is zero. The list still counts the guest call, and nonempty draws keep requesting their pipeline. This is the direct-graphics counterpart of #2556, and the two branches merge cleanly.

The same Windows/WARP test exercises both entry points, with a fresh pending pipeline per case. For each entry point the cases are zero vertices or indices, zero instances, and a nonempty draw.

Revision Unindexed demand Indexed demand
63bcca43c6a00a758510398fa43096ce7e4f7df0 yes, yes, yes yes, yes, yes
1440d8c711364b85914ad0cc7a4c788e9921e7c9 no, no, yes no, no, yes

The regression failed on main and passed with the patch in all six paired runs. Full WARP GPU suite passed with 247 tests and one ignored under both D3D12 debug settings. Strict GPU Clippy in both configurations and asset policy passed.

Coordination · DrawInstanced · DrawIndexedInstanced

Please retain the Git author if cherry-picking the change. If folding the fix or test into another commit, please include Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6617014756 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2939). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T00:56:10Z. --- A direct `DrawInstanced` or `DrawIndexedInstanced` with zero vertices, indices, or instances still requests a pending graphics pipeline today. Return before preparation when either count is zero. The list still counts the guest call, and nonempty draws keep requesting their pipeline. This is the direct-graphics counterpart of #2556, and the two branches merge cleanly. The same Windows/WARP test exercises both entry points, with a fresh pending pipeline per case. For each entry point the cases are zero vertices or indices, zero instances, and a nonempty draw. | Revision | Unindexed demand | Indexed demand | | --- | --- | --- | | `63bcca43c6a00a758510398fa43096ce7e4f7df0` | yes, yes, yes | yes, yes, yes | | `1440d8c711364b85914ad0cc7a4c788e9921e7c9` | no, no, yes | no, no, yes | The regression failed on main and passed with the patch in all six paired runs. Full WARP GPU suite passed with 247 tests and one ignored under both D3D12 debug settings. Strict GPU Clippy in both configurations and asset policy passed. [Coordination](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7179181876) · [DrawInstanced](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-drawinstanced) · [DrawIndexedInstanced](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-drawindexedinstanced) Please retain the Git author if cherry-picking the change. If folding the fix or test into another commit, please include `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic tests only.
upstream-sync closed this pull request 2026-11-26 02:06:35 +00:00
fuzeofficlal commented 2026-11-26 02:06:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:08:16Z.


Code review and RTX 5090 + WARP verification at head 1440d8c71136 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-gpu/src/draw.rs:1563-1565, 1670-1672):
    • Returning early on vertices == 0 || instances == 0 in State::draw and indices == 0 || instances == 0 in State::draw_indexed skips trace, completes_rectangles (host_pipeline), and prepare so zero-count direct draws never push unused graphics pipelines into on-demand compilation (host.used).
    • Title state fields remain independently tracked on State and lazily sync against host snapshots on the next non-empty draw, with no state desync or missed resource transitions.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy (default + --features diagnostics): 0 warnings
    • draw::tests pipeline:: list::: 48/48 passed on RTX 5090 (default) and 51/51 passed on WARP (--features diagnostics), including zero_count_draws_do_not_request_graphics_pipelines.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179469934 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2939#issuecomment-7179469934). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:08:16Z. --- Code review and RTX 5090 + WARP verification at head `1440d8c71136` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-gpu/src/draw.rs:1563-1565, 1670-1672`)**: - Returning early on `vertices == 0 || instances == 0` in `State::draw` and `indices == 0 || instances == 0` in `State::draw_indexed` skips `trace`, `completes_rectangles` (`host_pipeline`), and `prepare` so zero-count direct draws never push unused graphics pipelines into on-demand compilation (`host.used`). - Title state fields remain independently tracked on `State` and lazily sync against host snapshots on the next non-empty draw, with no state desync or missed resource transitions. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy` (default + `--features diagnostics`): 0 warnings - `draw::tests pipeline:: list::`: **48/48 passed** on RTX 5090 (default) and **51/51 passed** on WARP (`--features diagnostics`), including `zero_count_draws_do_not_request_graphics_pipelines`. LGTM.
andrewpozdnakov7-jpg commented 2026-11-26 02:06:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T01:12:25Z.


Closing the duplicate in favor of #2654, which already has the same fix and covers both graphics entry points through the guest list vtable.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179539347 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2939#issuecomment-7179539347). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T01:12:25Z. --- Closing the duplicate in favor of #2654, which already has the same fix and covers both graphics entry points through the guest list vtable.

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!2937
No description provided.