perf(agc): wait at submit only for the preparations of the programs a submission binds #6867

Merged
Pipodi merged 5 commits from upstream-pr/6867 into main 2026-11-08 09:14:06 +00:00
Pipodi commented 2026-10-16 14:59:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T14:59:00Z.


What

Driver::Submit waits on the submitting thread only for the registration preparations of the programs the submission binds, and moves each to the front of the queue (PrioritizeRegistrationPreparation), instead of waiting for every queued preparation (#5007). The scan reads the program address registers (SPI_SHADER_PGM_LO/HI of the pixel, geometry, export, hull and local stages, COMPUTE_PGM_LO/HI) written by SET_SH_REG and by SET_SH_REG_INDIRECT lists, including packets inside INDIRECT_BUFFER and COND_INDIRECT_BUFFER targets (they are copied into the submission before the scan).

Rebased on main bb04a4f1ea. The pool part reuses main's PrioritizeRegistrationPreparation, as Dextroid17's port did. AwaitRegistrationPreparation and the pool's sequence tracking stay as they are, because the wait-for-all fallback below uses them. The pool also records which preparation owns each queued or running task, so the submit wait can wait for that task.

Change since the review: a submission that writes only one register of a program pair (the other half came from an earlier submission) is not proven by the scan. It now waits for all queued preparations at submit, as main does, instead of leaving that program to an unbounded wait in the queue worker at first use (CnRJay's #5007 concern). A bound after N seconds was not chosen: continuing without the program would skip the draw, which is invented behaviour.

Change since jotitadev's run on 10-27: the wait for a bound program waited on its snapshot's settled condition whenever pending was set. A preparation marked pending with no pool task, as agc_driver_prepared_shaders_dispatch_ahead_prewarm (#8735) does, was never settled, and the submission hung. The wait now moves the program's pool task to the front and waits for that task to finish. It does not wait for a preparation the pool does not hold.

The scan also falls back to the wait-for-all when it cannot see every program the submission uses: the submission ends in a REWIND (the tail is copied later in the queue worker), a SET_SH_REG_INDIRECT list has an invalid register (the worker reads such a list again at execution), a draw (a dispatch) comes before any graphics (the compute) program pair written in the same submission, so the program may have been bound by an earlier submission, or a program address is written by a predicated SET_SH_REG or one inside a COND_EXEC range, which may not run.

Not covered, and recorded in the technical debt entry: a draw that writes one graphics pair but also uses a stage bound by an earlier submission, and a program registered again at an address an earlier submission bound, then used without rebinding while the submission writes a different graphics pair. Their first draw waits in the queue worker with no bound. The longest preparation seen is 74 s on one thread (cold, 55,144-dword shader, Ghost of Yōtei), and a submission that binds such a shader waits as long at submit. A submission the scan cannot prove waits for every queued preparation, as on main (76.3 s first-submission wait on Yōtei, cold, earlier measurement). The measured waits below are machine and cache dependent; no bound is claimed.

Tested

Tests on the rebased branch (Windows, MinGW GCC 15.2, Release, RTX, ANYPS5_REQUIRE_VULKAN=1)
  • ^agc_driver_(prepared|registered), 28 tests, --repeat until-fail:3: 28/28 (a3c2759583); the four agc_driver_prepared_shaders* variants pass again on ccbf4f29e3.
  • Validation: the same 28 tests on main e5f23554c9 and on this branch, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R "^agc_driver_(prepared|registered)" -V: 28/28 on both. Neither log has the "was not found but was requested" line. Both logs have the same 14 VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 errors, all in agc_driver_prepared_exports, so this branch adds no new validation errors.
  • New UnprovenProgramsAtSubmit (in agc_driver_prepared_shaders): a slow (1500 ms) queued preparation, then a real sceAgcDriverSubmitDcb:
submission Submit waited
low register only (SET_SH_REG) waits (preparation done on return)
high register only waits (preparation done on return)
low register only inside an INDIRECT_BUFFER target waits (preparation done on return)
submission ending in a REWIND (tail not scanned) waits (preparation done on return)
whole pair (control) returns before the preparation is done

The rows prove the early return or the wait by whether the preparation had finished when Submit returned, not by a time bound. Scan-level rows cover an invalid indirect list, a draw or dispatch with no pair written before it in the submission (a bind by an earlier submission and none now), a predicated pair, a pair inside a COND_EXEC range (not complete, no address resolved), and a pair after a COND_EXEC range that holds only another register (still complete). The invalid-list fallback is tested at scan level only: through Submit, the queue worker throws on such a list ("indirect register sentinel semantics are not implemented"), so it never reaches the wait.

  • Negative controls: with the half-pair fallback disabled (if (false && !scan.complete)) the test fails at the first row ("a submission writing half of a program address did not wait for the queued preparations"); with the REWIND fallback removed it fails with "a submission ending in a REWIND did not wait ..."; with the draw/dispatch check disabled it fails with "a dispatch that binds no program in its submission was reported as fully scanned"; without the predication check it fails with "a predicated program pair was reported as fully scanned", and without the COND_EXEC check with "a program pair inside a conditional execution range was reported as fully scanned". In that state the program would be waited for at first use in the queue worker, for the whole remaining preparation (1500 ms here; 74 s for the cold shader above).
  • AwaitedRegistrationPreparation (main's ticket-rule test) is kept.
  • Full ctest on 08fe590f67 (rebased on main bb04a4f1ea): 3028/3029; guest_freebsd_clocks aborts with 0xc0000409 as in #12736 (host zone not UTC), a libkernel test this branch does not touch.
  • Full ctest on ccbf4f29e3: 2304/2306. agc_host_import_cut_lifetime and agc_driver_depth_plane_partial_store fail; both fail the same way on plain main e5f23554c9 on this machine.
Ghost of Yōtei, this revision, cold: total submit wait 182 s → 7 s, first wait 49–52 s → 1 s

Windows, RTX 4090, driver 617.42. Both builds have a fully cold recompiler cache and a drained NVIDIA pipeline cache, a fresh profile, and the same environment. Each run is 900 s. A is main e5f23554c9 (run499, and run501 as a rerun for the trace). B is this branch, 4703b22bde (run500). Both builds carry the same local log line for submit waits of 100 ms or more; it is not part of this PR. On plain main the intro stays dark for the whole 900 s in all three runs, with or without this PR, so first-lit-frame times are missing.

A (main) B (this PR)
submit waits ≥ 100 ms 20 (22) 5
waits > 1 s 12 (12) 2
first wait 49.3 s (51.9 s) 0.96 s
longest wait 49.3 s (51.9 s) 3.2 s
total submit wait 182 s (182 s) 7 s
time to frame 1 / 10 / 200 101 / 121 / 141 s 60 / 80 / 101 s
time to frame 300 402 s 342 s
time to frame 330 422 s 563 s

Frame 330 is later in B because a 116 s compute compile stall (shader 0x8000196500, the same in both builds) falls earlier there; this PR does not change compile times.

Trace digest, frames 100–200, queue worker (the hottest thread), inclusive ms per frame, A (run501) / B (run500). The window covers 277 s in A and 258 s in B.

phase A B
Driver.Packet 888 1128
dispatch 502 652
Vulkan.ComputePipeline 443 573
memory_wait 256 312
WorkerWait 495 161

The worker waits a third as long for preparations. That time now goes to compiling pipelines that are no longer held back behind the submit wait, so per-frame work in the window is higher, not lower.

Summary lines of the two traces above (aps5-summary.jsonl, frames 100–200)

main e5f23554c9 (run501), then this branch 4703b22bde (run500). Both are marked dirty because both builds carry the local submit-wait log line described above. 4703b22bde is the measured revision; the head since adds only the fix for a pending preparation with no pool task (761ef1105e), and was not remeasured. The traces are kept locally and can be shared on request. The title field is written as Y\u014dtei here; the summary writer had stored it double-encoded (\u00c5\u008d), which GitHub does not keep intact.

{"commit":"e5f23554c9c7","dirty":true,"env":{"APS5_GPU_CHECKPOINTS":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PIPELINE_JOURNAL":"1","APS5_NO_RESULT_MEMO":"1","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PIPELINE_DISPATCH":"1","APS5_PREBUILD_THREADS":"2","APS5_PREPARED_SPIRV_MIB":"6144","APS5_PROFILE_DRAW":"1","APS5_RESOURCE_CACHE_ENTRIES":"1024","APS5_SPANNED_WAVE":"1","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_FRAMES":"100:200"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"13th Gen Intel(R) Core(TM) i9-13900K","cpu_threads":32,"memory_mib":32476,"title_id":"PPSA26344","title":"Ghost of Y\u014dtei","content_version":"01.008.000","resolution":"3840x2160","window":{"spec":"frames 100:200","first_present":100,"ms":277022.035},"presents":200,"frame_ms":{"p50":128.075,"p90":1197.832,"p99":41793.606,"max":90343.336},"gpu_busy_ms_per_present":78.271,"worker_busy_pct":{"queue worker 0x0":64.237,"queue worker 0x52":3.601,"queue worker 0x53":0.792,"queue worker 0x20":16.643,"queue worker 0x30":32.427,"queue worker 0x38":25.118,"queue worker 0x48":8.323},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":5975.056,"Driver.Packet":2091.511,"Driver.Packet.dispatch":1004.043,"Driver.Dispatch":979.062,"Driver.Packet.memory_wait":912.059,"Vulkan.ComputePipeline":824.439,"Vulkan.GraphicsPipeline":98.891,"Graphics.Draw":76.754},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":69.232,"events_lost":19632,"totals_full":false}},"trace":"aps5-trace-e5f23554c9c7-39372.json.gz"}
{"commit":"4703b22bde3c","dirty":true,"env":{"APS5_GPU_CHECKPOINTS":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PIPELINE_JOURNAL":"1","APS5_NO_RESULT_MEMO":"1","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PIPELINE_DISPATCH":"1","APS5_PREBUILD_THREADS":"2","APS5_PREPARED_SPIRV_MIB":"6144","APS5_PROFILE_DRAW":"1","APS5_RESOURCE_CACHE_ENTRIES":"1024","APS5_SPANNED_WAVE":"1","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_FRAMES":"100:200"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"13th Gen Intel(R) Core(TM) i9-13900K","cpu_threads":32,"memory_mib":32476,"title_id":"PPSA26344","title":"Ghost of Y\u014dtei","content_version":"01.008.000","resolution":"3840x2160","window":{"spec":"frames 100:200","first_present":100,"ms":258171.356},"presents":200,"frame_ms":{"p50":147.813,"p90":899.185,"p99":42781.232,"max":92980.382},"gpu_busy_ms_per_present":86.150,"worker_busy_pct":{"queue worker 0x0":87.494,"queue worker 0x20":26.181,"queue worker 0x52":3.969,"queue worker 0x53":0.884,"queue worker 0x30":44.612,"queue worker 0x38":38.061,"queue worker 0x48":13.947},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":6685.836,"Driver.Packet":2774.642,"Driver.Packet.dispatch":1299.561,"Driver.Dispatch":1272.832,"Driver.Packet.memory_wait":1259.496,"Vulkan.ComputePipeline":1071.626,"Vulkan.GraphicsPipeline":145.679,"Vulkan.GraphicsPipelineLibrary":113.949},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":26.225,"events_lost":20046,"totals_full":false}},"trace":"aps5-trace-4703b22bde3c-13556.json.gz"}
Earlier measurements (before this revision)
  • Ghost of Yōtei (PPSA26344), Windows, RTX 4090, cold cache: first frame 101 s to 40 s; first submission wait 76.3 s to under 3 s; longest wait 2.6 s for 83 bound programs.
  • Dextroid17, Linux, lavapipe, cold cache: first frame 221 s to 171 s (2 runs each). RTX 3080 Ti, cold cache, 3 runs each: longest frame 132-134 s on main, 1.6 / 4.9 / 4.2 s with a port of this PR; longest queue-worker WorkerWait 1.5 / 2.7 / 2.0 s.
  • Warm cache pair, supplied by Dextroid17 (RTX 3080 Ti, Linux, 2 runs each): median frame 192 / 137 ms on main, 194 / 134 ms with the port; p90 357 / 362 vs 359 / 347 ms; presents 96 / 115 vs 114 / 121. No visible cost of ReferencedPrograms; it was not timed on its own.
  • parl0v, RTX 3060, Minecraft Dungeons II: neutral (6.61 / 6.61 FPS vs 6.70 / 6.60).
  • Not remeasured on this revision: how often titles write one register of a pair alone, which makes a submit wait for all preparations again.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA26344 (Ghost of Yōtei) first-frame time
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 (this revision's tests); RTX 4090, RTX 3080 Ti, RTX 3070, RTX 3060, lavapipe for the earlier revision (see the reports above)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9BMpf1muQhujJd4AbteUA

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4890194985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-16T14:59:00Z. --- ### What `Driver::Submit` waits on the submitting thread only for the registration preparations of the programs the submission binds, and moves each to the front of the queue (`PrioritizeRegistrationPreparation`), instead of waiting for every queued preparation (#5007). The scan reads the program address registers (`SPI_SHADER_PGM_LO/HI` of the pixel, geometry, export, hull and local stages, `COMPUTE_PGM_LO/HI`) written by `SET_SH_REG` and by `SET_SH_REG_INDIRECT` lists, including packets inside `INDIRECT_BUFFER` and `COND_INDIRECT_BUFFER` targets (they are copied into the submission before the scan). Rebased on `main` `bb04a4f1ea`. The pool part reuses `main`'s `PrioritizeRegistrationPreparation`, as Dextroid17's port did. `AwaitRegistrationPreparation` and the pool's sequence tracking stay as they are, because the wait-for-all fallback below uses them. The pool also records which preparation owns each queued or running task, so the submit wait can wait for that task. Change since the review: a submission that writes only one register of a program pair (the other half came from an earlier submission) is not proven by the scan. It now waits for all queued preparations at submit, as `main` does, instead of leaving that program to an unbounded wait in the queue worker at first use (CnRJay's #5007 concern). A bound after N seconds was not chosen: continuing without the program would skip the draw, which is invented behaviour. Change since jotitadev's run on 10-27: the wait for a bound program waited on its snapshot's `settled` condition whenever `pending` was set. A preparation marked pending with no pool task, as `agc_driver_prepared_shaders_dispatch_ahead_prewarm` (#8735) does, was never settled, and the submission hung. The wait now moves the program's pool task to the front and waits for that task to finish. It does not wait for a preparation the pool does not hold. The scan also falls back to the wait-for-all when it cannot see every program the submission uses: the submission ends in a `REWIND` (the tail is copied later in the queue worker), a `SET_SH_REG_INDIRECT` list has an invalid register (the worker reads such a list again at execution), a draw (a dispatch) comes before any graphics (the compute) program pair written in the same submission, so the program may have been bound by an earlier submission, or a program address is written by a predicated `SET_SH_REG` or one inside a `COND_EXEC` range, which may not run. Not covered, and recorded in the technical debt entry: a draw that writes one graphics pair but also uses a stage bound by an earlier submission, and a program registered again at an address an earlier submission bound, then used without rebinding while the submission writes a different graphics pair. Their first draw waits in the queue worker with no bound. The longest preparation seen is 74 s on one thread (cold, 55,144-dword shader, Ghost of Yōtei), and a submission that binds such a shader waits as long at submit. A submission the scan cannot prove waits for every queued preparation, as on `main` (76.3 s first-submission wait on Yōtei, cold, earlier measurement). The measured waits below are machine and cache dependent; no bound is claimed. ### Tested <details><summary>Tests on the rebased branch (Windows, MinGW GCC 15.2, Release, RTX, ANYPS5_REQUIRE_VULKAN=1)</summary> - `^agc_driver_(prepared|registered)`, 28 tests, `--repeat until-fail:3`: 28/28 (a3c2759583); the four `agc_driver_prepared_shaders*` variants pass again on ccbf4f29e3. - Validation: the same 28 tests on `main` e5f23554c9 and on this branch, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R "^agc_driver_(prepared|registered)" -V`: 28/28 on both. Neither log has the "was not found but was requested" line. Both logs have the same 14 `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` errors, all in `agc_driver_prepared_exports`, so this branch adds no new validation errors. - New `UnprovenProgramsAtSubmit` (in `agc_driver_prepared_shaders`): a slow (1500 ms) queued preparation, then a real `sceAgcDriverSubmitDcb`: | submission | Submit waited | |---|---| | low register only (`SET_SH_REG`) | waits (preparation done on return) | | high register only | waits (preparation done on return) | | low register only inside an `INDIRECT_BUFFER` target | waits (preparation done on return) | | submission ending in a `REWIND` (tail not scanned) | waits (preparation done on return) | | whole pair (control) | returns before the preparation is done | The rows prove the early return or the wait by whether the preparation had finished when Submit returned, not by a time bound. Scan-level rows cover an invalid indirect list, a draw or dispatch with no pair written before it in the submission (a bind by an earlier submission and none now), a predicated pair, a pair inside a `COND_EXEC` range (not complete, no address resolved), and a pair after a `COND_EXEC` range that holds only another register (still complete). The invalid-list fallback is tested at scan level only: through Submit, the queue worker throws on such a list ("indirect register sentinel semantics are not implemented"), so it never reaches the wait. - Negative controls: with the half-pair fallback disabled (`if (false && !scan.complete)`) the test fails at the first row ("a submission writing half of a program address did not wait for the queued preparations"); with the REWIND fallback removed it fails with "a submission ending in a REWIND did not wait ..."; with the draw/dispatch check disabled it fails with "a dispatch that binds no program in its submission was reported as fully scanned"; without the predication check it fails with "a predicated program pair was reported as fully scanned", and without the `COND_EXEC` check with "a program pair inside a conditional execution range was reported as fully scanned". In that state the program would be waited for at first use in the queue worker, for the whole remaining preparation (1500 ms here; 74 s for the cold shader above). - `AwaitedRegistrationPreparation` (main's ticket-rule test) is kept. - Full ctest on 08fe590f67 (rebased on `main` bb04a4f1ea): 3028/3029; `guest_freebsd_clocks` aborts with 0xc0000409 as in #12736 (host zone not UTC), a libkernel test this branch does not touch. - Full ctest on ccbf4f29e3: 2304/2306. `agc_host_import_cut_lifetime` and `agc_driver_depth_plane_partial_store` fail; both fail the same way on plain `main` e5f23554c9 on this machine. </details> <details><summary>Ghost of Yōtei, this revision, cold: total submit wait 182 s → 7 s, first wait 49–52 s → 1 s</summary> Windows, RTX 4090, driver 617.42. Both builds have a fully cold recompiler cache and a drained NVIDIA pipeline cache, a fresh profile, and the same environment. Each run is 900 s. A is `main` e5f23554c9 (run499, and run501 as a rerun for the trace). B is this branch, 4703b22bde (run500). Both builds carry the same local log line for submit waits of 100 ms or more; it is not part of this PR. On plain `main` the intro stays dark for the whole 900 s in all three runs, with or without this PR, so first-lit-frame times are missing. | | A (`main`) | B (this PR) | |---|---|---| | submit waits ≥ 100 ms | 20 (22) | 5 | | waits > 1 s | 12 (12) | 2 | | first wait | 49.3 s (51.9 s) | 0.96 s | | longest wait | 49.3 s (51.9 s) | 3.2 s | | total submit wait | 182 s (182 s) | 7 s | | time to frame 1 / 10 / 200 | 101 / 121 / 141 s | 60 / 80 / 101 s | | time to frame 300 | 402 s | 342 s | | time to frame 330 | 422 s | 563 s | Frame 330 is later in B because a 116 s compute compile stall (shader 0x8000196500, the same in both builds) falls earlier there; this PR does not change compile times. Trace digest, frames 100–200, queue worker (the hottest thread), inclusive ms per frame, A (run501) / B (run500). The window covers 277 s in A and 258 s in B. | phase | A | B | |---|---|---| | Driver.Packet | 888 | 1128 | | dispatch | 502 | 652 | | Vulkan.ComputePipeline | 443 | 573 | | memory_wait | 256 | 312 | | WorkerWait | 495 | 161 | The worker waits a third as long for preparations. That time now goes to compiling pipelines that are no longer held back behind the submit wait, so per-frame work in the window is higher, not lower. </details> <details><summary>Summary lines of the two traces above (aps5-summary.jsonl, frames 100–200)</summary> `main` e5f23554c9 (run501), then this branch 4703b22bde (run500). Both are marked `dirty` because both builds carry the local submit-wait log line described above. 4703b22bde is the measured revision; the head since adds only the fix for a pending preparation with no pool task (761ef1105e), and was not remeasured. The traces are kept locally and can be shared on request. The `title` field is written as `Y\u014dtei` here; the summary writer had stored it double-encoded (`\u00c5\u008d`), which GitHub does not keep intact. ```json {"commit":"e5f23554c9c7","dirty":true,"env":{"APS5_GPU_CHECKPOINTS":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PIPELINE_JOURNAL":"1","APS5_NO_RESULT_MEMO":"1","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PIPELINE_DISPATCH":"1","APS5_PREBUILD_THREADS":"2","APS5_PREPARED_SPIRV_MIB":"6144","APS5_PROFILE_DRAW":"1","APS5_RESOURCE_CACHE_ENTRIES":"1024","APS5_SPANNED_WAVE":"1","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_FRAMES":"100:200"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"13th Gen Intel(R) Core(TM) i9-13900K","cpu_threads":32,"memory_mib":32476,"title_id":"PPSA26344","title":"Ghost of Y\u014dtei","content_version":"01.008.000","resolution":"3840x2160","window":{"spec":"frames 100:200","first_present":100,"ms":277022.035},"presents":200,"frame_ms":{"p50":128.075,"p90":1197.832,"p99":41793.606,"max":90343.336},"gpu_busy_ms_per_present":78.271,"worker_busy_pct":{"queue worker 0x0":64.237,"queue worker 0x52":3.601,"queue worker 0x53":0.792,"queue worker 0x20":16.643,"queue worker 0x30":32.427,"queue worker 0x38":25.118,"queue worker 0x48":8.323},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":5975.056,"Driver.Packet":2091.511,"Driver.Packet.dispatch":1004.043,"Driver.Dispatch":979.062,"Driver.Packet.memory_wait":912.059,"Vulkan.ComputePipeline":824.439,"Vulkan.GraphicsPipeline":98.891,"Graphics.Draw":76.754},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":69.232,"events_lost":19632,"totals_full":false}},"trace":"aps5-trace-e5f23554c9c7-39372.json.gz"} ``` ```json {"commit":"4703b22bde3c","dirty":true,"env":{"APS5_GPU_CHECKPOINTS":"1","APS5_HOST_IMPORT_MIB":"16384","APS5_NO_PIPELINE_JOURNAL":"1","APS5_NO_RESULT_MEMO":"1","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PIPELINE_DISPATCH":"1","APS5_PREBUILD_THREADS":"2","APS5_PREPARED_SPIRV_MIB":"6144","APS5_PROFILE_DRAW":"1","APS5_RESOURCE_CACHE_ENTRIES":"1024","APS5_SPANNED_WAVE":"1","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_FRAMES":"100:200"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"13th Gen Intel(R) Core(TM) i9-13900K","cpu_threads":32,"memory_mib":32476,"title_id":"PPSA26344","title":"Ghost of Y\u014dtei","content_version":"01.008.000","resolution":"3840x2160","window":{"spec":"frames 100:200","first_present":100,"ms":258171.356},"presents":200,"frame_ms":{"p50":147.813,"p90":899.185,"p99":42781.232,"max":92980.382},"gpu_busy_ms_per_present":86.150,"worker_busy_pct":{"queue worker 0x0":87.494,"queue worker 0x20":26.181,"queue worker 0x52":3.969,"queue worker 0x53":0.884,"queue worker 0x30":44.612,"queue worker 0x38":38.061,"queue worker 0x48":13.947},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":6685.836,"Driver.Packet":2774.642,"Driver.Packet.dispatch":1299.561,"Driver.Dispatch":1272.832,"Driver.Packet.memory_wait":1259.496,"Vulkan.ComputePipeline":1071.626,"Vulkan.GraphicsPipeline":145.679,"Vulkan.GraphicsPipelineLibrary":113.949},"trace_dropped":true,"trace_dropped_threads":{"title":{"events_full_after_s":26.225,"events_lost":20046,"totals_full":false}},"trace":"aps5-trace-4703b22bde3c-13556.json.gz"} ``` </details> <details><summary>Earlier measurements (before this revision)</summary> - Ghost of Yōtei (PPSA26344), Windows, RTX 4090, cold cache: first frame 101 s to 40 s; first submission wait 76.3 s to under 3 s; longest wait 2.6 s for 83 bound programs. - Dextroid17, Linux, lavapipe, cold cache: first frame 221 s to 171 s (2 runs each). RTX 3080 Ti, cold cache, 3 runs each: longest frame 132-134 s on `main`, 1.6 / 4.9 / 4.2 s with a port of this PR; longest queue-worker WorkerWait 1.5 / 2.7 / 2.0 s. - Warm cache pair, supplied by Dextroid17 (RTX 3080 Ti, Linux, 2 runs each): median frame 192 / 137 ms on `main`, 194 / 134 ms with the port; p90 357 / 362 vs 359 / 347 ms; presents 96 / 115 vs 114 / 121. No visible cost of `ReferencedPrograms`; it was not timed on its own. - parl0v, RTX 3060, Minecraft Dungeons II: neutral (6.61 / 6.61 FPS vs 6.70 / 6.60). - Not remeasured on this revision: how often titles write one register of a pair alone, which makes a submit wait for all preparations again. </details> ### 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 - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA26344 (Ghost of Yōtei) first-frame time - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 (this revision's tests); RTX 4090, RTX 3080 Ti, RTX 3070, RTX 3060, lavapipe for the earlier revision (see the reports above) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q9BMpf1muQhujJd4AbteUA
MarcZX10 commented 2026-10-16 15:05:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:05:29Z.


I traced the new scan against the driver paths: readRegisterLists keys each indirect list by packet offset, and draw/dispatch resolve the same program address encoding from the SH register pairs. The per-snapshot wait still prioritizes and settles a demanded registration; work not found by the scan falls back to the existing first-use wait in the queue worker. The regression exercises direct compute binding, indirect vertex binding, half-written addresses, bound-vs-unrelated preparation, and a submission behind unrelated work.

I did not find a concrete correctness issue in the diff. I attempted the focused Linux build locally, but GCC 12 stops earlier in unchanged SrtDescriptorEvaluation.cpp:183 (read.read->Flags<MemoryFlags>()), so I could not run agc_driver_prepared_shaders here. The platform CI jobs are currently skipped; I am not treating the reported Windows/Yōtei runs as my own validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218390759 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6218390759). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:05:29Z. --- I traced the new scan against the driver paths: `readRegisterLists` keys each indirect list by packet offset, and draw/dispatch resolve the same program address encoding from the SH register pairs. The per-snapshot wait still prioritizes and settles a demanded registration; work not found by the scan falls back to the existing first-use wait in the queue worker. The regression exercises direct compute binding, indirect vertex binding, half-written addresses, bound-vs-unrelated preparation, and a submission behind unrelated work. I did not find a concrete correctness issue in the diff. I attempted the focused Linux build locally, but GCC 12 stops earlier in unchanged `SrtDescriptorEvaluation.cpp:183` (`read.read->Flags<MemoryFlags>()`), so I could not run `agc_driver_prepared_shaders` here. The platform CI jobs are currently skipped; I am not treating the reported Windows/Yōtei runs as my own validation.
MarcZX10 commented 2026-10-16 15:07:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:07:41Z.


One small regression-coverage gap: in ReferencedRegistrationPreparation, boundSnapshot->prepared is marked pending and then settled by SettleLater on a separate std::async thread. It does exercise the wait on a referenced snapshot while the unrelated pool task is pending, but it does not exercise the newly integrated path where the bound snapshot's own registration task is queued in RegistrationPreparePool and PrioritizeRegistrationPreparation moves that task ahead of unrelated queued work (the pool only receives the unrelated snapshot in this fixture).

Could the fixture queue the bound preparation through SubmitRegistrationPreparation(..., boundSnapshot->prepared.get()) as well, then verify that the bound task settles before a blocked/unrelated task completes? The separate queue-priority test is useful, but this would connect registry lookup, task identity, prioritization and the submission wait in one regression. I see this as coverage hardening rather than a code defect.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218433597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6218433597). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:07:41Z. --- One small regression-coverage gap: in `ReferencedRegistrationPreparation`, `boundSnapshot->prepared` is marked pending and then settled by `SettleLater` on a separate `std::async` thread. It does exercise the wait on a referenced snapshot while the unrelated pool task is pending, but it does not exercise the newly integrated path where the bound snapshot's own registration task is queued in `RegistrationPreparePool` and `PrioritizeRegistrationPreparation` moves that task ahead of unrelated queued work (the pool only receives the unrelated snapshot in this fixture). Could the fixture queue the bound preparation through `SubmitRegistrationPreparation(..., boundSnapshot->prepared.get())` as well, then verify that the bound task settles before a blocked/unrelated task completes? The separate queue-priority test is useful, but this would connect registry lookup, task identity, prioritization and the submission wait in one regression. I see this as coverage hardening rather than a code defect.
jotitadev commented 2026-10-16 16:24:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T16:24:45Z.

Review: COMMENTED


A Linux run of the regression, which the description (Windows) and the review above (GCC 12 stopped before it) do not have.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head 20cc5ae56 merged into main 452494439 (clean merge). The build of PreparedShaders.cpp and the changed driver sources goes through on GCC 15.2.

  • agc_driver_prepared_shaders: 3/3 pass on the RTX 3070 (Selected GPU name=NVIDIA GeForce RTX 3070) and 3/3 on lavapipe, about 3.4 to 3.9 s per run (1.1 s on main with main's test).
  • ^agc_driver_(prepared|registered), 18 tests, -j1: 18/18 on both devices, no skips.
  • No negative control: with main's Submission.* and ShaderRegistry.* the new test does not compile (ReferencedPrograms is not a member of AgcDriver::DriverDetail).

This does not address the coverage gap raised above (the bound snapshot's own task queued in RegistrationPreparePool); I did not try that variant.

Not run: Windows, AMD, the full suite, any title.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5550649159 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#pullrequestreview-5550649159). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T16:24:45Z. **Review:** COMMENTED --- A Linux run of the regression, which the description (Windows) and the review above (GCC 12 stopped before it) do not have. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `20cc5ae56` merged into `main` `452494439` (clean merge). The build of `PreparedShaders.cpp` and the changed driver sources goes through on GCC 15.2. - `agc_driver_prepared_shaders`: 3/3 pass on the RTX 3070 (`Selected GPU name=NVIDIA GeForce RTX 3070`) and 3/3 on lavapipe, about 3.4 to 3.9 s per run (1.1 s on `main` with `main`'s test). - `^agc_driver_(prepared|registered)`, 18 tests, `-j1`: 18/18 on both devices, no skips. - No negative control: with `main`'s `Submission.*` and `ShaderRegistry.*` the new test does not compile (`ReferencedPrograms` is not a member of `AgcDriver::DriverDetail`). This does not address the coverage gap raised above (the bound snapshot's own task queued in `RegistrationPreparePool`); I did not try that variant. Not run: Windows, AMD, the full suite, any title. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Pipodi commented 2026-10-16 16:27:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T16:27:52Z.


Thanks, good catch. 7241b052b now queues the bound preparation through SubmitRegistrationPreparation as well. The test occupies every preparation worker, queues the unrelated preparation ahead of the bound one, and frees a single worker once the submit wait has demanded the bound one. The bound task must run first and the unrelated one must still be pending when the wait returns. With the PrioritizeRegistrationPreparation call removed from AwaitReferencedPreparations, the test fails ("the queued preparation of a bound program was not moved ahead of unrelated queued work").

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6219975365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6219975365). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-16T16:27:52Z. --- Thanks, good catch. 7241b052b now queues the bound preparation through `SubmitRegistrationPreparation` as well. The test occupies every preparation worker, queues the unrelated preparation ahead of the bound one, and frees a single worker once the submit wait has demanded the bound one. The bound task must run first and the unrelated one must still be pending when the wait returns. With the `PrioritizeRegistrationPreparation` call removed from `AwaitReferencedPreparations`, the test fails ("the queued preparation of a bound program was not moved ahead of unrelated queued work").
Dextroid17 commented 2026-10-16 17:15:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T17:15:49Z.


Timed this on Ghost of Yōtei (PPSA26344) on Linux with lavapipe, cold shader cache on every run, base and PR runs interleaved:

run  build   first frame
1    base    231 s
2    PR      181 s
3    base    211 s
4    PR      161 s

Base averages 221 s and the PR 171 s (2 runs each), so the first frame came about 50 s (23%) earlier. The ranges do not overlap (base 211–231 s, PR 161–181 s). The time comes from a memory probe that logs every 10 s, so each value can be up to 10 s after the actual first frame.

Setup: both builds are main 5d9dcc42d plus the same 11 local commits that are not in main. These are the sceNetCtlGetInfo code 12 fix (the same fix as #6227), sRGB and min/max texture copies this title needs to get past three early stops, two shader-cache checks, and the env-gated memory probe used for the timing. The PR build adds 20cc5ae56 and 7241b052b, which cherry-picked cleanly. The two trees differ only by those two commits, and libSceAgcDriver.prx is the only library built from the files they change. -O2 build (CMAKE_BUILD_TYPE empty), lavapipe from Mesa 26.2.4 (LLVM 23.1.1), same game files, same host.

For comparison, your Windows runs had the first frame at 40 s with this PR against 101 s on main (61 s), and main ranged 80–181 s across your three runs. A 50 s gain here is in the same range. I did not measure the submit waits themselves.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6220822155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6220822155). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-16T17:15:49Z. --- Timed this on Ghost of Yōtei (PPSA26344) on Linux with lavapipe, cold shader cache on every run, base and PR runs interleaved: ``` run build first frame 1 base 231 s 2 PR 181 s 3 base 211 s 4 PR 161 s ``` Base averages 221 s and the PR 171 s (2 runs each), so the first frame came about 50 s (23%) earlier. The ranges do not overlap (base 211–231 s, PR 161–181 s). The time comes from a memory probe that logs every 10 s, so each value can be up to 10 s after the actual first frame. Setup: both builds are `main` 5d9dcc42d plus the same 11 local commits that are not in `main`. These are the `sceNetCtlGetInfo` code 12 fix (the same fix as #6227), sRGB and min/max texture copies this title needs to get past three early stops, two shader-cache checks, and the env-gated memory probe used for the timing. The PR build adds 20cc5ae56 and 7241b052b, which cherry-picked cleanly. The two trees differ only by those two commits, and `libSceAgcDriver.prx` is the only library built from the files they change. -O2 build (CMAKE_BUILD_TYPE empty), lavapipe from Mesa 26.2.4 (LLVM 23.1.1), same game files, same host. For comparison, your Windows runs had the first frame at 40 s with this PR against 101 s on `main` (61 s), and `main` ranged 80–181 s across your three runs. A 50 s gain here is in the same range. I did not measure the submit waits themselves. AI-assisted: yes
parl0v commented 2026-10-16 19:03:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T19:03:16Z.


Data point: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows, APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1; main 93e54cedd vs main + this PR, interleaved with three other PRs in one batch, two rounds. FPS is the mean of the last 10 [present] windows, GPU busy and idle gaps per frame over the last 8.

libs FPS GPU busy idle gaps
main 6.61 / 6.61 104 / 105 ms 46 / 46 ms
+ this PR (7241b052b) 6.70 / 6.60 106 / 104 ms 44 / 47 ms

Neutral on this scene (mean +0.7 %, within the row spread); no regression. 0 fatal.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222691727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6222691727). Originally posted by [parl0v](https://github.com/parl0v) on 2026-10-16T19:03:16Z. --- Data point: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows, `APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1`; `main` 93e54cedd vs `main` + this PR, interleaved with three other PRs in one batch, two rounds. FPS is the mean of the last 10 `[present]` windows, GPU busy and idle gaps per frame over the last 8. | libs | FPS | GPU busy | idle gaps | |---|---|---|---| | `main` | 6.61 / 6.61 | 104 / 105 ms | 46 / 46 ms | | + this PR (7241b052b) | 6.70 / 6.60 | 106 / 104 ms | 44 / 47 ms | Neutral on this scene (mean +0.7 %, within the row spread); no regression. 0 fatal. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-20 20:23:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:23:43Z.


I have an independent follow-up in progress for #8470: at shutdown, finish the running library prebuild but discard queued speculative prebuilds, leaving registration preparation and device-replacement waits unchanged. The candidate touches RegistrationPreparePool::Close and the ticket/wait bookkeeping that this PR also refactors, so the current-main branch may need a rebase/adaptation if #6867 lands first. I have not opened or pushed a PR; the candidate still needs a runtime test. Please let me know if you prefer a particular merge order or want me to wait for this pool refactor before preparing the follow-up.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300675072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#issuecomment-6300675072). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T20:23:43Z. --- I have an independent follow-up in progress for #8470: at shutdown, finish the running library prebuild but discard queued speculative prebuilds, leaving registration preparation and device-replacement waits unchanged. The candidate touches `RegistrationPreparePool::Close` and the ticket/wait bookkeeping that this PR also refactors, so the current-main branch may need a rebase/adaptation if #6867 lands first. I have not opened or pushed a PR; the candidate still needs a runtime test. Please let me know if you prefer a particular merge order or want me to wait for this pool refactor before preparing the follow-up.
CnRJay commented 2026-10-21 17:53:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-21T17:53:57Z.

Review: COMMENTED


The result is large and measured (Ghost of Yotei, cold cache, first frame 101 s to 40 s, first submission wait 76.3 s to under 3 s), and moving a bound program's preparation to the front of the queue (#4404) is the right use of the scan. The part I would not merge as is is the fallback.

  • #5007 made Driver::Submit wait for every queued preparation for one reason: a title that sees a submission take seconds treats the GPU as hung. Goat Simulator 3 (PPSA04159) failed a 10 s timeout when the wait sat in the queue worker. Waiting "in the queue worker at first use" is what this PR leaves for any program the scan misses: bound by an earlier submission, a half-written address, an address reached another way, or an indirect buffer the scan didn't follow. Those cases reproduce the Goat Simulator situation (the GPU side of a submission blocked on a long preparation), and the PR does not say how long such a wait can be. The cold-cache 55,144-dword shader this was found on took 74 s on one thread. If a program the scan misses is bound by a draw, the queue worker blocks for that long.
  • Please add a test where the program is reachable only through a path the scan doesn't see (address written in two halves across submissions; address in an indirect buffer), with a slow preparation, and state the resulting wait. If it is long, the scan needs the missing paths, or the fallback needs a bound (after N seconds, report and continue).
  • The 2.6 s longest wait for 83 bound programs is still a seconds-long submit. It is under the 10 s limit that failed, but the margin is a property of this title on a 4090; a slower machine's cold cache would be longer. State the worst wait by machine, or the time the scan assumes.
  • The numbers are from a tree with #6227 and two local diagnostics. The runs are cold-cache only. Post a warm-cache pair as well to show the scan costs nothing when preparations are already done (ReferencedPrograms walks every copied command on every submit).
  • Marked conflicting with main; rebase before it can be tested again.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5603955023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#pullrequestreview-5603955023). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-21T17:53:57Z. **Review:** COMMENTED --- The result is large and measured (Ghost of Yotei, cold cache, first frame 101 s to 40 s, first submission wait 76.3 s to under 3 s), and moving a bound program's preparation to the front of the queue (#4404) is the right use of the scan. The part I would not merge as is is the fallback. - #5007 made `Driver::Submit` wait for every queued preparation for one reason: a title that sees a submission take seconds treats the GPU as hung. Goat Simulator 3 (PPSA04159) failed a 10 s timeout when the wait sat in the queue worker. Waiting "in the queue worker at first use" is what this PR leaves for any program the scan misses: bound by an earlier submission, a half-written address, an address reached another way, or an indirect buffer the scan didn't follow. Those cases reproduce the Goat Simulator situation (the GPU side of a submission blocked on a long preparation), and the PR does not say how long such a wait can be. The cold-cache 55,144-dword shader this was found on took 74 s on one thread. If a program the scan misses is bound by a draw, the queue worker blocks for that long. - Please add a test where the program is reachable only through a path the scan doesn't see (address written in two halves across submissions; address in an indirect buffer), with a slow preparation, and state the resulting wait. If it is long, the scan needs the missing paths, or the fallback needs a bound (after N seconds, report and continue). - The 2.6 s longest wait for 83 bound programs is still a seconds-long submit. It is under the 10 s limit that failed, but the margin is a property of this title on a 4090; a slower machine's cold cache would be longer. State the worst wait by machine, or the time the scan assumes. - The numbers are from a tree with #6227 and two local diagnostics. The runs are cold-cache only. Post a warm-cache pair as well to show the scan costs nothing when preparations are already done (`ReferencedPrograms` walks every copied command on every submit). - Marked conflicting with `main`; rebase before it can be tested again.
jotitadev commented 2026-10-27 06:24:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T06:24:29Z.

Review: COMMENTED


Follow-up on d5bcd0c6c. My earlier run had no negative control and noted the bound-task gap; the new tests cover both. But merged with current main, a test that came in with #8735 now hangs.

Setup: Ubuntu 26.04, i7-8700, GCC 15.2, Release. Head merged onto main fe2b52c7e (clean merge). ANYPS5_NO_SHADER_CACHE=1, ctest -j1. Devices: RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), picked with VK_ICD_FILENAMES.

  • agc_driver_prepared_shaders: passes 3/3 on each device. The unproven submits wait 1500 ms and the proven pair waits 0 ms.
  • Controls, each 3/3 on both devices:
    • Submit always calling AwaitRegistrationPreparation(), as on main: a submission writing a whole program address waited for an unrelated preparation.
    • Without the !scan.complete fallback: a submission writing half of a program address did not wait for the queued preparations.
    • Without PrioritizeRegistrationPreparation in AwaitReferencedPreparations: the queued preparation of a bound program was not moved ahead of unrelated queued work. That is the gap I raised before, so it is covered now.
  • Regression: agc_driver_prepared_shaders_dispatch_ahead_prewarm times out 3/3 on each device, at 30 s and at 60 s. On plain main fe2b52c7e it passes 3/3 in under 1 s. DispatchAheadPrewarm sets the pending snapshot's prepared->pending = true with no queued task, then submits an ACB that writes its full 0x20c/0x20d pair. The scan is complete, so Submit waits on settled in AwaitReferencedPreparations, and nothing settles it. With the first control applied, the test passes 3/3 again.
  • I also ran 35 entries: ^agc_driver_(prepared|registered|registration|preparation), plus agc_driver_recorder and agc_driver_graphics. The other 34 pass on both devices.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663040353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#pullrequestreview-5663040353). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T06:24:29Z. **Review:** COMMENTED --- Follow-up on `d5bcd0c6c`. My earlier run had no negative control and noted the bound-task gap; the new tests cover both. But merged with current `main`, a test that came in with #8735 now hangs. Setup: Ubuntu 26.04, i7-8700, GCC 15.2, Release. Head merged onto `main` `fe2b52c7e` (clean merge). `ANYPS5_NO_SHADER_CACHE=1`, `ctest -j1`. Devices: RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), picked with `VK_ICD_FILENAMES`. - `agc_driver_prepared_shaders`: passes 3/3 on each device. The unproven submits wait 1500 ms and the proven pair waits 0 ms. - Controls, each 3/3 on both devices: - `Submit` always calling `AwaitRegistrationPreparation()`, as on `main`: `a submission writing a whole program address waited for an unrelated preparation`. - Without the `!scan.complete` fallback: `a submission writing half of a program address did not wait for the queued preparations`. - Without `PrioritizeRegistrationPreparation` in `AwaitReferencedPreparations`: `the queued preparation of a bound program was not moved ahead of unrelated queued work`. That is the gap I raised before, so it is covered now. - **Regression:** `agc_driver_prepared_shaders_dispatch_ahead_prewarm` times out 3/3 on each device, at 30 s and at 60 s. On plain `main` `fe2b52c7e` it passes 3/3 in under 1 s. `DispatchAheadPrewarm` sets the pending snapshot's `prepared->pending = true` with no queued task, then submits an ACB that writes its full `0x20c`/`0x20d` pair. The scan is complete, so `Submit` waits on `settled` in `AwaitReferencedPreparations`, and nothing settles it. With the first control applied, the test passes 3/3 again. - I also ran 35 entries: `^agc_driver_(prepared|registered|registration|preparation)`, plus `agc_driver_recorder` and `agc_driver_graphics`. The other 34 pass on both devices. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-30 14:28:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T14:28:14Z.

Review: COMMENTED


Follow-up on the dispatch_ahead_prewarm hang from my last review: fixed on 08fe590f6.

Linux, Ubuntu 26.04, i7-8700, GCC 15.2, Release. Head merged --no-commit onto main f91137142e, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest -j1.

  • agc_driver_prepared_shaders and agc_driver_prepared_shaders_dispatch_ahead_prewarm: 3/3 on lavapipe (Mesa 26.0.3) and 3/3 on the RTX 3070 (595.99.02). dispatch_ahead_prewarm takes 0.06 s on lavapipe and 0.6 s on the 3070. The unproven submits still wait 1500 ms and the proven pair 0 ms.
  • Control: with only 08fe590f6's ShaderRegistry.cpp hunk reverted, dispatch_ahead_prewarm times out at 30 s, 3/3 on lavapipe. agc_driver_prepared_shaders still passes, as before.
  • ^agc_driver_(prepared|registered|registration|preparation) plus agc_driver_recorder and agc_driver_graphics (38 tests) pass on lavapipe.

The branch conflicts with main again since #12147 (merged today), in ShaderRegistry.cpp's worker loop: main added const bool budgeted = task.budgeted; where this PR adds const auto* const prepared = task.prepared;. I kept both lines for these runs. Nothing else conflicted.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5713744432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#pullrequestreview-5713744432). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T14:28:14Z. **Review:** COMMENTED --- Follow-up on the `dispatch_ahead_prewarm` hang from my last review: fixed on `08fe590f6`. Linux, Ubuntu 26.04, i7-8700, GCC 15.2, Release. Head merged `--no-commit` onto `main` `f91137142e`, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `ctest -j1`. - `agc_driver_prepared_shaders` and `agc_driver_prepared_shaders_dispatch_ahead_prewarm`: 3/3 on lavapipe (Mesa 26.0.3) and 3/3 on the RTX 3070 (595.99.02). `dispatch_ahead_prewarm` takes 0.06 s on lavapipe and 0.6 s on the 3070. The unproven submits still wait 1500 ms and the proven pair 0 ms. - Control: with only `08fe590f6`'s `ShaderRegistry.cpp` hunk reverted, `dispatch_ahead_prewarm` times out at 30 s, 3/3 on lavapipe. `agc_driver_prepared_shaders` still passes, as before. - `^agc_driver_(prepared|registered|registration|preparation)` plus `agc_driver_recorder` and `agc_driver_graphics` (38 tests) pass on lavapipe. The branch conflicts with `main` again since #12147 (merged today), in `ShaderRegistry.cpp`'s worker loop: `main` added `const bool budgeted = task.budgeted;` where this PR adds `const auto* const prepared = task.prepared;`. I kept both lines for these runs. Nothing else conflicted. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
XairRrR commented 2026-11-03 08:45:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T08:45:06Z.

Review: APPROVED


Reviewed — approved

The merged tree builds, and all 24 agc_driver_prepared_shaders* tests pass with the Khronos validation layer. Three targeted negative controls each fail with the expected message, and the one new VUID in the script's comparison also appears with main's production files.

What I ran

Head 36fc8f9cc93098b621694564d4432fc9a3973c75, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 2e2c8ac56814ee32fb9eab40be05cf8b4c32771d, in a clean worktree. Debian 13 VM, 2× Xeon Gold 6136 (32 vCPU), GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...36fc8f9cc93098b621694564d4432fc9a3973c75
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  ctest --test-dir build -j8 --test-load 32 -V -R "agc_driver_prepared_shaders|agc_driver_native_depth_uniform_planes"
# main's four production files restored (Submission.hpp/.cpp, ShaderRegistry.hpp/.cpp):
ninja -C build -j32 -l32 libs agc_driver_native_multisample_depth_tests agc_driver_prepared_shaders_tests
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ... ctest --test-dir build -V -R "^agc_driver_native_depth_uniform_planes$"
# partial controls on the merged Submission.cpp, each rebuilt and run as build/tests/agc_driver_prepared_shaders_tests
# finally the merged files restored, rebuilt, test rerun, git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py all checks passed
Configure / build / libs (script) ok
Script test run (2169 tests) no new failures, no timeouts; 7 known failures that also fail on main
agc_driver_prepared_shaders* (23) + agc_driver_native_depth_uniform_planes, with validation 24/24 pass; the layer loaded; agc_driver_prepared_shaders 9.3 s (longest of the four *_shaders variants: 10.1 s), all under 30 s
Waits measured by UnprovenProgramsAtSubmit on this machine low-only 1500 ms, high-only 1500–1505 ms, low-only through an INDIRECT_BUFFER 1500 ms, proven pair 0 ms
Script's validation comparison, new VUID in agc_driver_native_depth_uniform_planes not caused by this PR: the same 4 VUID-vkCmdDispatch-groupCountX-00386 errors appear with main's production files (the baseline run was on an older main, d1ae628bc2, where this test did not run)
VUID check with main's production files
ctest -R ^agc_driver_native_depth_uniform_planes$ -V   -> exit 0
Validation Error: [ VUID-vkCmdDispatch-groupCountX-00386 ]   x4 (same count as the merged tree)
Insert instance layer                                         x4

Negative control

When main's four production files are restored, the test does not compile ('ReferencedPrograms' is not a member of 'AgcDriver::DriverDetail'), as jotitadev already reported. So I changed single lines in the merged Submission.cpp instead, rebuilding and running the test after each change:

Change Result
0x048u removed from programRegisters (the classic-VS fix taken from JJenkx) fails: a pixel and classic vertex program pair did not both reach the submit preparation wait
Submit always waits for every queued preparation (main's behaviour) fails: a submission writing a whole program address waited for an unrelated preparation
!scan.complete fallback removed fails: a submission writing half of a program address did not wait for the queued preparations

Afterwards I restored the merged file and rebuilt. The test passes again, and git status --porcelain is empty. This confirms on Linux and lavapipe the controls jotitadev ran and the classic-VS regression JJenkx reported.

Findings

Blocking

None.

Non-blocking

  • The Yōtei traces are not attached. CONTRIBUTING asks a perf PR to attach its traces. The description has both summary lines and a digest table, but says the traces "are kept locally and can be shared on request". JJenkx's archive has a main/change trace pair, but it is for Severed Steel. Suggested fix: attach the two aps5-trace-*.json.gz files that the summary lines name.
  • The measured revision is older than the head. The Yōtei numbers come from 4703b22bde. Since then the branch gained the pool-ownership wait (761ef1105e) and the 0x048 vertex pair. The 0x048 fix makes submit wait for more programs. So the "3.2 s longest, 7 s total" figure in docs/dev/debt/libSceAgcDriver.md:333 may be too low for the current code. Suggested fix: re-measure, or say in the debt entry which revision the figure is from.
  • The Unblocks line has no discussion link. The line names PPSA26344 but not its Game bring-up discussion (Unblocks: PPSAxxxxx #N), which CONTRIBUTING asks for.

What I checked in the code without finding a problem:

  • AwaitReferencedPreparations (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp:1919) uses the same upper_bound and code-range lookup as RegisteredProgram.
  • AwaitOwned (ShaderRegistry.cpp:1658) waits on the pool's unfinished sequences under the pool mutex. owned is cleaned up both when a worker finishes a task and when queued tasks are dropped. The pending check takes prepared.mutex and releases it before the pool lock, so the two locks are never held together.
  • ReferencedPrograms (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp:229) builds the address the same way as BoundGraphicsPrograms, and its register list now matches BoundGraphicsPrograms plus 0x20c.

Not verified

  • Hardware GPUs: I ran only on lavapipe.
  • Any title, and the Yōtei and Severed Steel timings.
  • How long submit waits are under the current head on a real workload.
  • The full test suite: I ran only the tests this change reaches.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5749256988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6867#pullrequestreview-5749256988). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T08:45:06Z. **Review:** APPROVED --- # Reviewed — approved The merged tree builds, and all 24 `agc_driver_prepared_shaders*` tests pass with the Khronos validation layer. Three targeted negative controls each fail with the expected message, and the one new VUID in the script's comparison also appears with `main`'s production files. ## What I ran Head `36fc8f9cc93098b621694564d4432fc9a3973c75`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `2e2c8ac56814ee32fb9eab40be05cf8b4c32771d`, in a clean worktree. Debian 13 VM, 2× Xeon Gold 6136 (32 vCPU), GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19). ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...36fc8f9cc93098b621694564d4432fc9a3973c75 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -j8 --test-load 32 -V -R "agc_driver_prepared_shaders|agc_driver_native_depth_uniform_planes" # main's four production files restored (Submission.hpp/.cpp, ShaderRegistry.hpp/.cpp): ninja -C build -j32 -l32 libs agc_driver_native_multisample_depth_tests agc_driver_prepared_shaders_tests VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ... ctest --test-dir build -V -R "^agc_driver_native_depth_uniform_planes$" # partial controls on the merged Submission.cpp, each rebuilt and run as build/tests/agc_driver_prepared_shaders_tests # finally the merged files restored, rebuilt, test rerun, git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | all checks passed | | Configure / build / `libs` (script) | ok | | Script test run (2169 tests) | no new failures, no timeouts; 7 known failures that also fail on `main` | | `agc_driver_prepared_shaders*` (23) + `agc_driver_native_depth_uniform_planes`, with validation | 24/24 pass; the layer loaded; `agc_driver_prepared_shaders` 9.3 s (longest of the four `*_shaders` variants: 10.1 s), all under 30 s | | Waits measured by `UnprovenProgramsAtSubmit` on this machine | low-only 1500 ms, high-only 1500–1505 ms, low-only through an `INDIRECT_BUFFER` 1500 ms, proven pair 0 ms | | Script's validation comparison, new VUID in `agc_driver_native_depth_uniform_planes` | not caused by this PR: the same 4 `VUID-vkCmdDispatch-groupCountX-00386` errors appear with `main`'s production files (the baseline run was on an older `main`, `d1ae628bc2`, where this test did not run) | <details><summary>VUID check with main's production files</summary> ``` ctest -R ^agc_driver_native_depth_uniform_planes$ -V -> exit 0 Validation Error: [ VUID-vkCmdDispatch-groupCountX-00386 ] x4 (same count as the merged tree) Insert instance layer x4 ``` </details> ## Negative control When `main`'s four production files are restored, the test does not compile (`'ReferencedPrograms' is not a member of 'AgcDriver::DriverDetail'`), as jotitadev already reported. So I changed single lines in the merged `Submission.cpp` instead, rebuilding and running the test after each change: | Change | Result | |---|---| | `0x048u` removed from `programRegisters` (the classic-VS fix taken from JJenkx) | fails: `a pixel and classic vertex program pair did not both reach the submit preparation wait` | | `Submit` always waits for every queued preparation (`main`'s behaviour) | fails: `a submission writing a whole program address waited for an unrelated preparation` | | `!scan.complete` fallback removed | fails: `a submission writing half of a program address did not wait for the queued preparations` | Afterwards I restored the merged file and rebuilt. The test passes again, and `git status --porcelain` is empty. This confirms on Linux and lavapipe the controls jotitadev ran and the classic-VS regression JJenkx reported. ## Findings ### Blocking None. ### Non-blocking - **The Yōtei traces are not attached.** CONTRIBUTING asks a `perf` PR to attach its traces. The description has both summary lines and a digest table, but says the traces "are kept locally and can be shared on request". JJenkx's archive has a `main`/change trace pair, but it is for Severed Steel. Suggested fix: attach the two `aps5-trace-*.json.gz` files that the summary lines name. - **The measured revision is older than the head.** The Yōtei numbers come from `4703b22bde`. Since then the branch gained the pool-ownership wait (`761ef1105e`) and the `0x048` vertex pair. The `0x048` fix makes submit wait for more programs. So the "3.2 s longest, 7 s total" figure in `docs/dev/debt/libSceAgcDriver.md:333` may be too low for the current code. Suggested fix: re-measure, or say in the debt entry which revision the figure is from. - **The Unblocks line has no discussion link.** The line names PPSA26344 but not its Game bring-up discussion (`Unblocks: PPSAxxxxx #N`), which CONTRIBUTING asks for. What I checked in the code without finding a problem: - `AwaitReferencedPreparations` (`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp:1919`) uses the same `upper_bound` and code-range lookup as `RegisteredProgram`. - `AwaitOwned` (`ShaderRegistry.cpp:1658`) waits on the pool's `unfinished` sequences under the pool mutex. `owned` is cleaned up both when a worker finishes a task and when queued tasks are dropped. The `pending` check takes `prepared.mutex` and releases it before the pool lock, so the two locks are never held together. - `ReferencedPrograms` (`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp:229`) builds the address the same way as `BoundGraphicsPrograms`, and its register list now matches `BoundGraphicsPrograms` plus `0x20c`. ## Not verified - Hardware GPUs: I ran only on lavapipe. - Any title, and the Yōtei and Severed Steel timings. - How long submit waits are under the current head on a real workload. - The full test suite: I ran only the tests this change reaches. <!-- anyps5-bots job=3199 head=36fc8f9cc93098b621694564d4432fc9a3973c75 -->
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!6867
No description provided.