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

Open
opened 2026-11-28 11:39:45 +00:00 by github-bot · 5 comments
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 11:33 UTC · original

What happens

VICTORY_PASS_TIMING=1 (#464, PR #598) 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 #598). 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** on GitHub · 2026-11-28 11:33 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600) ## What happens `VICTORY_PASS_TIMING=1` (#464, PR #598) 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 #598). 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 11:39:46 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 11:33 UTC · original

/claim

Taking this follow-up to #464 (PR #598): 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.

**@⁠AnastasisKon** on GitHub · 2026-11-28 11:33 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7238634136) /claim Taking this follow-up to #464 (PR #598): 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.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 11:33 UTC · original

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

**@⁠github-actions[bot]** on GitHub · 2026-11-28 11:33 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7238635987) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #600` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 12:37 UTC · original

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

**@⁠AnastasisKon** on GitHub · 2026-11-28 12:37 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239352618) /release - done: PR #606 adds `VICTORY_PASS_TIMING=draw` for per-draw/per-dispatch GPU timing. Carried in my fork's `main` (69146296) on top of #598.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 12:42 UTC · original

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

**@⁠AnastasisKon** on GitHub · 2026-11-28 12:42 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239408997) /release - done: PR #606 adds `VICTORY_PASS_TIMING=draw` for per-draw/per-dispatch GPU timing. Carried in my fork's `main` (69146296) on top of #598.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 12:42 UTC · original

Released. This issue is free to claim.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 12:42 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/600#issuecomment-7239410924) Released. This issue is free to claim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.