feat(agc): trace slices and GPU ranges carry the recorder batch they belong to #5046

Merged
parl0v merged 1 commit from upstream-pr/5046 into main 2026-10-14 12:00:56 +00:00
parl0v commented 2026-10-13 09:35:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-13T09:35:30Z.


What

A trace (#4526, GPU track #4632) shows the GPU's batches and the CPU's packet slices, but nothing ties a GPU batch to the work that recorded it. On a dispatch-heavy scene the GPU track is a row of unlabeled batch slices, some taking 10+ ms, with no way to tell which packets filled them.

  • A recorder batch takes a trace id when it opens while a trace records (Batch::traceId, from a counter; 0 when no trace records).
  • The thread that opened the batch stamps that id on every slice it records afterwards (TraceBatchTag, thread-local, read in TraceThread::Add).
  • The batch's GPU ranges, the whole-batch range and its command-class ranges, carry the same id (TraceGpuRange::batch, GpuSlices).
  • TraceFormat::Events writes the id as "args":{"batch":N} on X events that have one; events without an id keep their current shape.

Tested

  • Windows 10 19045, i5-14400F, RTX 4060, MinGW-w64 GCC 15.2. agc_performance_trace passes, with a new BatchIds case: a slice's id in the JSON, a thread's tag on Add, and a GPU range keeping its id through GpuSlices. The libs target builds.
  • PPSA25344 (main menu, APS5_TRACE_SECONDS=60:20), on the SotS working-group base with #4526/#4581/#4632 ported: 10,399 of 10,406 GPU slices and 299,401 of 301,361 CPU slices carry an id. Joining on it gives each GPU batch the packets that recorded it, e.g. the 16 ms batches of that scene each come from ~1.6 ms of Driver.Packet.dispatch work.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4841260524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5046). Originally posted by [parl0v](https://github.com/parl0v) on 2026-10-13T09:35:30Z. --- ### What A trace (#4526, GPU track #4632) shows the GPU's batches and the CPU's packet slices, but nothing ties a GPU batch to the work that recorded it. On a dispatch-heavy scene the GPU track is a row of unlabeled `batch` slices, some taking 10+ ms, with no way to tell which packets filled them. - A recorder batch takes a trace id when it opens while a trace records (`Batch::traceId`, from a counter; 0 when no trace records). - The thread that opened the batch stamps that id on every slice it records afterwards (`TraceBatchTag`, thread-local, read in `TraceThread::Add`). - The batch's GPU ranges, the whole-batch range and its command-class ranges, carry the same id (`TraceGpuRange::batch`, `GpuSlices`). - `TraceFormat::Events` writes the id as `"args":{"batch":N}` on `X` events that have one; events without an id keep their current shape. ### Tested - Windows 10 19045, i5-14400F, RTX 4060, MinGW-w64 GCC 15.2. `agc_performance_trace` passes, with a new `BatchIds` case: a slice's id in the JSON, a thread's tag on `Add`, and a GPU range keeping its id through `GpuSlices`. The `libs` target builds. - PPSA25344 (main menu, `APS5_TRACE_SECONDS=60:20`), on the SotS working-group base with #4526/#4581/#4632 ported: 10,399 of 10,406 GPU slices and 299,401 of 301,361 CPU slices carry an id. Joining on it gives each GPU batch the packets that recorded it, e.g. the 16 ms batches of that scene each come from ~1.6 ms of `Driver.Packet.dispatch` work. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-14 11:27:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:27:35Z.


Rebased onto current main (the conflict was adjacency with TraceInterval from #4812 and the GpuRange signature; both kept). agc_performance_trace and the rest of the libSceAgcDriver tests pass on Linux (only agc_driver_tessellation segfaults, as on main); the new BatchIds case fails to build without the change. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167281216 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5046#issuecomment-6167281216). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T11:27:35Z. --- Rebased onto current `main` (the conflict was adjacency with `TraceInterval` from #4812 and the `GpuRange` signature; both kept). `agc_performance_trace` and the rest of the libSceAgcDriver tests pass on Linux (only `agc_driver_tessellation` segfaults, as on `main`); the new `BatchIds` case fails to build without the change. Merging once the full Build is green.
github-actions[bot] commented 2026-10-14 12:00:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T12:00:23Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5813 core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp L108
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167840778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5046#issuecomment-6167840778). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T12:00:23Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5813 | `core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp` [L108](https://github.com/boykopovar/AnyPS5/blob/c7844d9cb5a3d5811a810359d85d97bf3fe98742/core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp#L108) | | |
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!5046
No description provided.