Proposal: GPU time per pass on the native Metal path (and later, record and replay of one world frame) #464
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS#464
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Hayyan612 on GitHub · 2026-11-27 21:03 UTC · original
The native host times whole command buffers (
GPUEndTime - GPUStartTimeinvictory-metal/src/gfx.rs), not passes, so a slow pass in a world frame cannot be told from the others. On the Wine route, #47 found its frame recorder and replayer, with per-pass GPU times and leave-one-pass-out costs, the tool that helped most. victory-fork and cool_fox use the same (VICTORY_RECORD,docs/replay.mdthere); victory-fork found, for one, that two water-lighting programs cost about 15 ms a frame.Step 1, small:
VICTORY_PASS_TIMING=1(off by default). AnMTLCounterSampleBuffersampled at each encoder's start and end (stage-boundary sampling, which Apple GPUs support), resolved when the buffer completes. Log the N most expensive passes of a world frame, by pipeline hash and draw count.Step 2, later: record one world frame's submissions and the title memory they read to a folder outside the repo, and replay it on its own with per-pass times. That makes a shader or pipeline change measurable on a real frame without playing to it again.
Not claiming. I can write step 1 with a test on a synthetic two-pass frame, if it is wanted.
@marcus-4 on GitHub · 2026-11-27 21:53 UTC · original
/claim
I'm taking step 1 only (
VICTORY_PASS_TIMING=1), not the record and replay. Thanks for writing it up, @Hayyan612. If you'd rather do it yourself, say so and I'll release it.Plan
supportsCounterSampling(.atStageBoundary), true on Apple GPUs), each compute, render and blit pass the native host encodes gets a pair of timestamp samples. OneMTLCounterSampleBufferholds the slots, allocated per command buffer, and passes are attached through their pass descriptors (sampleBufferAttachments). Compute passes are made withcomputeCommandEncoderWithDescriptoronly while the switch is on, so nothing changes with it off.sampleTimestamps, and add each pass's time to its key: the pipeline hash (orblit), plus the draw or dispatch count.pass timing), plus the total and the share of command-buffer GPU time the passes cover. A device without the counters logs that once and times nothing.victory-metal, Metal): a synthetic frame of a short and a long compute pass, plus a blit, where the long pass must rank first, with nonzero times that add up to no more than the command buffer's own GPU time.Draft PR within the day.
@github-actions[bot] on GitHub · 2026-11-27 21:53 UTC · original
Claimed by @marcus-4. Open a draft pull request with
Refs #460in its description within 24 hours, or the claim expires.@marcus-4 on GitHub · 2026-11-28 08:19 UTC · original
/release
@marcus-4 on GitHub · 2026-11-28 08:24 UTC · original
/release
@github-actions[bot] on GitHub · 2026-11-28 08:24 UTC · original
Released. This issue is free to claim.
@AnastasisKon on GitHub · 2026-11-28 10:40 UTC · original
/claim
Taking step 1 only: (off by default) — an sampled at each encoder's start/end, resolved on completion, logging the most expensive passes of a world frame by pipeline hash and draw count — plus a unit test on a synthetic two-pass command buffer. Step 2 (record/replay) stays open. Draft PR from my fork's vibe/ branch to follow.
@github-actions[bot] on GitHub · 2026-11-28 10:40 UTC · original
Claimed by @AnastasisKon. Open a draft pull request with
Refs #460in its description within 24 hours, or the claim expires.@AnastasisKon on GitHub · 2026-11-28 12:47 UTC · original
/release - done, first two steps: PR #598 adds
VICTORY_PASS_TIMING(GPU time per pass at each encoder boundary) and PR #606 addsVICTORY_PASS_TIMING=draw(per draw and per dispatch), both in my fork'smain, with #601 making run-summary.sh summarise the lines. The parenthetical part of the proposal, record and replay of one world frame, is still open and is not covered by these; freeing the claim on the timing part so it can be picked up separately.@github-actions[bot] on GitHub · 2026-11-28 12:48 UTC · original
Released. This issue is free to claim.