feat(run-report): count milestones, frames, GPU and shader diagnostics #15705

Merged
oneandonlydean merged 16 commits from upstream-pr/15705 into main 2026-11-05 08:24:15 +00:00
oneandonlydean commented 2026-11-04 08:14:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-04T08:14:36Z.


What

Adds what a run observed to the run report written by #14235 (the writer): how far it got, the frames it presented, the GPU, and shader and image-format counters. Until now these sections were marked as not collected (coverage false); now they are collected (coverage true).

  • Milestones and frames. loaded/started (macOS entry bridge only), firstDraw (a batch that carries a recorded guest draw or dispatch was accepted by the GPU queue), firstPresent and framesPresented (guest display buffers the swapchain queue accepted), and the average frame rate between the first and last presented frame.
  • GPU. Vendor, name, driver text and Vulkan API version of the device the driver selected (system.gpu).
  • Shaders. Counts of shaders compiled, failed and served from the cache; the instruction that ended a shader compile because the recompiler could not translate it (encoding family, opcode, numeric value; undecodable words after the end of a program are skipped by the decoder and are not reported); the guest image formats looked up and those it rejected; the descriptor kinds shaders bind, with their use.
  • Quit. The window system's request to quit is recorded as the reason a run ended (quit-requested) instead of guest-exit.
  • The recompiler reports through a small diagnostic sink (DiagnosticSink.hpp), a table of function pointers installed once by the driver library; with no sink installed nothing changes. UnsupportedInstructionError now carries the encoding, the opcode value and the throw site.
  • The counters are relaxed atomics (or a bounded table under a timed lock) and are only touched while a report is being collected: the hot-path sites in the driver read a function-local static const bool first.
  • The first-draw mark is kept per thread with the command buffer's batch: a submit consumes it, a batch released without a successful submit forgets it, and a batch that is handed the same buffer handle later carries nothing.

This is the third of four PRs; it depends on the writer (#14235). The fourth (recovery of a killed run) also rewrites RunReport.cpp: whichever of the two lands second reruns the privacy sweep and kill-and-recover tests with both sets of fields. Not here: the stop kinds that name a missing function, an unsupported shader or an unsupported format when a run ends in an abort, and recovery of a run that was killed.

Tested

Linux (workstation). run_report_tests: 52 passed, 0 failed, 2 not run (no comma-decimal locale installed; the junction test is Windows only). ctest of the tests selected from this diff (CMake directories of libc, libSceVideoOut, libSceAgcDriver, libkernel, libSceJson2 and the shared-memory tests) plus public_headers (65), run_report* and agc_run_report*: 437 tests, 100% passed, 7 skipped by the tests themselves (video_out_flip_cpuflip_in_order, video_out_frame_dump_queue, video_out_frame_dump_wait, video_out_frame_dump_cpu_queue, video_out_telemetry_caption, pad_sdl, pad_port0: they need a display and are skipped in the same way in other builds on this machine). The new agc_run_report_shader_failure test checks the sink: an unsupported instruction is reported with its encoding, each compile attempt is counted once as a compile or a failure (cached and uncached), and the guest-work marks behave as described; CommandBatchFailure has new cases for the mark's lifetime. As a check that the tests pin the behaviour, taking the first-present milestone out of the frame counter makes frames and observations fail; with it restored they pass.
Cost, report on versus off. A game-less entry (run_report_tests --child exit, 300 runs, three rounds, medians): 1.47 ms off, 1.77 ms on, so 0.30 ms added to a run (0.25 ms of that is the writer in #14235). Per call, 2,000,000 calls each, median of 5 runs: with the report off every hook is about 0.4 ns (a null check); on: Enabled 0.4 ns, frame presented 17.3 ns, milestone 14.6 ns, shader 4.6 ns, image format 24.4 ns, descriptor 22.7 ns. No title was run, so the cost on a real draw path is not measured.
Not run: Windows and macOS (the platform code, MainThreadMacOs.cpp, the Windows run of the new tests); any title, so the GPU fields, firstDraw and firstPresent have not been seen on a real game or on more than one GPU.

Things reviewers may question

  • Hot paths. Counters in Draw.cpp, the recorder, the present path and the texture-format lookup. Each is guarded by a cached static const bool; the measured per-call costs are above, but not on a real title.
  • Overlap with open PRs. Files this PR edits that other open PRs also edit: VulkanDevice.cpp (125 open PRs), Draw.cpp (96), Recompiler.cpp (57), Recorder.cpp (41), VideoOutDriver.cpp (8). Expect conflicts to be resolved per PR.
  • A new diagnostic-sink API in the shader recompiler for something that is not shader compilation. It is a single pointer slot with a few function pointers, installed by the driver library.
  • Definitions. What "first draw" and "first present" mean (accepted by the queue, not visible pixels; a dispatch that is submitted and waited for on its own does not count) are described in docs/user/run-report.md, not in code, because code comments are limited to technical debt.
  • Counting. The format counters count lookups, not images; the descriptor counters count bindings as shaders are prepared, not distinct shaders (also in the docs).
  • The per-thread mark table (8 entries) for the first-draw milestone is small and lossy by design: a full table drops one mark.
  • Windows and macOS are not run (see Tested). The macOS entry bridge is the only source of loaded and started.

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: #14235
  • Fixes: none
  • Unblocks: none
  • GPUs tested: none (no title run; the tests above run without a GPU title)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5151153733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15705). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-04T08:14:36Z. --- ### What Adds what a run observed to the run report written by #14235 (the writer): how far it got, the frames it presented, the GPU, and shader and image-format counters. Until now these sections were marked as not collected (`coverage` false); now they are collected (`coverage` true). - **Milestones and frames.** `loaded`/`started` (macOS entry bridge only), `firstDraw` (a batch that carries a recorded guest draw or dispatch was accepted by the GPU queue), `firstPresent` and `framesPresented` (guest display buffers the swapchain queue accepted), and the average frame rate between the first and last presented frame. - **GPU.** Vendor, name, driver text and Vulkan API version of the device the driver selected (`system.gpu`). - **Shaders.** Counts of shaders compiled, failed and served from the cache; the instruction that ended a shader compile because the recompiler could not translate it (encoding family, opcode, numeric value; undecodable words after the end of a program are skipped by the decoder and are not reported); the guest image formats looked up and those it rejected; the descriptor kinds shaders bind, with their use. - **Quit.** The window system's request to quit is recorded as the reason a run ended (`quit-requested`) instead of `guest-exit`. - The recompiler reports through a small diagnostic sink (`DiagnosticSink.hpp`), a table of function pointers installed once by the driver library; with no sink installed nothing changes. `UnsupportedInstructionError` now carries the encoding, the opcode value and the throw site. - The counters are relaxed atomics (or a bounded table under a timed lock) and are only touched while a report is being collected: the hot-path sites in the driver read a function-local `static const bool` first. - The first-draw mark is kept per thread with the command buffer's batch: a submit consumes it, a batch released without a successful submit forgets it, and a batch that is handed the same buffer handle later carries nothing. This is the third of four PRs; it depends on the writer (#14235). The fourth (recovery of a killed run) also rewrites `RunReport.cpp`: whichever of the two lands second reruns the privacy sweep and kill-and-recover tests with both sets of fields. Not here: the stop kinds that name a missing function, an unsupported shader or an unsupported format when a run ends in an abort, and recovery of a run that was killed. ### Tested Linux (workstation). `run_report_tests`: 52 passed, 0 failed, 2 not run (no comma-decimal locale installed; the junction test is Windows only). ctest of the tests selected from this diff (CMake directories of `libc`, `libSceVideoOut`, `libSceAgcDriver`, `libkernel`, `libSceJson2` and the shared-memory tests) plus `public_headers` (65), `run_report*` and `agc_run_report*`: 437 tests, 100% passed, 7 skipped by the tests themselves (`video_out_flip_cpuflip_in_order`, `video_out_frame_dump_queue`, `video_out_frame_dump_wait`, `video_out_frame_dump_cpu_queue`, `video_out_telemetry_caption`, `pad_sdl`, `pad_port0`: they need a display and are skipped in the same way in other builds on this machine). The new `agc_run_report_shader_failure` test checks the sink: an unsupported instruction is reported with its encoding, each compile attempt is counted once as a compile or a failure (cached and uncached), and the guest-work marks behave as described; `CommandBatchFailure` has new cases for the mark's lifetime. As a check that the tests pin the behaviour, taking the first-present milestone out of the frame counter makes `frames` and `observations` fail; with it restored they pass. Cost, report on versus off. A game-less entry (`run_report_tests --child exit`, 300 runs, three rounds, medians): 1.47 ms off, 1.77 ms on, so 0.30 ms added to a run (0.25 ms of that is the writer in #14235). Per call, 2,000,000 calls each, median of 5 runs: with the report off every hook is about 0.4 ns (a null check); on: `Enabled` 0.4 ns, frame presented 17.3 ns, milestone 14.6 ns, shader 4.6 ns, image format 24.4 ns, descriptor 22.7 ns. No title was run, so the cost on a real draw path is not measured. Not run: Windows and macOS (the platform code, `MainThreadMacOs.cpp`, the Windows run of the new tests); any title, so the GPU fields, `firstDraw` and `firstPresent` have not been seen on a real game or on more than one GPU. ### Things reviewers may question - **Hot paths.** Counters in `Draw.cpp`, the recorder, the present path and the texture-format lookup. Each is guarded by a cached `static const bool`; the measured per-call costs are above, but not on a real title. - **Overlap with open PRs.** Files this PR edits that other open PRs also edit: `VulkanDevice.cpp` (125 open PRs), `Draw.cpp` (96), `Recompiler.cpp` (57), `Recorder.cpp` (41), `VideoOutDriver.cpp` (8). Expect conflicts to be resolved per PR. - **A new diagnostic-sink API in the shader recompiler** for something that is not shader compilation. It is a single pointer slot with a few function pointers, installed by the driver library. - **Definitions.** What "first draw" and "first present" mean (accepted by the queue, not visible pixels; a dispatch that is submitted and waited for on its own does not count) are described in `docs/user/run-report.md`, not in code, because code comments are limited to technical debt. - **Counting.** The format counters count lookups, not images; the descriptor counters count bindings as shaders are prepared, not distinct shaders (also in the docs). - **The per-thread mark table** (8 entries) for the first-draw milestone is small and lossy by design: a full table drops one mark. - **Windows and macOS** are not run (see Tested). The macOS entry bridge is the only source of `loaded` and `started`. ### 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: #14235 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: none (no title run; the tests above run without a GPU title) - [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!15705
No description provided.