perf(libSceAgcDriver): stop the idle store for a thread blocked on the GPU mutex #20145

Merged
xXPBSXx merged 4 commits from upstream-pr/20145 into main 2026-11-15 10:58:12 +00:00
xXPBSXx commented 2026-11-14 17:59:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-14T17:59:00Z.


What

When queue 0 has nothing queued, the queue worker stores the pending storage-image results back to guest memory (VulkanDevice::StoreIdleResults, which calls StorageTexture::FlushAllPendingUntil in pieces of 4 MiB) while holding GuestMemory::GpuMutex. Its stop test looks only at the queue state, so a title thread that is blocked on the mutex and therefore has queued nothing does not make it stop: the store runs on, and the title waits behind it.

In Slay The Princess (PPSA24423) on main the title waited behind the idle store for up to 348 to 373 ms (single waits in the 20 s capture windows), and the worker sat in idle_and_completion_poll for up to 1.5 s. This PR adds two things. GpuMutexType::Waiters() counts the threads blocked in lock(), spinning included (a relaxed atomic that is only counted, nothing waits on it). YieldToGpuMutexWaiters(stop) wraps the stop predicate: it never stops before the first piece has been stored, and after that stops as soon as another thread is blocked on the mutex. StoreIdleResults passes it to FlushAllPendingUntil. The rest of the pending results is stored in the next idle round, as before.

Side effects. The counter changes no ordering and cannot deadlock (no thread waits for it). The first piece is always stored, so a mutex that is always contended does not starve the store; a store that yields stores its remaining images in later idle rounds, so the number of submits per image can grow (not measured separately). #16011 makes FlushPending wait for the recorder after a piece of an idle flush, under the mutex; it does not touch this predicate and merges with this change without a conflict, but each piece it stores then holds the mutex for that wait too. #20015 ends the 50 ms quiet-period wait of queue 0 in QueueWorker.cpp when a completion is pending; it is the same idle path but another wait (this change stops a store that is already running for a thread blocked on the mutex), and it merges with this change without a conflict. The tests of #20015 and #16011 were not run on a tree with this change.

What is not claimed: the frames are not free of stalls. With this change, residual stalls remain in some intervals (see the table), for example a 246 ms frame in one capture window where the worker was in idle_and_completion_poll for 239 ms while the title was not blocked on the mutex; I do not know their source.

Tested

Windows 10 Pro, AMD Ryzen 7 5800X3D, NVIDIA GeForce RTX 4080 SUPER (driver NVIDIA 610.74 as shown in the summary lines) and AMD Radeon RX 6400 for the tests. WinLibs GCC Release.

Tests. Two pairs, each test commit failing on main and the following fix commit passing, on the RTX 4080 SUPER: the new CountsMutexWaiters (GpuMutexType::Waiters() is 0 without a waiter and while holding, 1 while a thread is blocked, 0 again afterwards) and StopsForMutexWaiter (with a thread blocked on the mutex an idle store stops after exactly one of two pending images and reports it is not finished; with none it stores both; the result of both stores is in guest memory). Without the fix agc_driver_idle_store_yields aborts, with it it passes; the pairs were run again on main 0f4538fa022 as the base (the series was rebased from 0d2db33e0d5; git range-diff shows the two fix commits unchanged and the two test commits differing only by two comments removed from GuestMemory.hpp), on the RTX 4080 SUPER. With the validation layer (VK_LAYER_KHRONOS_validation, inserted into the device as VK_LOADER_DEBUG=layer shows) the new test program on this head passes on the RTX 4080 SUPER and on the RX 6400 with 0 VUID- lines, and the test commit without the fix aborts at the same place as without the layer on both GPUs. ctest of the 279 tests of agc_driver_* whose name contains draw, pipeline, present, label, recorder, commit, frame_replay, idle, store or mutex, on main 0f4538fa022 and on this head, once each on both GPUs, without the validation layer: the same result in all four runs: one test (agc_driver_write_data_written_ahead_draw_pipeline) fails the same way on main and on this head in all four full runs, but passes in 12 of 12 separate runs of that test alone (3 per arm and GPU), so it depends on the run of the whole group and not on this change; three tests were not run in the full runs because their programs were not built (agc_driver_batch_cap_wait_draw_pipeline, agc_driver_color_write_mask_dynamic_in_pipeline, agc_driver_prepared_shaders_abi_deferred_background_draw) and pass when built and run (3 of 3 on each arm and GPU); and agc_driver_present_upscale and agc_driver_partially_committed_volume_page_samples skip themselves (on the RX 6400 agc_driver_copied_writer_label_order and _drain skip as well). On the earlier base 0d2db33e0d5 the same run over 267 tests had no failing test (24 programs not built in the first pass passed in a second pass on each arm and GPU). The validation layer crashes in most of the other tests on the base too, so I do not claim that no new validation message appears outside the new test program.

Frame stalls, PPSA24423, measured on the earlier base 0d2db33e0d5 (A) and the head before the rebase 0a74e649147 (B), 1920x1080, 600 s runs, APS5_TRACE_SUMMARY_EVERY=10, APS5_TRACE_SECONDS=300:20, APS5_TRACE_EVENTS=2097152, no APS5_PROFILE_DRAW, arms interleaved (B A B A B A B A), same session. A stall interval is a 10 s interval from 60 s on whose longest frame is over 40 ms; the scene differs between runs (title state, not controlled), so the share per run varies from 24 to 83 %.

run arm intervals stall intervals share longest frame, median of intervals (ms) title wait on the GPU mutex over 50 ms in the capture window (count, longest)
1 head 47 18 38 % 17 0 (4 ms)
2 main 49 37 76 % 490 1 (348 ms)
3 head 49 38 78 % 225 0 (18 ms)
4 main 46 38 83 % 566 3 (373 ms)
5 head 51 33 65 % 121 0 (4 ms)
6 main 49 35 71 % 470 0 (11 ms)
7 head 38 9 24 % 18 0 (19 ms)
8 main 51 32 63 % 442 0 (4 ms)

Over the four pairs there were fewer stall intervals with the change (the rebased series differs only by two removed comments): 98 of 185 (53 %) against 142 of 195 (73 %), and the head is lower in all four pairs (38 against 76, 78 against 83, 65 against 71, 24 against 63 %). In the capture windows (one 20 s window per run) the title waited on the mutex for more than 50 ms in two of the four main windows (1 and 3 waits, up to 348 and 373 ms) and in none of the four head windows (up to 19 ms); in the other two main windows it did not wait either (up to 11 ms) although those runs had stall intervals, so stalls also have other sources. The longest wait of the worker in idle_and_completion_poll in a window was 238 ms with the change and 1548 ms on main. Presents per 10 s: medians 544 to 600 with the change, 530 to 572 on main; frame time p50 about 16.7 to 16.9 ms in all runs (the title runs at 60 fps between stalls).

VK_ERROR_DEVICE_LOST: 0 of the 8 runs ended that way (title and arm). The GPU was also used by other jobs of the machine's owner: nvidia-smi every 30 s for runs 5 to 8: mean 18, 27, 15 and 20 % (single readings 1 to 45 %); there are no readings for runs 1 to 4 (the log of that series was overwritten). Working set maximum of the process in runs 5 to 8: 3978 and 4192 MiB with the change (runs 7 and 5) against 4106 and 4639 MiB on main (runs 8 and 6), so it is not larger with the change.

The summary line of one capture window of each commit (main run 2, head run 1) and the digests are below; the traces are attached.

{"commit":"0d2db33e0d50","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"300:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 610.74","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 5800X3D 8-Core Processor","cpu_threads":16,"memory_mib":65459,"title_id":"PPSA24423","title":"Slay The Princess","content_version":"02.003.000","resolution":"1920x1080","window":{"spec":"seconds 300:20","first_present":13613,"ms":20003.381},"presents":1117,"frame_ms":{"p50":16.943,"p90":17.017,"p99":17.086,"max":1362.647},"gpu_busy_ms_per_present":0.691,"worker_busy_pct":{"queue worker 0x0":87.218},"phase_totals_ms":{"Driver.Completion":0.802,"Driver.Draw":4752.441,"Driver.Draw.device_setup":238.515,"Driver.Draw.draw_enqueued":1075.831,"Driver.Draw.post_compile_prepare":48.264,"Driver.Draw.prepare":313.123,"Driver.Draw.shader_compile_and_link":2983.305,"Driver.EndSubmission":1.041,"Driver.Packet":17444.543,"Driver.Packet.device_lock":43.407,"Driver.Packet.draw":4820.134,"Driver.Packet.execute":262.693,"Driver.Packet.flip_flush":71.328,"Driver.Packet.flush_between_packets":144.222,"Driver.Packet.pipeline_drain":327.45,"Driver.Packet.pipeline_prepare":74.109,"Driver.Packet.prepare_memory":72.405,"Driver.Packet.rendering_wait":11560.889,"Driver.Present":365.468,"Driver.Present.acquire_image":17.538,"Driver.Present.device_setup":0.596,"Driver.Present.gpu_mutex_wait":2.552,"Driver.Present.inflight_wait":3.832,"Driver.Present.present_display_buffer":133.697,"Driver.Present.queue_present":105.013,"Driver.Present.release_and_callback":4.795,"Driver.Present.render_fence_wait":94.377,"Driver.Present.resize":1.777,"Driver.Present.validate":0.454,"Driver.Suspend":0.217,"GpuMutex.wait.draw":1.813,"GpuMutex.wait.end":0.0,"GpuMutex.wait.other":347.77,"GpuMutex.wait.present":0.313,"GpuMutex.wait.wait":27.129,"Graphics.Draw":5072.271,"Graphics.Draw.draw_and_resource_release":2498.637,"Graphics.Draw.index_upload":823.872,"Graphics.Draw.validate":245.117,"Graphics.Draw.vertex_upload":1436.688,"Graphics.Submit":1.127,"Graphics.Submit.command_end":0.064,"Graphics.Submit.queue_submit":1.048,"Graphics.Wait":230.413,"Graphics.Wait.fence_wait":230.37,"Recorder.Reap":24.88,"Recorder.Submit":188.458,"Recorder.WaitSerial":417.008,"Resources.Complete":89.821,"Resources.Prepare":16.837,"Shader.DrawStage":1616.536,"Shader.DrawStage.capture_resources":475.528,"Shader.DrawStage.materialize":734.904,"Shader.DrawStage.prepared_invocation":386.46,"Shader.ResolveAbi":979.222,"Shader.ResolveGraphicsAbi":1243.86,"Shader.ResolveGraphicsStagesAbi":1529.436,"VideoOut.Flip":18027.448,"VideoOut.Flip.completion_mutex_wait":1.821,"VideoOut.Flip.config_mutex_wait":0.169,"VideoOut.Flip.frame_limit":3.121,"VideoOut.Flip.notify_game":72.301,"VideoOut.Flip.present":370.055,"VideoOut.Flip.validate":1.343,"VideoOut.Flip.vblank_wait":17503.812,"VideoOut.Flip.window_prepare":1.915,"VideoOut.Flip.window_title":71.724,"VideoOut.Readiness":2.583,"VideoOut.Readiness.locks_validate":0.808,"Vulkan.Acquire":16.412,"Vulkan.Acquire.acquire_fence_wait":2.74,"Vulkan.Acquire.acquire_image":10.312,"Vulkan.Acquire.fence_reset":2.392,"Vulkan.Acquire.retired_swapchains":0.599,"Vulkan.Present":86.214,"Vulkan.Present.command_record_scale":37.164,"Vulkan.Present.pixel_upload":2.498,"Vulkan.Present.queue_submit":45.454,"Vulkan.QueuePresent":103.009,"Vulkan.QueuePresent.queue_present":101.126,"Vulkan.Retire":94.641,"Vulkan.Retire.wait":88.309},"top_phases_ms_per_frame":{"VideoOut.Flip":16.139,"VideoOut.Flip.vblank_wait":15.67,"Driver.Packet":15.617,"Driver.Packet.rendering_wait":10.35,"Graphics.Draw":4.541,"Driver.Packet.draw":4.315,"Driver.Draw":4.255,"Driver.Draw.shader_compile_and_link":2.671},"owned_draw_counts":{"OwnedDraw.evicted_other":4876},"graphics_track":{"Graphics.Barrier.draw":7897,"Graphics.Barrier.label-run":2224,"Graphics.Barrier.present-blit":4468,"Graphics.Barrier.shadow-publish":1,"Graphics.Barrier.storage-upload":212,"Graphics.Barrier.storage-writeback":33,"Graphics.BarrierMerged.shadow-publish":1,"Graphics.BarrierMerged.storage-writeback":1,"Graphics.Copy":56,"Graphics.Copy.bytes":2359820288,"Graphics.RenderPass":2668,"Graphics.RenderPass.Close.command":102,"Graphics.RenderPass.Close.new-batch":2566,"Graphics.RenderPass.Continued":110554},"trace_dropped":false,"trace":"aps5-trace-0d2db33e0d50-32260.json.gz"}
{"commit":"0a74e649147e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"300:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 610.74","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 5800X3D 8-Core Processor","cpu_threads":16,"memory_mib":65459,"title_id":"PPSA24423","title":"Slay The Princess","content_version":"02.003.000","resolution":"1920x1080","window":{"spec":"seconds 300:20","first_present":14410,"ms":20003.836},"presents":1199,"frame_ms":{"p50":16.71,"p90":17.0,"p99":17.057,"max":17.378},"gpu_busy_ms_per_present":0.47,"worker_busy_pct":{"queue worker 0x0":95.292},"phase_totals_ms":{"Driver.Completion":0.896,"Driver.Draw":2432.054,"Driver.Draw.device_setup":104.839,"Driver.Draw.draw_enqueued":1441.18,"Driver.Draw.post_compile_prepare":21.716,"Driver.Draw.prepare":153.067,"Driver.Draw.shader_compile_and_link":659.491,"Driver.EndSubmission":0.988,"Driver.Packet":19059.955,"Driver.Packet.device_lock":18.425,"Driver.Packet.draw":2459.856,"Driver.Packet.execute":119.215,"Driver.Packet.flip_flush":67.129,"Driver.Packet.flush_between_packets":62.976,"Driver.Packet.memory_wait":0.036,"Driver.Packet.pipeline_drain":387.315,"Driver.Packet.pipeline_prepare":30.396,"Driver.Packet.prepare_memory":30.085,"Driver.Packet.rendering_wait":15657.053,"Driver.Present":419.885,"Driver.Present.acquire_image":19.584,"Driver.Present.device_setup":0.636,"Driver.Present.gpu_mutex_wait":15.193,"Driver.Present.inflight_wait":3.619,"Driver.Present.present_display_buffer":150.657,"Driver.Present.queue_present":113.377,"Driver.Present.release_and_callback":5.743,"Driver.Present.render_fence_wait":107.558,"Driver.Present.resize":2.039,"Driver.Present.validate":0.483,"Driver.Suspend":0.23,"GpuMutex.wait.draw":2.443,"GpuMutex.wait.end":0.188,"GpuMutex.wait.flush":0.151,"GpuMutex.wait.label":0.01,"GpuMutex.wait.present":12.54,"GpuMutex.wait.wait":0.398,"Graphics.Draw":2692.947,"Graphics.Draw.draw_and_resource_release":1665.175,"Graphics.Draw.index_upload":427.892,"Graphics.Draw.validate":88.466,"Graphics.Draw.vertex_upload":486.034,"Graphics.DrawWithRecipe":229.571,"Graphics.DrawWithRecipe.draw_and_resource_release":171.018,"Graphics.DrawWithRecipe.index_upload":24.595,"Graphics.DrawWithRecipe.validate":2.716,"Graphics.DrawWithRecipe.vertex_upload":29.982,"Recorder.Reap":13.489,"Recorder.Submit":161.623,"Recorder.Sync":91.191,"Recorder.WaitSerial":366.768,"Resources.Complete":98.091,"Resources.Prepare":32.313,"Shader.DrawStage":238.214,"Shader.DrawStage.capture_resources":67.106,"Shader.DrawStage.materialize":118.39,"Shader.DrawStage.prepared_invocation":50.044,"Shader.ResolveAbi":395.124,"Shader.ResolveGraphicsAbi":516.995,"Shader.ResolveGraphicsStagesAbi":666.129,"VideoOut.Flip":19447.665,"VideoOut.Flip.completion_mutex_wait":2.29,"VideoOut.Flip.config_mutex_wait":0.173,"VideoOut.Flip.frame_limit":3.547,"VideoOut.Flip.notify_game":26.431,"VideoOut.Flip.present":424.771,"VideoOut.Flip.validate":1.486,"VideoOut.Flip.vblank_wait":18908.251,"VideoOut.Flip.window_prepare":2.696,"VideoOut.Flip.window_title":77.329,"VideoOut.Readiness":2.318,"VideoOut.Readiness.locks_validate":0.697,"Vulkan.Acquire":18.246,"Vulkan.Acquire.acquire_fence_wait":3.057,"Vulkan.Acquire.acquire_image":11.33,"Vulkan.Acquire.fence_reset":2.699,"Vulkan.Acquire.retired_swapchains":0.657,"Vulkan.DrawFromRecipe":231.416,"Vulkan.Present":99.602,"Vulkan.Present.command_record_scale":41.217,"Vulkan.Present.pixel_upload":3.092,"Vulkan.Present.queue_submit":54.023,"Vulkan.QueuePresent":111.076,"Vulkan.QueuePresent.queue_present":109.19,"Vulkan.Retire":107.522,"Vulkan.Retire.wait":100.675},"top_phases_ms_per_frame":{"VideoOut.Flip":16.22,"Driver.Packet":15.897,"VideoOut.Flip.vblank_wait":15.77,"Driver.Packet.rendering_wait":13.058,"Graphics.Draw":2.246,"Driver.Packet.draw":2.052,"Driver.Draw":2.028,"Graphics.Draw.draw_and_resource_release":1.389},"owned_draw_counts":{"OwnedDraw.evicted_other":1984},"graphics_track":{"Graphics.Barrier.draw":7504,"Graphics.Barrier.label-run":3640,"Graphics.Barrier.present-blit":4796,"Graphics.Barrier.shadow-publish":58,"Graphics.Barrier.storage-upload":2964,"Graphics.Barrier.storage-writeback":557,"Graphics.BarrierMerged.shadow-publish":56,"Graphics.BarrierMerged.storage-writeback":65,"Graphics.RenderPass":4149,"Graphics.RenderPass.Close.command":918,"Graphics.RenderPass.Close.image":855,"Graphics.RenderPass.Close.key":576,"Graphics.RenderPass.Close.new-batch":1800,"Graphics.RenderPass.Continued":38417},"trace_dropped":false,"trace":"aps5-trace-0a74e649147e-18376.json.gz"}

Overlap: the 97 other open pull requests that change one of the four files of this branch (found by reading the changed files of all 1542 open pull requests at about 16:28 UTC; nearly all of them through VulkanDevice.cpp) were test-merged on 2026-11-14 at about 16:35 UTC against main 32a2f1e1d73 (the branch is based on 0f4538fa022, which is an ancestor of it); the branch merges into main without a conflict. 55 of them already conflict with main without this change and still conflict with it, 42 merge cleanly with and without it; none conflicts only with this change. Three pull requests that touch the same code path through other files were merged with this branch separately, against main 0a32f988315 at about 16:43 UTC: #16011 (Texture.cpp) and #20015 (QueueWorker.cpp, the quiet period's wait) merge cleanly with and without it, #13963 already conflicts with main. The tests of #20015 and #16011 were not run on a tree with this change.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1074, NVIDIA 610.74 in the trace summary lines) and AMD Radeon RX 6400 (driver 32.0.21033.3005), versions as reported by Windows, Windows 10 Pro 10.0.19045
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5314506409 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20145). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-11-14T17:59:00Z. --- ### What When queue 0 has nothing queued, the queue worker stores the pending storage-image results back to guest memory (`VulkanDevice::StoreIdleResults`, which calls `StorageTexture::FlushAllPendingUntil` in pieces of 4 MiB) while holding `GuestMemory::GpuMutex`. Its stop test looks only at the queue state, so a title thread that is blocked on the mutex and therefore has queued nothing does not make it stop: the store runs on, and the title waits behind it. In Slay The Princess (PPSA24423) on `main` the title waited behind the idle store for up to 348 to 373 ms (single waits in the 20 s capture windows), and the worker sat in `idle_and_completion_poll` for up to 1.5 s. This PR adds two things. `GpuMutexType::Waiters()` counts the threads blocked in `lock()`, spinning included (a relaxed atomic that is only counted, nothing waits on it). `YieldToGpuMutexWaiters(stop)` wraps the stop predicate: it never stops before the first piece has been stored, and after that stops as soon as another thread is blocked on the mutex. `StoreIdleResults` passes it to `FlushAllPendingUntil`. The rest of the pending results is stored in the next idle round, as before. Side effects. The counter changes no ordering and cannot deadlock (no thread waits for it). The first piece is always stored, so a mutex that is always contended does not starve the store; a store that yields stores its remaining images in later idle rounds, so the number of submits per image can grow (not measured separately). #16011 makes `FlushPending` wait for the recorder after a piece of an idle flush, under the mutex; it does not touch this predicate and merges with this change without a conflict, but each piece it stores then holds the mutex for that wait too. #20015 ends the 50 ms quiet-period wait of queue 0 in `QueueWorker.cpp` when a completion is pending; it is the same idle path but another wait (this change stops a store that is already running for a thread blocked on the mutex), and it merges with this change without a conflict. The tests of #20015 and #16011 were not run on a tree with this change. What is not claimed: the frames are not free of stalls. With this change, residual stalls remain in some intervals (see the table), for example a 246 ms frame in one capture window where the worker was in `idle_and_completion_poll` for 239 ms while the title was not blocked on the mutex; I do not know their source. ### Tested Windows 10 Pro, AMD Ryzen 7 5800X3D, NVIDIA GeForce RTX 4080 SUPER (driver `NVIDIA 610.74` as shown in the summary lines) and AMD Radeon RX 6400 for the tests. WinLibs GCC Release. **Tests.** Two pairs, each test commit failing on `main` and the following fix commit passing, on the RTX 4080 SUPER: the new `CountsMutexWaiters` (`GpuMutexType::Waiters()` is 0 without a waiter and while holding, 1 while a thread is blocked, 0 again afterwards) and `StopsForMutexWaiter` (with a thread blocked on the mutex an idle store stops after exactly one of two pending images and reports it is not finished; with none it stores both; the result of both stores is in guest memory). Without the fix `agc_driver_idle_store_yields` aborts, with it it passes; the pairs were run again on `main` `0f4538fa022` as the base (the series was rebased from `0d2db33e0d5`; `git range-diff` shows the two fix commits unchanged and the two test commits differing only by two comments removed from `GuestMemory.hpp`), on the RTX 4080 SUPER. With the validation layer (`VK_LAYER_KHRONOS_validation`, inserted into the device as `VK_LOADER_DEBUG=layer` shows) the new test program on this head passes on the RTX 4080 SUPER and on the RX 6400 with 0 `VUID-` lines, and the test commit without the fix aborts at the same place as without the layer on both GPUs. `ctest` of the 279 tests of `agc_driver_*` whose name contains `draw`, `pipeline`, `present`, `label`, `recorder`, `commit`, `frame_replay`, `idle`, `store` or `mutex`, on `main` `0f4538fa022` and on this head, once each on both GPUs, without the validation layer: the same result in all four runs: one test (`agc_driver_write_data_written_ahead_draw_pipeline`) fails the same way on `main` and on this head in all four full runs, but passes in 12 of 12 separate runs of that test alone (3 per arm and GPU), so it depends on the run of the whole group and not on this change; three tests were not run in the full runs because their programs were not built (`agc_driver_batch_cap_wait_draw_pipeline`, `agc_driver_color_write_mask_dynamic_in_pipeline`, `agc_driver_prepared_shaders_abi_deferred_background_draw`) and pass when built and run (3 of 3 on each arm and GPU); and `agc_driver_present_upscale` and `agc_driver_partially_committed_volume_page_samples` skip themselves (on the RX 6400 `agc_driver_copied_writer_label_order` and `_drain` skip as well). On the earlier base `0d2db33e0d5` the same run over 267 tests had no failing test (24 programs not built in the first pass passed in a second pass on each arm and GPU). The validation layer crashes in most of the other tests on the base too, so I do not claim that no new validation message appears outside the new test program. **Frame stalls, PPSA24423, measured on the earlier base `0d2db33e0d5` (A) and the head before the rebase `0a74e649147` (B), 1920x1080, 600 s runs, `APS5_TRACE_SUMMARY_EVERY=10`, `APS5_TRACE_SECONDS=300:20`, `APS5_TRACE_EVENTS=2097152`, no `APS5_PROFILE_DRAW`, arms interleaved (B A B A B A B A), same session.** A stall interval is a 10 s interval from 60 s on whose longest frame is over 40 ms; the scene differs between runs (title state, not controlled), so the share per run varies from 24 to 83 %. | run | arm | intervals | stall intervals | share | longest frame, median of intervals (ms) | title wait on the GPU mutex over 50 ms in the capture window (count, longest) | |---|---|---|---|---|---|---| | 1 | head | 47 | 18 | 38 % | 17 | 0 (4 ms) | | 2 | main | 49 | 37 | 76 % | 490 | 1 (348 ms) | | 3 | head | 49 | 38 | 78 % | 225 | 0 (18 ms) | | 4 | main | 46 | 38 | 83 % | 566 | 3 (373 ms) | | 5 | head | 51 | 33 | 65 % | 121 | 0 (4 ms) | | 6 | main | 49 | 35 | 71 % | 470 | 0 (11 ms) | | 7 | head | 38 | 9 | 24 % | 18 | 0 (19 ms) | | 8 | main | 51 | 32 | 63 % | 442 | 0 (4 ms) | Over the four pairs there were fewer stall intervals with the change (the rebased series differs only by two removed comments): 98 of 185 (53 %) against 142 of 195 (73 %), and the head is lower in all four pairs (38 against 76, 78 against 83, 65 against 71, 24 against 63 %). In the capture windows (one 20 s window per run) the title waited on the mutex for more than 50 ms in two of the four `main` windows (1 and 3 waits, up to 348 and 373 ms) and in none of the four head windows (up to 19 ms); in the other two `main` windows it did not wait either (up to 11 ms) although those runs had stall intervals, so stalls also have other sources. The longest wait of the worker in `idle_and_completion_poll` in a window was 238 ms with the change and 1548 ms on `main`. Presents per 10 s: medians 544 to 600 with the change, 530 to 572 on `main`; frame time p50 about 16.7 to 16.9 ms in all runs (the title runs at 60 fps between stalls). `VK_ERROR_DEVICE_LOST`: 0 of the 8 runs ended that way (title and arm). The GPU was also used by other jobs of the machine's owner: `nvidia-smi` every 30 s for runs 5 to 8: mean 18, 27, 15 and 20 % (single readings 1 to 45 %); there are no readings for runs 1 to 4 (the log of that series was overwritten). Working set maximum of the process in runs 5 to 8: 3978 and 4192 MiB with the change (runs 7 and 5) against 4106 and 4639 MiB on `main` (runs 8 and 6), so it is not larger with the change. The summary line of one capture window of each commit (`main` run 2, head run 1) and the digests are below; the traces are attached. ```json {"commit":"0d2db33e0d50","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"300:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 610.74","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 5800X3D 8-Core Processor","cpu_threads":16,"memory_mib":65459,"title_id":"PPSA24423","title":"Slay The Princess","content_version":"02.003.000","resolution":"1920x1080","window":{"spec":"seconds 300:20","first_present":13613,"ms":20003.381},"presents":1117,"frame_ms":{"p50":16.943,"p90":17.017,"p99":17.086,"max":1362.647},"gpu_busy_ms_per_present":0.691,"worker_busy_pct":{"queue worker 0x0":87.218},"phase_totals_ms":{"Driver.Completion":0.802,"Driver.Draw":4752.441,"Driver.Draw.device_setup":238.515,"Driver.Draw.draw_enqueued":1075.831,"Driver.Draw.post_compile_prepare":48.264,"Driver.Draw.prepare":313.123,"Driver.Draw.shader_compile_and_link":2983.305,"Driver.EndSubmission":1.041,"Driver.Packet":17444.543,"Driver.Packet.device_lock":43.407,"Driver.Packet.draw":4820.134,"Driver.Packet.execute":262.693,"Driver.Packet.flip_flush":71.328,"Driver.Packet.flush_between_packets":144.222,"Driver.Packet.pipeline_drain":327.45,"Driver.Packet.pipeline_prepare":74.109,"Driver.Packet.prepare_memory":72.405,"Driver.Packet.rendering_wait":11560.889,"Driver.Present":365.468,"Driver.Present.acquire_image":17.538,"Driver.Present.device_setup":0.596,"Driver.Present.gpu_mutex_wait":2.552,"Driver.Present.inflight_wait":3.832,"Driver.Present.present_display_buffer":133.697,"Driver.Present.queue_present":105.013,"Driver.Present.release_and_callback":4.795,"Driver.Present.render_fence_wait":94.377,"Driver.Present.resize":1.777,"Driver.Present.validate":0.454,"Driver.Suspend":0.217,"GpuMutex.wait.draw":1.813,"GpuMutex.wait.end":0.0,"GpuMutex.wait.other":347.77,"GpuMutex.wait.present":0.313,"GpuMutex.wait.wait":27.129,"Graphics.Draw":5072.271,"Graphics.Draw.draw_and_resource_release":2498.637,"Graphics.Draw.index_upload":823.872,"Graphics.Draw.validate":245.117,"Graphics.Draw.vertex_upload":1436.688,"Graphics.Submit":1.127,"Graphics.Submit.command_end":0.064,"Graphics.Submit.queue_submit":1.048,"Graphics.Wait":230.413,"Graphics.Wait.fence_wait":230.37,"Recorder.Reap":24.88,"Recorder.Submit":188.458,"Recorder.WaitSerial":417.008,"Resources.Complete":89.821,"Resources.Prepare":16.837,"Shader.DrawStage":1616.536,"Shader.DrawStage.capture_resources":475.528,"Shader.DrawStage.materialize":734.904,"Shader.DrawStage.prepared_invocation":386.46,"Shader.ResolveAbi":979.222,"Shader.ResolveGraphicsAbi":1243.86,"Shader.ResolveGraphicsStagesAbi":1529.436,"VideoOut.Flip":18027.448,"VideoOut.Flip.completion_mutex_wait":1.821,"VideoOut.Flip.config_mutex_wait":0.169,"VideoOut.Flip.frame_limit":3.121,"VideoOut.Flip.notify_game":72.301,"VideoOut.Flip.present":370.055,"VideoOut.Flip.validate":1.343,"VideoOut.Flip.vblank_wait":17503.812,"VideoOut.Flip.window_prepare":1.915,"VideoOut.Flip.window_title":71.724,"VideoOut.Readiness":2.583,"VideoOut.Readiness.locks_validate":0.808,"Vulkan.Acquire":16.412,"Vulkan.Acquire.acquire_fence_wait":2.74,"Vulkan.Acquire.acquire_image":10.312,"Vulkan.Acquire.fence_reset":2.392,"Vulkan.Acquire.retired_swapchains":0.599,"Vulkan.Present":86.214,"Vulkan.Present.command_record_scale":37.164,"Vulkan.Present.pixel_upload":2.498,"Vulkan.Present.queue_submit":45.454,"Vulkan.QueuePresent":103.009,"Vulkan.QueuePresent.queue_present":101.126,"Vulkan.Retire":94.641,"Vulkan.Retire.wait":88.309},"top_phases_ms_per_frame":{"VideoOut.Flip":16.139,"VideoOut.Flip.vblank_wait":15.67,"Driver.Packet":15.617,"Driver.Packet.rendering_wait":10.35,"Graphics.Draw":4.541,"Driver.Packet.draw":4.315,"Driver.Draw":4.255,"Driver.Draw.shader_compile_and_link":2.671},"owned_draw_counts":{"OwnedDraw.evicted_other":4876},"graphics_track":{"Graphics.Barrier.draw":7897,"Graphics.Barrier.label-run":2224,"Graphics.Barrier.present-blit":4468,"Graphics.Barrier.shadow-publish":1,"Graphics.Barrier.storage-upload":212,"Graphics.Barrier.storage-writeback":33,"Graphics.BarrierMerged.shadow-publish":1,"Graphics.BarrierMerged.storage-writeback":1,"Graphics.Copy":56,"Graphics.Copy.bytes":2359820288,"Graphics.RenderPass":2668,"Graphics.RenderPass.Close.command":102,"Graphics.RenderPass.Close.new-batch":2566,"Graphics.RenderPass.Continued":110554},"trace_dropped":false,"trace":"aps5-trace-0d2db33e0d50-32260.json.gz"} ``` ```json {"commit":"0a74e649147e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"absent","APS5_TRACE_EVENTS":"2097152","APS5_TRACE_SECONDS":"300:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 610.74","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 5800X3D 8-Core Processor","cpu_threads":16,"memory_mib":65459,"title_id":"PPSA24423","title":"Slay The Princess","content_version":"02.003.000","resolution":"1920x1080","window":{"spec":"seconds 300:20","first_present":14410,"ms":20003.836},"presents":1199,"frame_ms":{"p50":16.71,"p90":17.0,"p99":17.057,"max":17.378},"gpu_busy_ms_per_present":0.47,"worker_busy_pct":{"queue worker 0x0":95.292},"phase_totals_ms":{"Driver.Completion":0.896,"Driver.Draw":2432.054,"Driver.Draw.device_setup":104.839,"Driver.Draw.draw_enqueued":1441.18,"Driver.Draw.post_compile_prepare":21.716,"Driver.Draw.prepare":153.067,"Driver.Draw.shader_compile_and_link":659.491,"Driver.EndSubmission":0.988,"Driver.Packet":19059.955,"Driver.Packet.device_lock":18.425,"Driver.Packet.draw":2459.856,"Driver.Packet.execute":119.215,"Driver.Packet.flip_flush":67.129,"Driver.Packet.flush_between_packets":62.976,"Driver.Packet.memory_wait":0.036,"Driver.Packet.pipeline_drain":387.315,"Driver.Packet.pipeline_prepare":30.396,"Driver.Packet.prepare_memory":30.085,"Driver.Packet.rendering_wait":15657.053,"Driver.Present":419.885,"Driver.Present.acquire_image":19.584,"Driver.Present.device_setup":0.636,"Driver.Present.gpu_mutex_wait":15.193,"Driver.Present.inflight_wait":3.619,"Driver.Present.present_display_buffer":150.657,"Driver.Present.queue_present":113.377,"Driver.Present.release_and_callback":5.743,"Driver.Present.render_fence_wait":107.558,"Driver.Present.resize":2.039,"Driver.Present.validate":0.483,"Driver.Suspend":0.23,"GpuMutex.wait.draw":2.443,"GpuMutex.wait.end":0.188,"GpuMutex.wait.flush":0.151,"GpuMutex.wait.label":0.01,"GpuMutex.wait.present":12.54,"GpuMutex.wait.wait":0.398,"Graphics.Draw":2692.947,"Graphics.Draw.draw_and_resource_release":1665.175,"Graphics.Draw.index_upload":427.892,"Graphics.Draw.validate":88.466,"Graphics.Draw.vertex_upload":486.034,"Graphics.DrawWithRecipe":229.571,"Graphics.DrawWithRecipe.draw_and_resource_release":171.018,"Graphics.DrawWithRecipe.index_upload":24.595,"Graphics.DrawWithRecipe.validate":2.716,"Graphics.DrawWithRecipe.vertex_upload":29.982,"Recorder.Reap":13.489,"Recorder.Submit":161.623,"Recorder.Sync":91.191,"Recorder.WaitSerial":366.768,"Resources.Complete":98.091,"Resources.Prepare":32.313,"Shader.DrawStage":238.214,"Shader.DrawStage.capture_resources":67.106,"Shader.DrawStage.materialize":118.39,"Shader.DrawStage.prepared_invocation":50.044,"Shader.ResolveAbi":395.124,"Shader.ResolveGraphicsAbi":516.995,"Shader.ResolveGraphicsStagesAbi":666.129,"VideoOut.Flip":19447.665,"VideoOut.Flip.completion_mutex_wait":2.29,"VideoOut.Flip.config_mutex_wait":0.173,"VideoOut.Flip.frame_limit":3.547,"VideoOut.Flip.notify_game":26.431,"VideoOut.Flip.present":424.771,"VideoOut.Flip.validate":1.486,"VideoOut.Flip.vblank_wait":18908.251,"VideoOut.Flip.window_prepare":2.696,"VideoOut.Flip.window_title":77.329,"VideoOut.Readiness":2.318,"VideoOut.Readiness.locks_validate":0.697,"Vulkan.Acquire":18.246,"Vulkan.Acquire.acquire_fence_wait":3.057,"Vulkan.Acquire.acquire_image":11.33,"Vulkan.Acquire.fence_reset":2.699,"Vulkan.Acquire.retired_swapchains":0.657,"Vulkan.DrawFromRecipe":231.416,"Vulkan.Present":99.602,"Vulkan.Present.command_record_scale":41.217,"Vulkan.Present.pixel_upload":3.092,"Vulkan.Present.queue_submit":54.023,"Vulkan.QueuePresent":111.076,"Vulkan.QueuePresent.queue_present":109.19,"Vulkan.Retire":107.522,"Vulkan.Retire.wait":100.675},"top_phases_ms_per_frame":{"VideoOut.Flip":16.22,"Driver.Packet":15.897,"VideoOut.Flip.vblank_wait":15.77,"Driver.Packet.rendering_wait":13.058,"Graphics.Draw":2.246,"Driver.Packet.draw":2.052,"Driver.Draw":2.028,"Graphics.Draw.draw_and_resource_release":1.389},"owned_draw_counts":{"OwnedDraw.evicted_other":1984},"graphics_track":{"Graphics.Barrier.draw":7504,"Graphics.Barrier.label-run":3640,"Graphics.Barrier.present-blit":4796,"Graphics.Barrier.shadow-publish":58,"Graphics.Barrier.storage-upload":2964,"Graphics.Barrier.storage-writeback":557,"Graphics.BarrierMerged.shadow-publish":56,"Graphics.BarrierMerged.storage-writeback":65,"Graphics.RenderPass":4149,"Graphics.RenderPass.Close.command":918,"Graphics.RenderPass.Close.image":855,"Graphics.RenderPass.Close.key":576,"Graphics.RenderPass.Close.new-batch":1800,"Graphics.RenderPass.Continued":38417},"trace_dropped":false,"trace":"aps5-trace-0a74e649147e-18376.json.gz"} ``` Overlap: the 97 other open pull requests that change one of the four files of this branch (found by reading the changed files of all 1542 open pull requests at about 16:28 UTC; nearly all of them through `VulkanDevice.cpp`) were test-merged on 2026-11-14 at about 16:35 UTC against `main` `32a2f1e1d73` (the branch is based on `0f4538fa022`, which is an ancestor of it); the branch merges into `main` without a conflict. 55 of them already conflict with `main` without this change and still conflict with it, 42 merge cleanly with and without it; none conflicts only with this change. Three pull requests that touch the same code path through other files were merged with this branch separately, against `main` `0a32f988315` at about 16:43 UTC: #16011 (`Texture.cpp`) and #20015 (`QueueWorker.cpp`, the quiet period's wait) merge cleanly with and without it, #13963 already conflicts with `main`. The tests of #20015 and #16011 were not run on a tree with this change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 4080 SUPER (driver 32.0.16.1074, `NVIDIA 610.74` in the trace summary lines) and AMD Radeon RX 6400 (driver 32.0.21033.3005), versions as reported by Windows, Windows 10 Pro 10.0.19045 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-14 19:00:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T19:00:54Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and its targeted tests support merging, though I did not run the reported checks myself.

What I ran

Reviewed head 645c18f94226de139809028b89e7ef10e0806907. I read the prepared description, commits, manifest, and diff, plus the changed GuestMemory.hpp, GuestMemory.cpp, and IdleStoreYields.cpp and targeted context in Mutex.hpp, HandoffSpin.hpp, Texture.cpp, and VulkanDevice.cpp. VulkanDevice.cpp was excluded from the prepared full-text files but its changed function was read through the pinned reader. No commands or tests were run.

Results

Check Result Note
Change and call path review passed Waiter count and flush stop behavior inspected
Tests not run Test results in the description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build, tests, or GPU measurements. The reported Windows and GPU results were not independently verified. Files reviewed: GuestMemory.hpp, GuestMemory.cpp, VulkanDevice.cpp changed function, and IdleStoreYields.cpp; targeted context: Mutex.hpp, HandoffSpin.hpp, and Texture.cpp. No changed files were excluded from source inspection; VulkanDevice.cpp was omitted from the prepared full-text bundle because it was too large, then read through the repository reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5906582871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20145#pullrequestreview-5906582871). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T19:00:54Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and its targeted tests support merging, though I did not run the reported checks myself. ## What I ran Reviewed head `645c18f94226de139809028b89e7ef10e0806907`. I read the prepared description, commits, manifest, and diff, plus the changed `GuestMemory.hpp`, `GuestMemory.cpp`, and `IdleStoreYields.cpp` and targeted context in `Mutex.hpp`, `HandoffSpin.hpp`, `Texture.cpp`, and `VulkanDevice.cpp`. `VulkanDevice.cpp` was excluded from the prepared full-text files but its changed function was read through the pinned reader. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Change and call path review | passed | Waiter count and flush stop behavior inspected | | Tests | not run | Test results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build, tests, or GPU measurements. The reported Windows and GPU results were not independently verified. Files reviewed: `GuestMemory.hpp`, `GuestMemory.cpp`, `VulkanDevice.cpp` changed function, and `IdleStoreYields.cpp`; targeted context: `Mutex.hpp`, `HandoffSpin.hpp`, and `Texture.cpp`. No changed files were excluded from source inspection; `VulkanDevice.cpp` was omitted from the prepared full-text bundle because it was too large, then read through the repository reader. ## To get this to a good state Nothing is required.
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!20145
No description provided.