feat(agc): opt-in per-draw GPU timing and dump-by-address diagnostics #11365

Merged
oneandonlydean merged 6 commits from upstream-pr/11365 into main 2026-10-26 22:08:25 +00:00
oneandonlydean commented 2026-10-26 08:49:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-26T08:49:41Z.


What

An opt-in extension of APS5_PROFILE_GPU for finding which draws cost GPU time. Today the [gputime] line lists the hottest programs by GPU time, but every recorded draw is counted in one Draw class total, so a slow scene shows that draws are expensive without naming the shader. Nothing changes unless the new switch is set.

  • APS5_PROFILE_GPU_DRAWS=1 (with APS5_PROFILE_GPU=1) records a [gputime] range around each recorded draw command that does not use a recipe, keyed by the fragment program's variant id, so draws appear in the hot list next to compute programs as draw 0x<variant>. A [drawvariant] line names the code address behind each variant id once, for queued and inline draws alike. The ranges share the batch's query cap with every other timed range.
  • APS5_DUMP_DRAW_SHADERS also matches a program's code address, besides the color-target and slot-0 addresses it takes today, so a program named by [drawvariant] or [gputime] can be dumped directly.

docs/dev/ENVIRONMENT.md documents both. Known residue: a draw whose variant id already uses bit 63 (the pixel-stub draws) is labelled with that bit cleared.

Tested

  • Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on the head merged with main 263eee0a77: build of agc_driver_recorder_tests and agc_driver_graphics_tests; ctest -R 'agc_gpu_timing|agc_driver_graphics_maps_fallback|public_headers': 69 of 69 passed, 0 failed, 0 not run, including agc_gpu_timing_key (the [gputime] label is draw plus the id [drawvariant] prints) and the existing agc_gpu_timing_complete and agc_gpu_timing_incomplete. tools/check_conventions.py against that main: all checks passed.
  • Windows 11, run by a community tester on 8e38bcf06d merged onto main 518d36eaec (comment 6421390537): RTX 4070 SUPER, GTX 1650 SUPER and the AMD Radeon RDNA2 iGPU, 90 of 91 passed on each, agc_gpu_timing_key passing on all three. The one failure, agc_host_import_cut_lifetime, fails the same way on main.
  • A real draw stream, run by a community tester on Linux (RTX 3080 Ti, comment 6422804495): every draw 0x id in [gputime] joined to a [drawvariant] line, the per-draw split stayed off without APS5_PROFILE_GPU_DRAWS, and the tester saw no frame-rate cost.
  • Not run by us: Windows, and the diagnostics on a real draw stream (the two runs above are the community's); the queued-draw naming has no unit test and is covered by source review.
  • Not a performance change: both switches are off by default.

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 (none added)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux (our run); RTX 4070 SUPER, GTX 1650 SUPER and AMD Radeon RDNA2 iGPU on Windows 11, and RTX 3080 Ti on Linux (community runs above)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5014622924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11365). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-26T08:49:41Z. --- ### What An opt-in extension of `APS5_PROFILE_GPU` for finding which draws cost GPU time. Today the `[gputime]` line lists the hottest programs by GPU time, but every recorded draw is counted in one `Draw` class total, so a slow scene shows that draws are expensive without naming the shader. Nothing changes unless the new switch is set. - `APS5_PROFILE_GPU_DRAWS=1` (with `APS5_PROFILE_GPU=1`) records a `[gputime]` range around each recorded draw command that does not use a recipe, keyed by the fragment program's variant id, so draws appear in the hot list next to compute programs as `draw 0x<variant>`. A `[drawvariant]` line names the code address behind each variant id once, for queued and inline draws alike. The ranges share the batch's query cap with every other timed range. - `APS5_DUMP_DRAW_SHADERS` also matches a program's code address, besides the color-target and slot-0 addresses it takes today, so a program named by `[drawvariant]` or `[gputime]` can be dumped directly. `docs/dev/ENVIRONMENT.md` documents both. Known residue: a draw whose variant id already uses bit 63 (the pixel-stub draws) is labelled with that bit cleared. ### Tested - Linux, Intel i9-14900KF, NVIDIA GeForce RTX 4090 (driver 610.57.04), on the head merged with `main` 263eee0a77: build of `agc_driver_recorder_tests` and `agc_driver_graphics_tests`; `ctest -R 'agc_gpu_timing|agc_driver_graphics_maps_fallback|public_headers'`: 69 of 69 passed, 0 failed, 0 not run, including `agc_gpu_timing_key` (the `[gputime]` label is `draw ` plus the id `[drawvariant]` prints) and the existing `agc_gpu_timing_complete` and `agc_gpu_timing_incomplete`. `tools/check_conventions.py` against that `main`: all checks passed. - Windows 11, run by a community tester on `8e38bcf06d` merged onto `main` 518d36eaec (comment 6421390537): RTX 4070 SUPER, GTX 1650 SUPER and the AMD Radeon RDNA2 iGPU, 90 of 91 passed on each, `agc_gpu_timing_key` passing on all three. The one failure, `agc_host_import_cut_lifetime`, fails the same way on `main`. - A real draw stream, run by a community tester on Linux (RTX 3080 Ti, comment 6422804495): every `draw 0x` id in `[gputime]` joined to a `[drawvariant]` line, the per-draw split stayed off without `APS5_PROFILE_GPU_DRAWS`, and the tester saw no frame-rate cost. - Not run by us: Windows, and the diagnostics on a real draw stream (the two runs above are the community's); the queued-draw naming has no unit test and is covered by source review. - Not a performance change: both switches are off by default. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file (none added) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 610.57.04, Linux (our run); RTX 4070 SUPER, GTX 1650 SUPER and AMD Radeon RDNA2 iGPU on Windows 11, and RTX 3080 Ti on Linux (community runs above) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 08:52:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:52:54Z.

Review: CHANGES_REQUESTED


Reviewed exact head 3cd49f9b9b1e8cbf85758af8bf607800100bf3c5.

I am requesting changes for these issues:

  1. The hosted conventions check fails because the PR body does not use the required template sections. It reports What, Tested and Checklist missing/empty. Please fill the repository template and rerun the check.
  2. The draw timing key is recorded as variantId | (1ull << 63) in Graphics/src/Draw.cpp, but the [gputime] reporter prints the key unchanged while [drawvariant] prints the untagged variantId from Execution/src/Driver/Draw/Draw.cpp. The timing row therefore cannot be joined to its code-address mapping as documented. Please normalize the key in reporting or make both lines use the same displayed identifier, and add a regression for that mapping.
  3. The PR is titled perf(...); the automated check requests the two aps5-summary.jsonl lines, same-scene/same-machine traces and tools/trace_digest.py output. None are in the description, and the author says the timing diagnostic was not tested on a real draw stream. Please provide applicable evidence under the repository performance-report protocol, or clarify the title/classification with maintainers if this diagnostic is not a speed change. Please also exercise the new switch on a real draw stream and confirm the timing and variant lines are emitted and usable.

Eligibility, intake, labels and report checks pass; hosted relinker/product tests are skipped by path policy. I did not independently build or run the GPU diagnostic.

AI-assisted review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649485915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11365#pullrequestreview-5649485915). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:52:54Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `3cd49f9b9b1e8cbf85758af8bf607800100bf3c5`. I am requesting changes for these issues: 1. The hosted `conventions` check fails because the PR body does not use the required template sections. It reports `What`, `Tested` and `Checklist` missing/empty. Please fill the repository template and rerun the check. 2. The draw timing key is recorded as `variantId | (1ull << 63)` in `Graphics/src/Draw.cpp`, but the `[gputime]` reporter prints the key unchanged while `[drawvariant]` prints the untagged `variantId` from `Execution/src/Driver/Draw/Draw.cpp`. The timing row therefore cannot be joined to its code-address mapping as documented. Please normalize the key in reporting or make both lines use the same displayed identifier, and add a regression for that mapping. 3. The PR is titled `perf(...)`; the automated check requests the two `aps5-summary.jsonl` lines, same-scene/same-machine traces and `tools/trace_digest.py` output. None are in the description, and the author says the timing diagnostic was not tested on a real draw stream. Please provide applicable evidence under the repository performance-report protocol, or clarify the title/classification with maintainers if this diagnostic is not a speed change. Please also exercise the new switch on a real draw stream and confirm the timing and variant lines are emitted and usable. Eligibility, intake, labels and report checks pass; hosted relinker/product tests are skipped by path policy. I did not independently build or run the GPU diagnostic. AI-assisted review.
MarcZX10 commented 2026-10-26 09:45:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T09:45:19Z.

Review: CHANGES_REQUESTED


Follow-up on exact current head 8c45681cc301b7a43055d6aaacfb7b7cbcbd7cfe against current main 4e43321bd6ceccdc1ae28568bbbc35d9a6446464. The latest commit fixes the tagged timing-key mismatch and adds a focused TimingKeyLabel test; I withdraw those earlier code findings. The branch is four commits ahead of current main, has a clean merge preview, and current git diff --check passes.

Two merge blockers remain:

  1. The hosted conventions check still fails: its log says the PR body is missing the required What, Tested and Checklist sections. The current body uses Summary and Tests and has no checklist. Please fill the repository template and rerun conventions.
  2. The title still starts perf(...), so the current policy requires valid same-scene main/change APS5 summary lines and attached traces plus trace_digest.py output. None are present. This change adds an opt-in diagnostic and does not claim to make the game faster; please obtain maintainer direction on an applicable report for this diagnostic or reclassify it so the title does not trigger the speed-change evidence rule. The author also says a real draw stream was not tested; please report the focused agc_gpu_timing_key test and a real draw-stream check for the emitted [gputime]/[drawvariant] mapping, or state clearly what could not be exercised.

The current CI lists eligibility, labels and report passing, conventions failing, and Linux/Windows/product jobs skipped by path policy. I did not run the GPU diagnostic locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5650042710 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11365#pullrequestreview-5650042710). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T09:45:19Z. **Review:** CHANGES_REQUESTED --- Follow-up on exact current head `8c45681cc301b7a43055d6aaacfb7b7cbcbd7cfe` against current `main` `4e43321bd6ceccdc1ae28568bbbc35d9a6446464`. The latest commit fixes the tagged timing-key mismatch and adds a focused `TimingKeyLabel` test; I withdraw those earlier code findings. The branch is four commits ahead of current `main`, has a clean merge preview, and current `git diff --check` passes. Two merge blockers remain: 1. The hosted conventions check still fails: its log says the PR body is missing the required `What`, `Tested` and `Checklist` sections. The current body uses `Summary` and `Tests` and has no checklist. Please fill the repository template and rerun conventions. 2. The title still starts `perf(...)`, so the current policy requires valid same-scene `main`/change APS5 summary lines and attached traces plus `trace_digest.py` output. None are present. This change adds an opt-in diagnostic and does not claim to make the game faster; please obtain maintainer direction on an applicable report for this diagnostic or reclassify it so the title does not trigger the speed-change evidence rule. The author also says a real draw stream was not tested; please report the focused `agc_gpu_timing_key` test and a real draw-stream check for the emitted `[gputime]`/`[drawvariant]` mapping, or state clearly what could not be exercised. The current CI lists eligibility, labels and report passing, conventions failing, and Linux/Windows/product jobs skipped by path policy. I did not run the GPU diagnostic locally.
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!11365
No description provided.