Proposal: GPU time per pass on the native Metal path (and later, record and replay of one world frame) #460
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Hayyan612 on 2026-11-27T21:03:44Z.
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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-27T21:53:20Z.
/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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T21:53:30Z.
Claimed by @marcus-4. Open a draft pull request with
Refs #460in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:19:17Z.
/release
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:24:43Z.
/release
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T08:24:53Z.
Released. This issue is free to claim.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T10:40:07Z.
/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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T10:40:18Z.
Claimed by @AnastasisKon. Open a draft pull request with
Refs #460in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:47:52Z.
/release - done, first two steps: PR #594 adds
VICTORY_PASS_TIMING(GPU time per pass at each encoder boundary) and PR #602 addsVICTORY_PASS_TIMING=draw(per draw and per dispatch), both in my fork'smain, with #597 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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T12:48:02Z.
Released. This issue is free to claim.