GPU diagnostics: pipeline statistics per noted command with VICTORY_GPU_TIMING #1723
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1723
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1723"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@LarryBebou on GitHub · 2026-11-24 21:19 UTC · original
LarryBebou:diag/timing-pipeline-statistics→main· +118 −2 · 2 files · 2 commits · openWhy
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.70564ae) into diag/timing-pipeline-statistics 5542340831@LarryBebou on GitHub · 2026-11-24 21:25 UTC · original
Correction to my report above, from two more runs on the same RTX 5060 (
ffe310e+ #1349, diag build,VICTORY_D3D12_DRED=1 VICTORY_GPU_TIMING=1, with the per-command pipeline statistics of #1723).AI-assisted (Claude Code); measured on my own machine.
What I got wrong
I 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:
mesh 3 [mesh 51ff151f75cd5759, pixel 7fe75645c406cac6]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)
VICTORY_SHADER_LOOP_LIMIT=64(every stage)db4835a364449a45/c10e7d95d8266d2a) in a 0.57 s submissionOne 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
8bbcbda6008eaa37(CSInvocations 122,944) takes 0.32–0.39 s per dispatch uncapped and is not what hangs.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).
@aycow on GitHub · 2026-11-24 21:58 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 03:36 UTC · original · edited 2026-11-25 15:55 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts inREADME.md). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge candidate) was for an older state ofmain.Generated by Claude Code
@DenRakEiw on GitHub · 2026-11-24 21:26 UTC · original · approved these changes
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— okClean opt-in pipeline statistics query heap and readback under
VICTORY_GPU_TIMINGwith clear documentation inREADME.md. Looks good.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-24 21:37 UTC · original · reviewed
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.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 07:50 UTC · original
@LarryBebou I tested
5542340and the same fixture with the fix and regression test inc66d2f2oncodex2/pr1723-timing-stats.CSInvocationsin recording order16, 56, 2416, 56, 2416, 56, 24Reset40, 840, 840, 8The 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
VICTORY_GPU_TIMING=1andVICTORY_D3D12_WARP=1, then run this once withVICTORY_D3D12_DREDunset and once with it set.If you fold the changes or fixture into another commit, please retain
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.