Skip to content

diag(gpu): GPU time per pipeline on D3DMetal, where timestamps read 0 (VICTORY_GPU_TIMING_CUTS) - #646

Merged
pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
mikebuckets171:contrib/gpu-timing-cuts
Nov 28, 2026
Merged

pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
mikebuckets171:contrib/gpu-timing-cuts

Conversation

@mikebuckets171

@mikebuckets171 mikebuckets171 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

On a Mac, VICTORY_GPU_TIMING=1 cannot say which pipeline a list's time went to. D3D12 timestamps read 0 under D3DMetal, so the report reads lists 264.5 ms/frame of wall time, their commands 0.0 ms/frame. The two loop-to-the-limit passes found so far (#148, #610) were each found by hand.

What

VICTORY_GPU_TIMING_CUTS (diagnostics builds; it turns VICTORY_GPU_TIMING on). A title list goes on in a fresh host list around the draws and dispatches of a few pipelines at a time, the same move as after a wait or for #570's clamp cut. Each such host list then runs one pipeline, and timing mode already submits and waits for every list on its own, so the list's wall time is that pipeline's GPU time. Everything else stays together, so the frame keeps its shape.

  • =<hash>,<hash>: the pipelines with a listed 16-digit shader hash, for the whole run.
  • =sweep (or sweep:<n>, 16 by default): n of the pipelines the title is drawing with, in the order it first drew with them, the next n after every frame-rate line. Standing still for a few minutes times every pipeline of the scene, draws included.

Every frame-rate line is followed by:

GPU wall time by pipeline: 317.7 timed lists/frame, 279.7 ms/frame; a list's floor 0.201 ms (tenth percentile); 50 lines; the sweep goes on with 24 of the 1395 pipelines drawn with
  GPU wall 73.98 ms (73.78 above the floor) in 1.0 lists, 115.0 commands a frame, in 12 frames: dispatch [compute b6df66af105d8b2d]
  GPU wall 18.06 ms (17.86 above the floor) in 1.0 lists, 1.0 commands a frame, in 15 frames: dispatch [compute 63381c3250b287fa]
  ...

Figures are per frame the pipeline had lists in, because a pipeline's turn starts and ends inside a report's frames. The floor is what an empty list costs (the tenth percentile of all lists' wall time).

Unset or 0, nothing changes, and without the diagnostics feature the cut is compiled out.

Measured

M5 Pro, 48 GB, macOS 27.2, D3DMetal 4.0 beta 3, Series X, 1280x720, diagnostics build, VICTORY_FAULT_TRACKING=1. First prison room, standing still, no input, medians of the 5-second report lines. One run each.

patch commit exe SHA-256 report lines frame GPU timed lists/frame
VICTORY_GPU_TIMING=1 (main d1609d9 + #610's commit, its switch off) n/a bf896c4562fa 20 409.1 ms 262.7 ms n/a
=b6df66af105d8b2d,63381c3250b287fa d3627cf 9fca98797cf2 19 411.3 ms 260.3 ms 254.8
=sweep (16) 8269961 2f2d2d2f10cc 56 401.9 ms 261.9 ms 269.9
=sweep:24 33d7908 (this change before the rebase) f08ab16ad89b 60 437.9 ms 280.8 ms 317.7

So listing two pipelines, or sweeping 16 at a time, leaves the frame where plain timing has it; 24 at a time costs about 7%.

What it found on main d1609d9 in that room:

pipeline listed sweep:24
compute b6df66af105d8b2d (the hair pass of #610), 112 to 115 dispatches in one list 76.0 ms 73.8 ms
compute 63381c3250b287fa, one dispatch 18.7 ms 17.9 ms
costliest draw pipeline n/a 5.4 ms

The sweep timed 1,199 pipelines in 330 s. Cross-check for the first row: #610's switch on the same Mac took GPU time from 262.7 to 163.1 ms (same exe, off and on). After those two, no pipeline is above 6 ms a frame.

Two cautions for reading it:

  • A draw pipeline in lists of its own ends a render pass at each of them, so its figure includes that. The pipelines' figures add up to more than the frame's GPU time (364 ms against 281 ms): rank with them, don't add them up.
  • An earlier form of this gave every compute pipeline lists of its own. A world frame became about 2,000 host lists, video memory grew by 12 GB, frames took 7 to 27 s, and it blamed ebe4e53f031f5249 for 2 to 15 s a frame. Listed alone, that pipeline costs 0.7 ms. That mode is not in this PR.

Verification

On 33d7908 (this change on main d1609d9), M5 Pro, Wine + D3DMetal 4.0 beta 3:

  • cargo test --workspace --locked --no-fail-fast: 772 passed, 0 failed, 23 ignored.
  • tools/macos/test-wine.sh --workspace --locked --no-fail-fast -- --test-threads=1: 1,549 passed, 0 failed, 40 ignored.
  • cargo clippy --target x86_64-pc-windows-gnullvm --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy: 300 files ok.
  • Seven unit tests in timing_cuts.rs (the switch's values, what is cut, the sweep's order with pipelines coming and going, the ranking, a pipeline timed in part of a report's frames); they ran in both suites.
  • The five files it touches have as many rustfmt hunks as on main; the new file has none.

Then rebased onto d1b5e54 without conflicts (this head); both Windows clippy runs and the unit tests pass again there. The game runs above were made before the rebase, on the commits the table names.

Not covered: other Macs, and Windows hosts (where timestamps advance and the cuts are not needed).

Prepared with Claude Opus 5.5 and Claude Fable 5.2 (Claude Code).

…NG_CUTS)

D3D12 timestamps all read 0 under D3DMetal, so VICTORY_GPU_TIMING times
whole host lists on a Mac and cannot say which pipeline of a list took
the time. With VICTORY_GPU_TIMING_CUTS a title list goes on in a fresh
host list around the draws and dispatches of a few pipelines at a time
(as it does after a wait or for a clamp cut), so each such list runs one
pipeline and its wall time is that pipeline's; everything else stays
together and the frame keeps its shape. A list of shader hashes takes
those pipelines; 'sweep' takes 16 at a time of the pipelines the title is
drawing with, the next ones after every frame-rate line. Each frame-rate
line is followed by the pipelines ranked by their time above the lists'
floor, per frame they had lists in. Diagnostics builds only; off, nothing
changes.
@pragyaangaur
pragyaangaur merged commit 6942f51 into pragyaangaur:main Nov 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants