metal: VICTORY_PASS_TIMING=draw — per-draw/per-dispatch GPU timing at draw/dispatch boundaries (#460 follow-up) #600

Open
opened 2026-11-28 11:33:16 +00:00 by AnastasisKon · 5 comments
AnastasisKon commented 2026-11-28 11:33:16 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T11:33:16Z.


What happens

VICTORY_PASS_TIMING=1 (#460, PR #594) samples each pass encoder's start and end, so a render pass of 500 draws is timed as one lump. Apple GPUs also support counter sampling at draw and dispatch boundaries (MTLCounterSamplingPointAtDrawBoundary / AtDispatchBoundary; an AGXG15X supports both, but not blit — see #594). Per-draw times would name the expensive draws inside a pass, not just the pass.

Fix

A finer mode of the same switch, e.g. VICTORY_PASS_TIMING=draw (or =2): sample at the pass encoder's start, at each draw/dispatch boundary inside the pass, and at its end; consecutive resolved timestamps then give per-draw and per-dispatch durations. Log per pass the N most expensive draws by pipeline hash and draw index (the pass's own lines today give the pass lump). Blit passes stay untimed where the device lacks AtBlitBoundary. Unit test: a synthetic two-draw render pass (zero-draw trick won't do — needs two draws, so a real pipeline from the test fixtures, or two dispatches of the affine compute) yields per-draw intervals that sum to about the pass interval.

Off by default like the rest; documented in docs/native-host.md.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6664262602 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:33:16Z. --- ## What happens `VICTORY_PASS_TIMING=1` (#460, PR #594) samples each pass encoder's start and end, so a render pass of 500 draws is timed as one lump. Apple GPUs also support counter sampling at draw and dispatch boundaries (`MTLCounterSamplingPointAtDrawBoundary` / `AtDispatchBoundary`; an AGXG15X supports both, but not blit — see #594). Per-draw times would name the expensive draws inside a pass, not just the pass. ## Fix A finer mode of the same switch, e.g. `VICTORY_PASS_TIMING=draw` (or `=2`): sample at the pass encoder's start, at each draw/dispatch boundary inside the pass, and at its end; consecutive resolved timestamps then give per-draw and per-dispatch durations. Log per pass the N most expensive draws by pipeline hash and draw index (the pass's own lines today give the pass lump). Blit passes stay untimed where the device lacks `AtBlitBoundary`. Unit test: a synthetic two-draw render pass (zero-draw trick won't do — needs two draws, so a real pipeline from the test fixtures, or two dispatches of the affine compute) yields per-draw intervals that sum to about the pass interval. Off by default like the rest; documented in docs/native-host.md.
AnastasisKon commented 2026-11-28 11:33:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T11:33:48Z.


/claim

Taking this follow-up to #460 (PR #594): a draw mode of VICTORY_PASS_TIMING that samples at each draw/dispatch boundary inside a pass (AtDrawBoundary/AtDispatchBoundary, which Apple GPUs support), so per-draw costs are named, not just the pass lump. Blit stays per-encoder (no AtBlitBoundary on G15X-class). Unit test with two dispatches of the test compute shader. Draft PR from my fork's vibe/ branch to follow.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238634136 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7238634136). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:33:48Z. --- /claim Taking this follow-up to #460 (PR #594): a `draw` mode of VICTORY_PASS_TIMING that samples at each draw/dispatch boundary inside a pass (AtDrawBoundary/AtDispatchBoundary, which Apple GPUs support), so per-draw costs are named, not just the pass lump. Blit stays per-encoder (no AtBlitBoundary on G15X-class). Unit test with two dispatches of the test compute shader. Draft PR from my fork's vibe/ branch to follow.
github-actions[bot] commented 2026-11-28 11:33:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T11:33:58Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #600 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238635987 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7238635987). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T11:33:58Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #600` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 12:37:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:37:14Z.


/release - done: PR #602 adds VICTORY_PASS_TIMING=draw for per-draw/per-dispatch GPU timing. Carried in my fork's main (69146296) on top of #594.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239352618 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239352618). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:37:14Z. --- /release - done: PR #602 adds `VICTORY_PASS_TIMING=draw` for per-draw/per-dispatch GPU timing. Carried in my fork's `main` (69146296) on top of #594.
AnastasisKon commented 2026-11-28 12:42:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:42:14Z.


/release - done: PR #602 adds VICTORY_PASS_TIMING=draw for per-draw/per-dispatch GPU timing. Carried in my fork's main (69146296) on top of #594.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239408997 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239408997). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:42:14Z. --- /release - done: PR #602 adds `VICTORY_PASS_TIMING=draw` for per-draw/per-dispatch GPU timing. Carried in my fork's `main` (69146296) on top of #594.
github-actions[bot] commented 2026-11-28 12:42:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T12:42:24Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239410924 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239410924). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T12:42:24Z. --- Released. This issue is free to claim.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#600
No description provided.