Repository navigation
GPU diagnostics: pipeline statistics per noted command with VICTORY_GPU_TIMING - #1723
LarryBebou wants to merge 2 commits into
Conversation
…PU_TIMING With timing on, each noted command also gets a pipeline-statistics query (begun at its note, ended at the next one or at close, resolved with the timestamps). The slow-command lines then say how many primitives reached the rasterizer, how many were rasterized and how often the pixel and compute shaders ran, so a slow draw can be told from one that rasterizes a large area. On an RTX 5060 this showed world mesh draws of 128 to 1,920 primitives and fewer than 1,500 pixel shader runs taking about 100 ms each (Marvisak#71).
|
Correction to my report above, from two more runs on the same RTX 5060 ( AI-assisted (Claude Code); measured on my own machine. What I got wrongI wrote that the slow world mesh draws are not slow because of overdraw. That holds for the small draws I had counters for, but not for the draw I had named as the 12.7 s one: its counters were lost with the device in that run. Now measured:
184 rasterized primitives give 51 million pixel shader runs: about six full 3840×2160 screens. So this draw does cover the screen many times over with a handful of primitives, which is what wrong vertex positions would look like. Also, the per-command times are less reliable than I implied: on this card a draw seems to be charged the wait for work queued before it. I would trust the counters (primitives, shader runs) and the per-submission times, not a single command's milliseconds. Two runs with loop caps (as measurements, not fixes)
One run each, so the difference between the last two rows may be chance. What the third row does say: with compute loops left alone and only pixel/mesh/vertex loops capped, the longest submission stays under half a second here, which fits @HenriqueSBueno's result on the RTX 3080 above. The compute What I think it points to (not shown)Draws like the one above rasterize screen-sized primitives, and every covered pixel then runs a pixel program with data-bounded loops. A cap hides the cost; the cause to look for is why the mesh stage gets such positions (the stream that draw reads is filled by an earlier pass). |
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):
cargo test -p victory-gpu— 50 passed, 0 failed (1 ignored) on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok
Clean opt-in pipeline statistics query heap and readback under VICTORY_GPU_TIMING with clear documentation in README.md. Looks good.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Pipeline statistics per noted command: a query heap + readback buffer are created lazily (stats() -> Option), and VICTORY_GPU_TIMING gates the per-command notes. README updated to say the timing switch needs DRED for the notes. Small, well-scoped diagnostics addition. The interplay with DRED (GPU-based validation removal) is the risky part — worth a Windows run with an actual title before merge.
Two conflicts, both kept from each side: the README row for VICTORY_GPU_TIMING (the counters, and main's device-removal sentence), and HostList::reset (the open statistics query, and main's targets).
|
A bounded native control held 64 authored triangles, draw shape and viewport fixed and varied only clip W. AMD pixel invocations rose from 17,664 at W=1 to 65,536 at W=.125. WARP covered the same pixels while reporting different PSInvocations and CPrimitives. CInvocations stayed at 64 for both positive-W runs. For the reported title draw, an authored primitive count and projected-bounds distribution would complement the clipping counters. I checked compatibility with #509 at bfc60cf. The branches conflict in host.rs and README, and census mode suppresses the legacy timing path. Paired runs use #509 for pipeline identity, spans and CPU build cost, and #1723 for invocation counters, with the same scene and whole-submission timing. This keeps per-command wait attribution out of the estimate. AI-assisted using Codex. |
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
|
@LarryBebou I tested
The fixture submits one list and reads the production slow-command formatter after the fence. For each label it checks the expected counter and the exact delta of the corresponding GPU timestamp pair, even when the rows are sorted by time. The final dispatch is included in both recordings, and the second report contains only its two new labels. The fix enables queries when timing is on, keeps DRED markers conditional, and closes the final statistics query before resolving the samples. It also lets the slow-list warning run for a single submitted list. The app-local WARP diagnostics suite passed 81 tests and the timing fixture passed separately in both DRED modes. The full system WARP suite had one placed-texture test failure that passed with app-local WARP. To rerun on Windows, set cargo test --locked -p victory-gpu --features diagnostics --lib host::timing_stats_warp::timing_stats_follow_commands_through_close_and_reset -- --ignored --exact --nocapture --test-threads=1If you fold the changes or fixture into another commit, please retain AI-assisted. |
Why
VICTORY_GPU_TIMING=1says which commands of a slow list took longest, but not what they did on the GPU. In #71 that left a question open for the slow world mesh draws: are they slow because they rasterize a huge area, or before rasterization?What
With timing on, each noted command also gets a
D3D12_QUERY_TYPE_PIPELINE_STATISTICSquery: begun at its note, ended at the next note or atclose, and resolved next to the timestamps. The slow-command lines then start with four of its counters:VICTORY_GPU_TIMINGset: without it no query heap is made and nothing is recorded.stats_open), so queries never nest;resetclears it.STAMPScommands per list).VICTORY_GPU_TIMINGrow mentions the counters.What it showed here (RTX 5060, driver 32.0.16.2124,
ffe310e+ #1349)World mesh draws of 128 to 1,920 primitives and fewer than 1,500 pixel shader runs take about 100 ms each, so their time is not overdraw. Details in my comment on #71.
Since then, one more run with
VICTORY_SHADER_LOOP_LIMIT=64(as a measurement, not a fix): GPU time per world frame fell from seconds to about 0.2 s and the slowest mesh draw from about 100 ms to 1.2 ms, although the native code of the pair I looked at (51ff151f75cd5759/7fe75645c406cac6) has no backward branch. The device was still removed after 62 s, at an indirect mesh draw in a 0.57 s submission.Verification
cargo clippy --workspace --all-targets --locked -- -D warnings: passedcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passedcargo test --workspace --locked: passedcargo xtask policy: passed (154 files)VICTORY_D3D12_DRED=1 VICTORY_GPU_TIMING=1on the RTX 5060: counters logged for every slow command.Limits
PIPELINE_STATISTICS1) are not used: the plain query works on every host.