Skip to content

GPU: skip pipeline demand for empty direct draws - #2654

Open
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex1/skip-empty-draws
Open

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex1/skip-empty-draws

Conversation

@andrewpozdnakov7-jpg

@andrewpozdnakov7-jpg andrewpozdnakov7-jpg commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Direct DrawInstanced and DrawIndexedInstanced with no vertices, indices or instances still request a host PSO. That can queue work and consume pipeline wait budget before the next draw. Return before preparing state for these empty calls. This covers the two graphics entry points. The related compute change is #2556.

The same WARP test calls the normal VIctory list vtable with a fresh pending pipeline for each case. On 13f91ca, all four empty cases mark the pipeline as used. On 5a603b0, none marks it. The nonempty instanced and indexed controls still request their pipelines. Six alternating A/B runs covered both D3D12 debug flag settings.

The serial victory-gpu suite passed with 199 passed and 1 ignored in each setting. Strict GPU Clippy in both modes and repository policy passed. Local merge checks with #2556, #2624 and the offered #1254 rebase were clean. AI-assisted. Synthetic tests only.

Coordination claim

Please preserve the Git author when reapplying the change. If you fold the code or test into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

Current main retest

The original guest-vtable test on 63bcca43c6a00a758510398fa43096ce7e4f7df0 requests a pipeline for all four empty cases. The same test with 5a603b00b1343bea8188de74bfb7a5521161b9b3 merged locally into that base requests none of them. Both nonempty controls request a pipeline. Six paired WARP runs, full GPU suite with 247 passed and one ignored under both D3D12 debug settings, strict GPU Clippy, and asset policy passed.

@kotekompotek

Copy link
Copy Markdown

Reviewed: early-out on vertices == 0 || instances == 0 (and the indexed variant) is right — an empty draw demands nothing from the pipeline, and on titles that issue degenerate draws this avoids useless pipeline creation. The test creates a real allocator/list on the host device. CI green.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent verification of head 5a603b00b1343bea8188de74bfb7a5521161b9b3 on origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (the PR is based on it; merges cleanly, fast-forward).

Environment: Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set for every run; victory-gpu tests were only run with --features diagnostics (without it the crate opens the default adapter). Limits: no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware.

  • Focused: cargo test -j 4 --locked -p victory-gpu --features diagnostics empty_draws_do_not_request -> pipeline::make::tests::empty_draws_do_not_request_graphics_pipelines 1 passed (ran, not skipped: it needs a D3D12 device and WARP provided one).
  • Full crate: 199 passed, 0 failed, 1 ignored. origin/main baseline (cargo test -j 4 --locked -p victory-gpu --features diagnostics): 197 passed, 1 failed (memory::tests::a_submission_that_missed_leaves_the_copies_at_once, memory.rs:886), 1 ignored. That test passed in all four PR runs, so it looks flaky; I did not investigate it, and none of these PRs touch memory.rs.
  • cargo clippy -j 4 --locked -p victory-gpu --all-targets [--features diagnostics | --all-features] -- -D warnings: clean.
  • Negative control: restored draw.rs from origin/main (kept the test) -> the test fails: left: [true, true, true, true], right: [false, false, false, false] (all four empty cases request a pipeline). With the fix it passes, and the two non-empty cases still request one.
  • Code read: both guards sit before the diagnostics trace, so empty draws no longer show up in the trace either; that looks intended but is a visible change.
  • Nit, not blocking: the test is in pipeline/make.rs but exercises draw.rs through a raw vtable offset (0x60/0x68/0xc8), which breaks quietly if the list layout changes.

AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. State::draw and State::draw_indexed (crates/victory-gpu/src/draw.rs) now return before doing anything when the vertex/index or instance count is zero, so such draws no longer ask for a host pipeline or spend wait budget on one. A zero-count draw does nothing under D3D12 rules, and the next real draw still prepares all its state, so nothing visible is lost. The only side effect is that empty draws disappear from the diagnostics draw trace. The WARP test in pipeline/make.rs drives the list through its vtable and checks that the empty cases leave the pipeline unrequested while the non-empty ones still request it; the IIDs it uses are the public PC D3D12 ones. It merges cleanly; CI check: passing.


Generated by Claude Code

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • cargo test -p victory-gpu --lib pipeline::make::tests: 3 passed, 0 failed (including new empty_draws_do_not_request_graphics_pipelines).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified 5a603b00 merged locally onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 and WARP, Rust 1.98.1 MSVC, Windows SDK 10.0.26100.0 dxil.dll; synthetic tests only, no game files).

Verification

  • git merge-tree against origin/main (63bcca43) and combined with #2696: clean.
  • cargo xtask policy (PR head): 184 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features, both PR head and merged): 0 warnings.
  • RTX 5090 (merged, default): cargo test --locked -p victory-gpu --lib -- pipeline::make::tests draw::tests — 23 passed, 0 failed (including empty_draws_do_not_request_graphics_pipelines).
  • RTX 5090 (VICTORY_D3D12_DEBUG=1, --features diagnostics): 24 passed, 0 failed.
  • WARP (VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1, --features diagnostics): 24 passed, 0 failed.
  • Combined #2654 + #2696 on 63bcca43 (RTX 5090): Clippy clean in both feature modes; pipeline::tests, pipeline::make::tests, and draw::tests — 27 passed, 0 failed.

Review Notes

  • Early-returning in State::draw (crates/victory-gpu/src/draw.rs:1486-1496) and State::draw_indexed (crates/victory-gpu/src/draw.rs:1592-1603) when the vertex/index or instance count is zero is a strict D3D12 no-op. Skipping before self.prepare avoids queuing host PSO work or burning pipeline wait budget while leaving draw::State untouched for subsequent non-empty draws.
  • The guest-vtable regression test in crates/victory-gpu/src/pipeline/make.rs:340-401 cleanly covers all four zero-count combinations plus both non-empty controls.

Looks good to merge.

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants