feat(agc): trace shader addresses for each draw #5238

Merged
MarcZX10 merged 2 commits from upstream-pr/5238 into main 2026-10-15 08:06:32 +00:00
MarcZX10 commented 2026-10-13 15:23:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T15:23:53Z.


What

Add opt-in APS5_TRACE_DRAW_PROGRAMS per-draw diagnostics that print the selected shader stage and role with the code base and entry addresses, plus submission serial and queue. This lets investigators compare selected shader addresses against shader-preparation failure logs without implying the failures caused the black frames.

Tested

  • Linux: configured the project and built agc_driver_draw_program_trace_tests with CMake/Ninja.
  • Linux: ctest --test-dir /tmp/AnyPS5-5166-build --output-on-failure -R '^agc_driver_draw_program_trace$' passed (1/1).
  • Linux: compiled the production Draw.cpp object with Ninja.
  • Linux: python3 tools/check_conventions.py --base upstream/main passed.
  • No GPU or game runtime tests were run.

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: PPSA02225 #5166
  • GPUs tested: no GPU tests run (diagnostic formatting and production object build only)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4845506913 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T15:23:53Z. --- ### What Add opt-in `APS5_TRACE_DRAW_PROGRAMS` per-draw diagnostics that print the selected shader stage and role with the code base and entry addresses, plus submission serial and queue. This lets investigators compare selected shader addresses against shader-preparation failure logs without implying the failures caused the black frames. ### Tested - Linux: configured the project and built `agc_driver_draw_program_trace_tests` with CMake/Ninja. - Linux: `ctest --test-dir /tmp/AnyPS5-5166-build --output-on-failure -R '^agc_driver_draw_program_trace$'` passed (1/1). - Linux: compiled the production `Draw.cpp` object with Ninja. - Linux: `python3 tools/check_conventions.py --base upstream/main` passed. - No GPU or game runtime tests were run. ### 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: PPSA02225 #5166 - [x] GPUs tested: no GPU tests run (diagnostic formatting and production object build only) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-13 15:47:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T15:47:58Z.


The Conventional Commit check initially caught the commit subject and PR title. Both are corrected now; the latest conventions check passes. The path-filtered Linux, Windows, relinker, register-context and write-watch jobs are skipped for this diagnostic-only change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149457281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6149457281). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T15:47:58Z. --- The Conventional Commit check initially caught the commit subject and PR title. Both are corrected now; the latest conventions check passes. The path-filtered Linux, Windows, relinker, register-context and write-watch jobs are skipped for this diagnostic-only change.
sktharunbalaji13-cmd commented 2026-10-13 16:48:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sktharunbalaji13-cmd on 2026-10-13T16:48:08Z.


Thank you @MarcZX100 for the per-draw shader-address tracing and for the CI and convention follow-up.

Your stage, role, code address, entry address, queue and submission fields complement our local investigation. They give a direct per-draw address comparison point for shader-selection decisions made at submission time.

Local update, uncommitted work only: we now have local draw-to-submission correlation covering draw attempts, shader-selection and preparation failures, recorded draw commands, and deduplicated draw-token sets associated with recorder batches. Submission attempts are distinguished from submit-confirmed events emitted after successful queue submission and recorder-state finalization.

Windows game-runtime validation has not been completed. Relevant object compilations and seven CaptureTrace utility tests passed, but the full PRX relink and AGC integration path remain blocked.

This does not claim that shader-preparation failures caused the black output. The cause remains unresolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150588361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6150588361). Originally posted by [sktharunbalaji13-cmd](https://github.com/sktharunbalaji13-cmd) on 2026-10-13T16:48:08Z. --- Thank you @MarcZX100 for the per-draw shader-address tracing and for the CI and convention follow-up. Your stage, role, code address, entry address, queue and submission fields complement our local investigation. They give a direct per-draw address comparison point for shader-selection decisions made at submission time. Local update, uncommitted work only: we now have local draw-to-submission correlation covering draw attempts, shader-selection and preparation failures, recorded draw commands, and deduplicated draw-token sets associated with recorder batches. Submission attempts are distinguished from submit-confirmed events emitted after successful queue submission and recorder-state finalization. Windows game-runtime validation has not been completed. Relevant object compilations and seven CaptureTrace utility tests passed, but the full PRX relink and AGC integration path remain blocked. This does not claim that shader-preparation failures caused the black output. The cause remains unresolved.
sktharunbalaji13-cmd commented 2026-10-13 19:35:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sktharunbalaji13-cmd on 2026-10-13T19:35:22Z.


Thank you for the per-draw shader-address tracing. We've now prepared a complementary contribution focused on connecting draw attempts and shader-preparation failures to actual recorded commands and the set of correlation tokens associated with each submitted recorder batch.

The clean-branch validation result for the new PR is: successful Windows configure, full instrumented libSceAgcDriver.prx build with NID patching, and 8/8 passing CaptureTrace tests. No GPU/game-runtime validation was performed.

The two diagnostic approaches complement each other: per-draw address information helps identify which shader program is selected, while the additional correlation data is intended to connect failures with recorded draw commands and queue-submission batches. We have not yet established that shader-preparation failures caused the black output; runtime validation remains necessary.

Related PR: https://github.com/boykopovar/AnyPS5/pull/5431

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153603571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6153603571). Originally posted by [sktharunbalaji13-cmd](https://github.com/sktharunbalaji13-cmd) on 2026-10-13T19:35:22Z. --- Thank you for the per-draw shader-address tracing. We've now prepared a complementary contribution focused on connecting draw attempts and shader-preparation failures to actual recorded commands and the set of correlation tokens associated with each submitted recorder batch. The clean-branch validation result for the new PR is: successful Windows configure, full instrumented `libSceAgcDriver.prx` build with NID patching, and 8/8 passing CaptureTrace tests. No GPU/game-runtime validation was performed. The two diagnostic approaches complement each other: per-draw address information helps identify which shader program is selected, while the additional correlation data is intended to connect failures with recorded draw commands and queue-submission batches. We have not yet established that shader-preparation failures caused the black output; runtime validation remains necessary. Related PR: https://github.com/boykopovar/AnyPS5/pull/5431
MarcZX10 commented 2026-10-13 19:38:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T19:38:36Z.


Thanks for clarifying the complementary scope. I agree the address trace and draw-to-batch correlation answer different diagnostic questions. I checked #5431 as well: its current convention job fails on inline comments in CaptureTrace.hpp and the missing required PR-template headings, so I left those concrete findings there. Since both PRs touch Draw.cpp and the AGC CMake target, I asked there how the implementations compose and whether they share or duplicate any instrumentation; that should make the integration boundary clear before either lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153660809 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6153660809). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T19:38:36Z. --- Thanks for clarifying the complementary scope. I agree the address trace and draw-to-batch correlation answer different diagnostic questions. I checked #5431 as well: its current convention job fails on inline comments in `CaptureTrace.hpp` and the missing required PR-template headings, so I left those concrete findings there. Since both PRs touch `Draw.cpp` and the AGC CMake target, I asked there how the implementations compose and whether they share or duplicate any instrumentation; that should make the integration boundary clear before either lands.
adriadam10 commented 2026-10-14 11:35:55 +00:00 (Migrated from github.com)

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


Checked the build, agc_driver_draw_program_trace and the scoped ctest on the PR rebased onto main; the only failures (agc_recorder_kept_bytes, agc_driver_tessellation) fail identically without the Draw.cpp change.

Added one commit: docs/dev/BUILD.md now documents APS5_TRACE_DRAW_PROGRAMS next to the other APS5_* diagnostics variables.

Not verified here: the output on a real draw (the test covers the formatter only). Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167417798 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6167417798). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T11:35:55Z. --- Checked the build, `agc_driver_draw_program_trace` and the scoped ctest on the PR rebased onto main; the only failures (`agc_recorder_kept_bytes`, `agc_driver_tessellation`) fail identically without the `Draw.cpp` change. Added one commit: `docs/dev/BUILD.md` now documents `APS5_TRACE_DRAW_PROGRAMS` next to the other `APS5_*` diagnostics variables. Not verified here: the output on a real draw (the test covers the formatter only). Merging once CI is green.
adriadam10 commented 2026-10-14 21:45:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:45:05Z.


Rebased onto current main (only the #include block in Draw.cpp conflicted; kept <cstdio> and <cstring>). Build and scoped ctest re-run: agc_driver_draw_program_trace passes; the only failure, agc_driver_tessellation, also fails without the Draw.cpp change. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179178724 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6179178724). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T21:45:05Z. --- Rebased onto current `main` (only the `#include` block in `Draw.cpp` conflicted; kept `<cstdio>` and `<cstring>`). Build and scoped ctest re-run: `agc_driver_draw_program_trace` passes; the only failure, `agc_driver_tessellation`, also fails without the `Draw.cpp` change. Merging once CI is green.
github-actions[bot] commented 2026-10-15 03:31:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T03:31:25Z.


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
#6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt L147
#6203 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L2
#6208 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L2
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6183761477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5238#issuecomment-6183761477). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T03:31:25Z. --- <!-- 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 | |---|---|---|---| | #6188 | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L147](https://github.com/boykopovar/AnyPS5/blob/d92a8dad390af1807cc91622b924252141816a5a/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L147) | | | | #6203 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` [L2](https://github.com/boykopovar/AnyPS5/blob/d92a8dad390af1807cc91622b924252141816a5a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp#L2) | | | | #6208 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` [L2](https://github.com/boykopovar/AnyPS5/blob/d92a8dad390af1807cc91622b924252141816a5a/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp#L2) | | |
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!5238
No description provided.