perf(agc): record render passes, barriers and copies in the trace summary #18948

Merged
Ethan-Hainline merged 2 commits from upstream-pr/18948 into main 2026-11-13 06:10:05 +00:00
Ethan-Hainline commented 2026-11-12 15:29:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ethan-Hainline on 2026-11-12T15:29:30Z.


What

Adds a machine-readable graphics track to the trace summary (aps5-summary.jsonl), the stage-1 instrumentation asked for on #17533: render passes, barriers and copies, per interval, next to frame_ms and gpu_busy_ms_per_present.

New graphics_track object, all counts summed across threads:

Scope Counted in Meaning
Graphics.RenderPass Draw.cpp, now via PerformanceTrace::Amount render passes begun (summary-only sessions now record it)
Graphics.RenderPass.Continued Recorder::StartDrawPass draws that joined the open pass
Graphics.RenderPass.Close.<reason> Recorder::endOpenRenderPass why each pass closed: new-batch, command, label, samples, forced, segment, key, raw, waw, war, image, unknown-read, unknown-write
Graphics.Barrier.<class> Recorder::CountBarriers recorded barriers by command class (all 17 classes)
Graphics.BarrierMerged.<class> Recorder::CountMerged leading barriers elided by a covering trailing barrier
Graphics.Copy, Graphics.Copy.bytes CopyBuffer and the two render-target image copies copy commands and bytes

PerformanceTrace::Amount(scope, amount) adds weighted counts to the existing per-thread totals, so TraceFormat::Since already gives each summary interval its own delta (the same path owned_draw_counts uses). Amount checks Recording() and drops the count when tracing is off, the same way CountOwnedDraw does.

Only these count scopes enter graphics_track. The timed Graphics.Draw, Graphics.DrawWithRecipe, Graphics.Submit and Graphics.Wait scopes stay in top_phases_ms_per_frame, so paired runs do not lose them.

Documented in docs/dev/BUILD.md; no production behavior changes.

Tested

  • agc_performance_trace passes: the exact summary line now includes graphics_track, and the new case asserts that Graphics.Barrier.draw and Graphics.Copy.bytes are summed across threads (4+3 = 7 and 65536), that Graphics.RenderPass is counted, and that a timed Graphics.Draw (5 ms) still lands in top_phases_ms_per_frame and is absent from graphics_track.
  • libSceAgcDriver and agc_performance_trace_tests build on Windows (WinLibs GCC 16.2.0 UCRT, Release).
  • With APS5_TRACE_* unset, CountBarriers/CountMerged keep their previous early return; Amount returns after the Recording() check, like the existing weighted counts.
  • GPUs tested: n/a for the unit test; the counters sit on the existing draw/barrier/copy sites already exercised by the AGC tests.

Companion tool changes render the object per interval in tools/trace_digest.py (#18949) and compare its per-present rates in tools/performance_compare.py (#18955).

Checklist

  • Based on current main; one topic per PR
  • Depends on: none
  • Fixes: none (instrumentation for #17533)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5280215337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18948). Originally posted by [Ethan-Hainline](https://github.com/Ethan-Hainline) on 2026-11-12T15:29:30Z. --- ### What Adds a machine-readable graphics track to the trace summary (`aps5-summary.jsonl`), the stage-1 instrumentation asked for on #17533: render passes, barriers and copies, per interval, next to `frame_ms` and `gpu_busy_ms_per_present`. New `graphics_track` object, all counts summed across threads: | Scope | Counted in | Meaning | |---|---|---| | `Graphics.RenderPass` | `Draw.cpp`, now via `PerformanceTrace::Amount` | render passes begun (summary-only sessions now record it) | | `Graphics.RenderPass.Continued` | `Recorder::StartDrawPass` | draws that joined the open pass | | `Graphics.RenderPass.Close.<reason>` | `Recorder::endOpenRenderPass` | why each pass closed: `new-batch`, `command`, `label`, `samples`, `forced`, `segment`, `key`, `raw`, `waw`, `war`, `image`, `unknown-read`, `unknown-write` | | `Graphics.Barrier.<class>` | `Recorder::CountBarriers` | recorded barriers by command class (all 17 classes) | | `Graphics.BarrierMerged.<class>` | `Recorder::CountMerged` | leading barriers elided by a covering trailing barrier | | `Graphics.Copy`, `Graphics.Copy.bytes` | `CopyBuffer` and the two render-target image copies | copy commands and bytes | `PerformanceTrace::Amount(scope, amount)` adds weighted counts to the existing per-thread totals, so `TraceFormat::Since` already gives each summary interval its own delta (the same path `owned_draw_counts` uses). `Amount` checks `Recording()` and drops the count when tracing is off, the same way `CountOwnedDraw` does. Only these count scopes enter `graphics_track`. The timed `Graphics.Draw`, `Graphics.DrawWithRecipe`, `Graphics.Submit` and `Graphics.Wait` scopes stay in `top_phases_ms_per_frame`, so paired runs do not lose them. Documented in `docs/dev/BUILD.md`; no production behavior changes. ### Tested - `agc_performance_trace` passes: the exact summary line now includes `graphics_track`, and the new case asserts that `Graphics.Barrier.draw` and `Graphics.Copy.bytes` are summed across threads (4+3 = 7 and 65536), that `Graphics.RenderPass` is counted, and that a timed `Graphics.Draw` (5 ms) still lands in `top_phases_ms_per_frame` and is absent from `graphics_track`. - `libSceAgcDriver` and `agc_performance_trace_tests` build on Windows (WinLibs GCC 16.2.0 UCRT, Release). - With `APS5_TRACE_*` unset, `CountBarriers`/`CountMerged` keep their previous early return; `Amount` returns after the `Recording()` check, like the existing weighted counts. - GPUs tested: n/a for the unit test; the counters sit on the existing draw/barrier/copy sites already exercised by the AGC tests. Companion tool changes render the object per interval in `tools/trace_digest.py` (#18949) and compare its per-present rates in `tools/performance_compare.py` (#18955). ### Checklist - [x] Based on current `main`; one topic per PR - [x] Depends on: none - [x] Fixes: none (instrumentation for #17533) - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
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
boykopovar/AnyPS5!18948
No description provided.