perf(agc): keep the current present's storage images in a recovery that can place the new allocation in host memory #12786

Closed
milescoviello wants to merge 7 commits from upstream-pr/12786 into main
milescoviello commented 2026-10-29 09:00:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-29T09:00:43Z.


What

#12684 lets the sampled texture cache grow past the device's share while a frame's textures don't fit. While the budget has that room, an out-of-memory recovery for an allocation with a host-memory fallback stops at the first sampled entry used in the last two presents. The recovery then goes on to the storage image cache and evicts its least recently used images, whatever their age. In Ghost of Tsushima Director's Cut (PPSA02225 02.024.000), those are the frame's own storage images. They're made again at their next use: 45,000 to 117,000 of them over 210-600 s of the opening, which is 86 to 103 s of storage image creation.

How

Storage cache entries now record the present of their last use: a hit, an insert, StorageImageCached, StorageImagesCached and RepeatStorageSurface. Under the same condition as the sampled stop (room past the device's share, and an allocation with a host-memory fallback), the recovery also stops at the first storage image used in the last two presents. The room is mirrored in an atomic, so the storage half can read it while the sampled cache is busy. The [gpu] texture caches released line says when the storage half stopped.

USAGE.md and the debt entry for the room mention the storage stop.

Tested

At this head 5bcf672fd1 (oneandonlydean's review on Context::DeviceMemoryType): ReclaimFallbackScope moves to Context.hpp, built on a SwapReclaimHostFallback setter that BufferPool.cpp defines next to ReclaimHasHostFallback. DeviceMemoryType now opens the scope around its reclaim before a budget-full allocation goes to host memory (#13064), so the storage stop also applies there. A new recovery mode, recover-storage-recent-type, reports the device-local heap full when the new texture picks its memory type. It requires the current present's storage image to stay cached, the texture to go to host memory, and no device allocation to fail.

  • Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09): ctest -R 'agc_driver_recover_|agc_device_memory_fallback', 15 tests, passes 3 of 3 at this head, the new mode included.
  • A full cmake --build build of every target passes at 8f9db9591e, which differs from this head only in the new test's request-count check.
  • Windows 11 VM (GT 1030, WinLibs GCC 15.2.0, Release): ctest -R 'agc_driver_recover_|agc_device_memory_fallback', 15 tests, passes 3 of 3 at this head.
  • Red control: 41391cc931 is this head with Context.hpp and BufferPool.cpp reverted, so only the new test remains. It fails recover-storage-recent-type 3 of 3 on the Windows VM: while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present. That is the reclaim through DeviceMemoryType evicting the image.

Earlier, at 08ae978210 (oneandonlydean's review; details): d13440dd05 takes the room the storage half uses from the sampled half's read under its lock. 08ae978210 adds four recovery modes: storage-hit, storage-repeat and storage-proved, which keep an image used in the current present through a cache hit, RepeatStorageSurface or a fast proof (StorageImagesCached), and storage-aged, which evicts an image left untouched for two presents. The 25 tests pass 3 of 3. A mutant dropping the present stamp at each of the three sites fails its mode. Khronos validation: 19 of 19 at ba0eaedff6 and 25 of 25 here, no VUID- messages.

Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09), at the first head 544cbf2044 (on #12684's head ba0eaedff6):

  • ctest -R '^agc_driver_recover_|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_storage_cache|^agc_buffer_pool', 21 tests, passes in each of 3 runs. That includes the two new recovery modes:
    • agc_driver_recover_storage-recent_allocation: with room past the device's share and a host fallback, the recovery keeps a storage image used in the current present.
    • agc_driver_recover_storage-recent-noroom_allocation: with no room, it still evicts that image, as before.
  • Each mode fails without the piece it pins:
    • 814a4a79e7 (the storage stop removed) fails storage-recent: while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present.
    • d48018c0d8 (the stop on any host fallback, room or not) fails storage-recent-noroom: with no room past the device's share, sampled allocation recovery did not evict the storage image of the current present.
  • Validation layer (Khronos VK_LAYER_KHRONOS_validation, LunarG SDK) on the same tests, at ba0eaedff6 and at this head: 9 of 9 and 11 of 11 pass, the layer checked the Vulkan device each run creates, and there are no VUID- messages on either side.

Windows 11 VM (GeForce GT 1030, WinLibs GCC, Release), the same regex: at this head 21 of 21 pass in each of 3 runs, and on the stack's base main c9207624bc 14 of 14 (the tests there).

Ghost of Tsushima Director's Cut (PPSA02225 02.024.000), the opening, 600 s runs with pad input and warm caches, APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_SECONDS=300:60, alternating without and with the stop. As in #12684, plain main stops early in this title on native multisample stencil or depth format import is not implemented (#9717), so "without" is #12684's capture build ee55f90649 (its local stack plus #12684's three commits), and "with" is 229a6c1473, the same build plus this PR's commit (the same changed lines as ba0eaedff6..544cbf2044). Each run's trace, aps5-summary.jsonl lines, trace_digest.py output on the trace and on the summary file, and performance_compare.py output for both pairs are in the release storage-recency-got-captures.

Run Build Presents in the interval lines from 195 s Frame p50 in those intervals Storage images made 210-600 s Their creation
B1 without 15 15.2 to 81.9 s 45,200 85.5 s
S2 with 20 11.1 to 28.0 s 11,900 57.5 s
B3 without 12 14.1 to 70.5 s 116,500 103.0 s
S4 with 20 12.4 to 29.4 s 12,850 64.4 s
  • Over the run, the stop cuts the storage images made again by 74 and 89 %, and the longest frame interval from about 70-82 s to about 28-29 s.
  • Window lines. At these frame times, the 60 s trace window holds only 2 to 4 presents per run, so each comparison covers a few frames: B1 against S2 gives frame p50 -21.9 %, mean frame -17.0 % and GPU busy per present -14.8 %. B3 against S4 gives frame p50 -59.3 %, mean frame -48.0 % and GPU busy -8.9 %, with Graphics.Draw.draw_and_resource_release at -70.6 %.
  • The opening is still slow with the stop: the draw committer then limits presents (about 3.6 ms per commit in this scene), which is separate work.
Window summary lines (aps5-summary.jsonl): B1 and B3 without, S2 and S4 with
{"commit":"ee55f9064948","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1151,"ms":72514.499},"presents":3,"frame_ms":{"p50":23861.123,"p90":24912.245,"p99":24912.245,"max":24912.245},"gpu_busy_ms_per_present":3963.606,"worker_busy_pct":{"queue worker 0x0":99.339,"queue worker 0x40":0.069,"queue worker 0x20":66.090,"queue worker 0x48":1.033,"queue worker 0x38":77.115,"queue worker 0x52":35.796,"queue worker 0x30":76.175,"queue worker 0x50":63.683,"queue worker 0x51":1.893},"top_phases_ms_per_frame":{"Driver.Packet":101008.254,"Driver.Packet.memory_wait":73715.714,"Driver.Packet.draw":18356.739,"Driver.Draw":18351.048,"Driver.Draw.shader_compile_and_link":13522.567,"Shader.DrawStage":12956.276,"Graphics.Draw":12011.301,"Graphics.Draw.draw_and_resource_release":11619.511},"trace_dropped":false,"trace":"aps5-trace-ee55f9064948-3.json.gz"}
{"commit":"229a6c147325","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1152,"ms":60167.721},"presents":3,"frame_ms":{"p50":18627.681,"p90":28032.414,"p99":28032.414,"max":28032.414},"gpu_busy_ms_per_present":3376.483,"worker_busy_pct":{"queue worker 0x0":97.536,"queue worker 0x40":0.059,"queue worker 0x20":65.260,"queue worker 0x48":3.038,"queue worker 0x38":82.889,"queue worker 0x52":36.618,"queue worker 0x30":81.748,"queue worker 0x50":58.986,"queue worker 0x51":2.044},"top_phases_ms_per_frame":{"Driver.Packet":85847.134,"Driver.Packet.memory_wait":63103.959,"Driver.Packet.draw":15432.876,"Driver.Draw":15427.807,"Driver.Draw.shader_compile_and_link":12049.275,"Shader.DrawStage":11545.091,"Shader.DrawStage.capture_resources":7798.279,"Graphics.Draw":6953.492},"trace_dropped":false,"trace":"aps5-trace-229a6c147325-3.json.gz"}
{"commit":"ee55f9064948","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1126,"ms":71121.755},"presents":2,"frame_ms":{"p50":51120.311,"p90":51120.311,"p99":51120.311,"max":51120.311},"gpu_busy_ms_per_present":2932.088,"worker_busy_pct":{"queue worker 0x0":99.746,"queue worker 0x40":0.045,"queue worker 0x20":87.721,"queue worker 0x48":3.150,"queue worker 0x38":96.461,"queue worker 0x52":19.588,"queue worker 0x30":95.700,"queue worker 0x50":79.817,"queue worker 0x51":1.852},"top_phases_ms_per_frame":{"Driver.Packet":172035.723,"Driver.Packet.memory_wait":131970.044,"Driver.Packet.draw":32243.880,"Driver.Draw":32238.044,"Graphics.Draw":24491.688,"Graphics.Draw.draw_and_resource_release":24075.473,"Driver.Draw.draw_enqueued":17191.114,"Resources.Complete":16613.777},"trace_dropped":false,"trace":"aps5-trace-ee55f9064948-3.json.gz"}
{"commit":"229a6c147325","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1137,"ms":74017.422},"presents":4,"frame_ms":{"p50":20800.970,"p90":22384.503,"p99":22384.503,"max":22384.503},"gpu_busy_ms_per_present":2671.504,"worker_busy_pct":{"queue worker 0x0":97.978,"queue worker 0x40":0.053,"queue worker 0x20":60.007,"queue worker 0x48":5.537,"queue worker 0x38":77.558,"queue worker 0x52":38.180,"queue worker 0x30":76.856,"queue worker 0x50":55.189,"queue worker 0x51":1.528},"top_phases_ms_per_frame":{"Driver.Packet":76363.516,"Driver.Packet.memory_wait":54510.439,"Driver.Packet.draw":13667.353,"Driver.Draw":13663.344,"Driver.Draw.shader_compile_and_link":9964.705,"Shader.DrawStage":9617.791,"Graphics.Draw":7370.673,"Graphics.Draw.draw_and_resource_release":7075.867},"trace_dropped":false,"trace":"aps5-trace-229a6c147325-3.json.gz"}
performance_compare.py, B3 (baseline) against S4 (candidate)

Performance comparison

Capture Commit Trace Presents Window (ms)
baseline ee55f9064948 aps5-trace-ee55f9064948-3.json.gz 2 71121.755
candidate 229a6c147325 aps5-trace-229a6c147325-3.json.gz 4 74017.422
  • Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
  • Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
  • A missing top phase is unreported, not zero; its change is unavailable.

Frame and GPU times (ms)

Metric Baseline Candidate Change Change (%)
frame_ms.p50 51120.311 20800.970 -30319.341 -59.310
frame_ms.p90 51120.311 22384.503 -28735.808 -56.212
frame_ms.p99 51120.311 22384.503 -28735.808 -56.212
frame_ms.max 51120.311 22384.503 -28735.808 -56.212
mean_frame_ms 35560.878 18504.356 -17056.522 -47.964
gpu_busy_ms_per_present 2932.088 2671.504 -260.584 -8.887

Top phases (ms per frame)

Metric Baseline Candidate Change Change (%)
Driver.Draw 32238.044 13663.344 -18574.700 -57.617
Driver.Draw.draw_enqueued 17191.114 n/a n/a n/a
Driver.Draw.shader_compile_and_link n/a 9964.705 n/a n/a
Driver.Packet 172035.723 76363.516 -95672.207 -55.612
Driver.Packet.draw 32243.880 13667.353 -18576.527 -57.613
Driver.Packet.memory_wait 131970.044 54510.439 -77459.605 -58.695
Graphics.Draw 24491.688 7370.673 -17121.015 -69.905
Graphics.Draw.draw_and_resource_release 24075.473 7075.867 -16999.606 -70.610
Resources.Complete 16613.777 n/a n/a n/a
Shader.DrawStage n/a 9617.791 n/a n/a

An earlier, env-gated version of this stop (71f251195e) on the same stack gave 22 and 23 presents in 210-600 s with it, against 12 without.

AMD RDNA 4, run by @bunbeans2-arch (comment): Windows 11, RX 9070 XT, c81fda17d1 merged onto main f7f03daf52, 3 runs, Khronos validation layer loaded. 12 of the 13 recovery modes and the agc_driver_sampled_cache* tests pass 3 of 3, with no VUID- line. recover-storage-proved is skipped there as on the Windows VM, because Revalidate takes the full walk on Windows. Its StorageImagesCached stamp is covered by the Linux run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #12684 (stacked on its head ba0eaedff6). #6194 (Thunderhawkk) grows the storage cache's budget while it evicts under pressure, a different mechanism; it conflicts with main itself, so its textual overlap with this PR can't be checked yet. Whichever lands second rebases.
  • Fixes: none
  • Unblocks: none (PPSA02225 #4461's opening frame rate, see Tested)
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows VM), AMD Radeon RX 9070 XT (Windows, @bunbeans2-arch)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5065182509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12786). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-29T09:00:43Z. --- ### What #12684 lets the sampled texture cache grow past the device's share while a frame's textures don't fit. While the budget has that room, an out-of-memory recovery for an allocation with a host-memory fallback stops at the first sampled entry used in the last two presents. The recovery then goes on to the storage image cache and evicts its least recently used images, whatever their age. In Ghost of Tsushima Director's Cut (PPSA02225 02.024.000), those are the frame's own storage images. They're made again at their next use: 45,000 to 117,000 of them over 210-600 s of the opening, which is 86 to 103 s of storage image creation. ### How Storage cache entries now record the present of their last use: a hit, an insert, `StorageImageCached`, `StorageImagesCached` and `RepeatStorageSurface`. Under the same condition as the sampled stop (room past the device's share, and an allocation with a host-memory fallback), the recovery also stops at the first storage image used in the last two presents. The room is mirrored in an atomic, so the storage half can read it while the sampled cache is busy. The `[gpu] texture caches released` line says when the storage half stopped. USAGE.md and the debt entry for the room mention the storage stop. ### Tested **At this head `5bcf672fd1`** (oneandonlydean's [review](https://github.com/boykopovar/AnyPS5/pull/12786#issuecomment-6556586099) on `Context::DeviceMemoryType`): `ReclaimFallbackScope` moves to `Context.hpp`, built on a `SwapReclaimHostFallback` setter that `BufferPool.cpp` defines next to `ReclaimHasHostFallback`. `DeviceMemoryType` now opens the scope around its reclaim before a budget-full allocation goes to host memory (#13064), so the storage stop also applies there. A new recovery mode, `recover-storage-recent-type`, reports the device-local heap full when the new texture picks its memory type. It requires the current present's storage image to stay cached, the texture to go to host memory, and no device allocation to fail. - Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09): `ctest -R 'agc_driver_recover_|agc_device_memory_fallback'`, 15 tests, passes 3 of 3 at this head, the new mode included. - A full `cmake --build build` of every target passes at `8f9db9591e`, which differs from this head only in the new test's request-count check. - Windows 11 VM (GT 1030, WinLibs GCC 15.2.0, Release): `ctest -R 'agc_driver_recover_|agc_device_memory_fallback'`, 15 tests, passes 3 of 3 at this head. - **Red control:** `41391cc931` is this head with `Context.hpp` and `BufferPool.cpp` reverted, so only the new test remains. It fails `recover-storage-recent-type` 3 of 3 on the Windows VM: `while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present`. That is the reclaim through `DeviceMemoryType` evicting the image. **Earlier, at `08ae978210`** (oneandonlydean's review; [details](https://github.com/boykopovar/AnyPS5/pull/12786#issuecomment-6494081486)): `d13440dd05` takes the room the storage half uses from the sampled half's read under its lock. `08ae978210` adds four recovery modes: `storage-hit`, `storage-repeat` and `storage-proved`, which keep an image used in the current present through a cache hit, `RepeatStorageSurface` or a fast proof (`StorageImagesCached`), and `storage-aged`, which evicts an image left untouched for two presents. The 25 tests pass 3 of 3. A mutant dropping the present stamp at each of the three sites fails its mode. Khronos validation: 19 of 19 at `ba0eaedff6` and 25 of 25 here, no `VUID-` messages. Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09), at the first head `544cbf2044` (on #12684's head `ba0eaedff6`): - `ctest -R '^agc_driver_recover_|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_storage_cache|^agc_buffer_pool'`, 21 tests, passes in each of 3 runs. That includes the two new recovery modes: - `agc_driver_recover_storage-recent_allocation`: with room past the device's share and a host fallback, the recovery keeps a storage image used in the current present. - `agc_driver_recover_storage-recent-noroom_allocation`: with no room, it still evicts that image, as before. - Each mode fails without the piece it pins: - `814a4a79e7` (the storage stop removed) fails `storage-recent`: `while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present`. - `d48018c0d8` (the stop on any host fallback, room or not) fails `storage-recent-noroom`: `with no room past the device's share, sampled allocation recovery did not evict the storage image of the current present`. - **Validation layer** (Khronos `VK_LAYER_KHRONOS_validation`, LunarG SDK) on the same tests, at `ba0eaedff6` and at this head: 9 of 9 and 11 of 11 pass, the layer checked the Vulkan device each run creates, and there are no `VUID-` messages on either side. Windows 11 VM (GeForce GT 1030, WinLibs GCC, Release), the same regex: at this head 21 of 21 pass in each of 3 runs, and on the stack's base `main` `c9207624bc` 14 of 14 (the tests there). **Ghost of Tsushima Director's Cut** (PPSA02225 02.024.000), the opening, 600 s runs with pad input and warm caches, `APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_SECONDS=300:60`, alternating without and with the stop. As in #12684, plain `main` stops early in this title on `native multisample stencil or depth format import is not implemented` (#9717), so "without" is #12684's capture build `ee55f90649` (its local stack plus #12684's three commits), and "with" is `229a6c1473`, the same build plus this PR's commit (the same changed lines as `ba0eaedff6..544cbf2044`). Each run's trace, `aps5-summary.jsonl` lines, `trace_digest.py` output on the trace and on the summary file, and `performance_compare.py` output for both pairs are in the release [storage-recency-got-captures](https://github.com/milescoviello/AnyPS5/releases/tag/storage-recency-got-captures). | Run | Build | Presents in the interval lines from 195 s | Frame p50 in those intervals | Storage images made 210-600 s | Their creation | |---|---|---|---|---|---| | B1 | without | 15 | 15.2 to 81.9 s | 45,200 | 85.5 s | | S2 | with | 20 | 11.1 to 28.0 s | 11,900 | 57.5 s | | B3 | without | 12 | 14.1 to 70.5 s | 116,500 | 103.0 s | | S4 | with | 20 | 12.4 to 29.4 s | 12,850 | 64.4 s | - Over the run, the stop cuts the storage images made again by 74 and 89 %, and the longest frame interval from about 70-82 s to about 28-29 s. - **Window lines.** At these frame times, the 60 s trace window holds only 2 to 4 presents per run, so each comparison covers a few frames: B1 against S2 gives frame p50 -21.9 %, mean frame -17.0 % and GPU busy per present -14.8 %. B3 against S4 gives frame p50 -59.3 %, mean frame -48.0 % and GPU busy -8.9 %, with `Graphics.Draw.draw_and_resource_release` at -70.6 %. - The opening is still slow with the stop: the draw committer then limits presents (about 3.6 ms per commit in this scene), which is separate work. <details><summary>Window summary lines (<code>aps5-summary.jsonl</code>): B1 and B3 without, S2 and S4 with</summary> ```json {"commit":"ee55f9064948","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1151,"ms":72514.499},"presents":3,"frame_ms":{"p50":23861.123,"p90":24912.245,"p99":24912.245,"max":24912.245},"gpu_busy_ms_per_present":3963.606,"worker_busy_pct":{"queue worker 0x0":99.339,"queue worker 0x40":0.069,"queue worker 0x20":66.090,"queue worker 0x48":1.033,"queue worker 0x38":77.115,"queue worker 0x52":35.796,"queue worker 0x30":76.175,"queue worker 0x50":63.683,"queue worker 0x51":1.893},"top_phases_ms_per_frame":{"Driver.Packet":101008.254,"Driver.Packet.memory_wait":73715.714,"Driver.Packet.draw":18356.739,"Driver.Draw":18351.048,"Driver.Draw.shader_compile_and_link":13522.567,"Shader.DrawStage":12956.276,"Graphics.Draw":12011.301,"Graphics.Draw.draw_and_resource_release":11619.511},"trace_dropped":false,"trace":"aps5-trace-ee55f9064948-3.json.gz"} {"commit":"229a6c147325","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1152,"ms":60167.721},"presents":3,"frame_ms":{"p50":18627.681,"p90":28032.414,"p99":28032.414,"max":28032.414},"gpu_busy_ms_per_present":3376.483,"worker_busy_pct":{"queue worker 0x0":97.536,"queue worker 0x40":0.059,"queue worker 0x20":65.260,"queue worker 0x48":3.038,"queue worker 0x38":82.889,"queue worker 0x52":36.618,"queue worker 0x30":81.748,"queue worker 0x50":58.986,"queue worker 0x51":2.044},"top_phases_ms_per_frame":{"Driver.Packet":85847.134,"Driver.Packet.memory_wait":63103.959,"Driver.Packet.draw":15432.876,"Driver.Draw":15427.807,"Driver.Draw.shader_compile_and_link":12049.275,"Shader.DrawStage":11545.091,"Shader.DrawStage.capture_resources":7798.279,"Graphics.Draw":6953.492},"trace_dropped":false,"trace":"aps5-trace-229a6c147325-3.json.gz"} {"commit":"ee55f9064948","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1126,"ms":71121.755},"presents":2,"frame_ms":{"p50":51120.311,"p90":51120.311,"p99":51120.311,"max":51120.311},"gpu_busy_ms_per_present":2932.088,"worker_busy_pct":{"queue worker 0x0":99.746,"queue worker 0x40":0.045,"queue worker 0x20":87.721,"queue worker 0x48":3.150,"queue worker 0x38":96.461,"queue worker 0x52":19.588,"queue worker 0x30":95.700,"queue worker 0x50":79.817,"queue worker 0x51":1.852},"top_phases_ms_per_frame":{"Driver.Packet":172035.723,"Driver.Packet.memory_wait":131970.044,"Driver.Packet.draw":32243.880,"Driver.Draw":32238.044,"Graphics.Draw":24491.688,"Graphics.Draw.draw_and_resource_release":24075.473,"Driver.Draw.draw_enqueued":17191.114,"Resources.Complete":16613.777},"trace_dropped":false,"trace":"aps5-trace-ee55f9064948-3.json.gz"} {"commit":"229a6c147325","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1137,"ms":74017.422},"presents":4,"frame_ms":{"p50":20800.970,"p90":22384.503,"p99":22384.503,"max":22384.503},"gpu_busy_ms_per_present":2671.504,"worker_busy_pct":{"queue worker 0x0":97.978,"queue worker 0x40":0.053,"queue worker 0x20":60.007,"queue worker 0x48":5.537,"queue worker 0x38":77.558,"queue worker 0x52":38.180,"queue worker 0x30":76.856,"queue worker 0x50":55.189,"queue worker 0x51":1.528},"top_phases_ms_per_frame":{"Driver.Packet":76363.516,"Driver.Packet.memory_wait":54510.439,"Driver.Packet.draw":13667.353,"Driver.Draw":13663.344,"Driver.Draw.shader_compile_and_link":9964.705,"Shader.DrawStage":9617.791,"Graphics.Draw":7370.673,"Graphics.Draw.draw_and_resource_release":7075.867},"trace_dropped":false,"trace":"aps5-trace-229a6c147325-3.json.gz"} ``` </details> <details><summary><code>performance_compare.py</code>, B3 (baseline) against S4 (candidate)</summary> # Performance comparison | Capture | Commit | Trace | Presents | Window (ms) | | --- | --- | --- | ---: | ---: | | baseline | ee55f9064948 | aps5-trace-ee55f9064948-3.json.gz | 2 | 71121.755 | | candidate | 229a6c147325 | aps5-trace-229a6c147325-3.json.gz | 4 | 74017.422 | - Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene. - Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval. - A missing top phase is unreported, not zero; its change is unavailable. ## Frame and GPU times (ms) | Metric | Baseline | Candidate | Change | Change (%) | | --- | ---: | ---: | ---: | ---: | | frame_ms.p50 | 51120.311 | 20800.970 | -30319.341 | -59.310 | | frame_ms.p90 | 51120.311 | 22384.503 | -28735.808 | -56.212 | | frame_ms.p99 | 51120.311 | 22384.503 | -28735.808 | -56.212 | | frame_ms.max | 51120.311 | 22384.503 | -28735.808 | -56.212 | | mean_frame_ms | 35560.878 | 18504.356 | -17056.522 | -47.964 | | gpu_busy_ms_per_present | 2932.088 | 2671.504 | -260.584 | -8.887 | ## Top phases (ms per frame) | Metric | Baseline | Candidate | Change | Change (%) | | --- | ---: | ---: | ---: | ---: | | Driver.Draw | 32238.044 | 13663.344 | -18574.700 | -57.617 | | Driver.Draw.draw_enqueued | 17191.114 | n/a | n/a | n/a | | Driver.Draw.shader_compile_and_link | n/a | 9964.705 | n/a | n/a | | Driver.Packet | 172035.723 | 76363.516 | -95672.207 | -55.612 | | Driver.Packet.draw | 32243.880 | 13667.353 | -18576.527 | -57.613 | | Driver.Packet.memory_wait | 131970.044 | 54510.439 | -77459.605 | -58.695 | | Graphics.Draw | 24491.688 | 7370.673 | -17121.015 | -69.905 | | Graphics.Draw.draw_and_resource_release | 24075.473 | 7075.867 | -16999.606 | -70.610 | | Resources.Complete | 16613.777 | n/a | n/a | n/a | | Shader.DrawStage | n/a | 9617.791 | n/a | n/a | </details> An earlier, env-gated version of this stop (`71f251195e`) on the same stack gave 22 and 23 presents in 210-600 s with it, against 12 without. AMD RDNA 4, run by @bunbeans2-arch ([comment](https://github.com/boykopovar/AnyPS5/pull/12786#issuecomment-6521051183)): Windows 11, RX 9070 XT, `c81fda17d1` merged onto `main` `f7f03daf52`, 3 runs, Khronos validation layer loaded. 12 of the 13 recovery modes and the `agc_driver_sampled_cache*` tests pass 3 of 3, with no `VUID-` line. `recover-storage-proved` is skipped there as on the Windows VM, because `Revalidate` takes the full walk on Windows. Its `StorageImagesCached` stamp is covered by the Linux run. ### 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: #12684 (stacked on its head `ba0eaedff6`). #6194 (Thunderhawkk) grows the storage cache's budget while it evicts under pressure, a different mechanism; it conflicts with `main` itself, so its textual overlap with this PR can't be checked yet. Whichever lands second rebases. - [x] Fixes: none - [x] Unblocks: none (PPSA02225 #4461's opening frame rate, see Tested) - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows VM), AMD Radeon RX 9070 XT (Windows, @bunbeans2-arch) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
XairRrR commented 2026-10-29 11:10:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T11:10:47Z.

Review: APPROVED


Reviewed — approved

The storage stop matches the sampled stop's condition and records the present at every place that moves a storage entry to the front of the cache. The 25 focused tests pass with Khronos validation and no VUID- messages, and the four new "keep" modes fail when this PR's production change is reverted.

What I ran

  • PR head: c81fda17d1bb6aad9fc008f7f1848b6d874a7078 (stacked on #12684's head ba0eaedff633434f93e03d39a19913ee4b799edd)
  • main: ba5b5330b37724bca4b99f30faab504653635a04, merged with the head into bc0f5bb2a1. The main baseline below ran at the same commit.
  • The head was amended during the review, from 08ae978210 to c81fda17d1. The amend changes only SampledCacheBudget.cpp: recover-storage-proved now skips instead of failing when the descriptor set does not take the fast proof. I repeated the merge, the checks, the full build, the focused tests with validation, the main baseline and the negative control at c81fda17d1. The two extra mutants further down ran at 08ae978210, whose production code is identical.
  • Machine: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release build with Ninja and BUILD_TESTING=ON, run in a clean worktree.
git fetch -q origin main pull/12786/head:refs/review/12786
git checkout -q --detach origin/main
git merge -q --no-ff --no-edit refs/review/12786
git diff --check origin/main...refs/review/12786
python3 tools/check_conventions.py --base origin/main
nice -n 10 cmake --build build -j10 --target agc_driver_sampled_cache_budget_tests libs
nice -n 10 cmake --build build -j10
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  nice -n 10 ctest --test-dir build -j4 -V --output-on-failure \
  -R '^agc_driver_recover_|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_storage_cache|^agc_buffer_pool'
# then the same build and ctest on origin/main (ba5b5330b3)

# negative control: reverse-apply only this PR's ShaderResources.cpp change
git diff ba0eaedff6 c81fda17d1 -- core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp | git apply -R
nice -n 10 cmake --build build -j10 --target agc_driver_sampled_cache_budget_tests
ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_storage-' -j4 --output-on-failure

# mutants, at 08ae978210: keepRecent = false in place of the atomic read at ShaderResources.cpp:1478
ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_|^agc_driver_sampled_cache|^agc_sampled_cache' -j4 --output-on-failure

# mutant: it->present >= present in place of it->present + 1u >= present at ShaderResources.cpp:1532
ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_' -j4 --output-on-failure

Results

Check Result
Merge onto main Clean (auto-merged CMakeLists.txt, the debt file and USAGE.md)
git diff --check Clean
tools/check_conventions.py --base origin/main All conventions checks passed.
Build: full tree plus libs (merged) Passed
Focused tests, merged tree, with validation 25 of 25 passed in 7.6 s, none slower than 5 s; recover-storage-proved ran (it took the fast proof here, it was not skipped)
Same tests on main, with validation 14 of 14 passed
VUID- lines 0 on the merged tree, 0 on main
was not found but was requested by env var VK_INSTANCE_LAYERS Absent from both logs
Validation layer loaded Device layer insertion logged in each of the six new tests (agc_driver_recover_storage-*) and on main
Negative control (this PR's production change reverted) 4 of the 6 new tests fail, as expected (see below)
Capture assets linked in the description The release exists and holds the 4 traces, the trace_digest.py outputs and both performance_compare.py outputs
Merged tree, new tests
 4/25 Test #1664: agc_driver_recover_storage-hit_allocation ...........................   Passed    1.30 sec
 5/25 Test #1665: agc_driver_recover_storage-repeat_allocation ........................   Passed    1.30 sec
 8/25 Test #1661: agc_driver_recover_storage-recent_allocation ........................   Passed    1.30 sec
 9/25 Test #1663: agc_driver_recover_storage-aged_allocation ..........................   Passed    1.30 sec
10/25 Test #1662: agc_driver_recover_storage-recent-noroom_allocation .................   Passed    1.34 sec
17/25 Test #1666: agc_driver_recover_storage-proved_allocation ........................   Passed    1.57 sec
1666: [gpu] texture caches released 0 MiB of the 256 MiB asked for: 0 sampled entries (cache busy, skipped), 0 storage images (stopped at one used in the last two presents; 1 such releases), 0 with pending results kept
1666: storage used through a fast proof image allocation recovered after 1 injected failures: 0 bytes released
100% tests passed out of 25

Negative control

The tests depend on #12684's API (SetSampledSpillForTest, the room), so restoring production files from main would only break the build. Instead I reverse-applied this PR's own ShaderResources.cpp diff (ba0eaedff6..c81fda17d1) on the merged tree, rebuilt and ran the six new tests. The modes that check old behaviour still pass (storage-recent-noroom, storage-aged). The four modes that check the stop fail with their messages:

Output
1/6 Test #1661: agc_driver_recover_storage-recent_allocation ..........***Failed    1.64 sec
AGC graphics: while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present
2/6 Test #1665: agc_driver_recover_storage-repeat_allocation ..........***Failed    1.68 sec
AGC graphics: the recovery evicted a storage image used in the current present through RepeatStorageSurface, while the sampled cache had room past the device's share
3/6 Test #1664: agc_driver_recover_storage-hit_allocation .............***Failed    1.68 sec
AGC graphics: the recovery evicted a storage image used in the current present through a storage cache hit, while the sampled cache had room past the device's share
4/6 Test #1662: agc_driver_recover_storage-recent-noroom_allocation ...   Passed    1.68 sec
5/6 Test #1663: agc_driver_recover_storage-aged_allocation ............   Passed    1.38 sec
6/6 Test #1666: agc_driver_recover_storage-proved_allocation ..........***Failed    1.38 sec
AGC graphics: the recovery evicted a storage image used in the current present through a fast proof of a descriptor set over it, while the sampled cache had room past the device's share
33% tests passed, 4 tests failed out of 6

I also ran two mutants that the description does not cover. The first replaces the atomic read at the top of ReleaseTextureCaches (ShaderResources.cpp:1478) with false. Only agc_driver_recover_storage-proved_allocation fails, and its recovery logs 0 sampled entries (cache busy, skipped). So the fallback to sampledRoom when the sampled half is skipped is covered, but only through the proved fixture (see the second non-blocking finding). The second, which narrows the window, is described in the third non-blocking finding.

Findings

Blocking

None.

I checked these points in the code:

  • All four storage-cache splice sites and the insert stamp present under the storage cache mutex: cachedStorageTexture hit and insert, StorageImageCached, StorageImagesCached and RepeatStorageSurface. No other site moves a storage entry to the front, so the LRU-order break at ShaderResources.cpp:1532-1535 cannot skip past an older entry that sits behind a recent one.
  • The storage stop uses the same present != 0 && it->present + 1u >= present window and the same hostFallback && room condition as the sampled stop.
  • oneandonlydean's three points are addressed at this head. Point 3 is resolved: when the sampled half runs, keepRecent is recomputed from cache.spill under the sampled lock (ShaderResources.cpp:1487). Point 1 is confirmed by the negative control above.

Non-blocking

  1. An unrelated wording change in #12684's debt entry. The "Sampled texture cache room" entry (docs/dev/debt/libSceAgcDriver.md:91 at the PR head, line 96 after the merge) adds the storage stop. It also changes "(an APU's GTT heap under RADV) is the title's own system memory" to "(an APU's GTT heap) is the title's own memory". That sentence is #12684's, and the change drops the driver it was observed on. Suggest leaving that sentence as #12684 has it, or making the change in #12684.
  2. The atomic-room path is covered only incidentally. The first mutant above shows that recover-storage-proved passes only because the sampled half is skipped there and the storage half reads sampledRoom. If a later change made the sampled half run in that fixture, the atomic path would lose its only test without any test failing. Suggest a dedicated mode that holds the sampled cache busy (or uses the inherited, non-newImage path) with room set, and asserts that the storage image is kept and that the log line says cache busy, skipped.
  3. The boundary of the two-present window is not pinned for storage. storage-aged ages the entry by two presents and expects it evicted. The "keep" modes touch it in the current present. Nothing checks an entry last used exactly one present earlier, which it->present + 1u >= present keeps. I narrowed the check at ShaderResources.cpp:1532 to it->present >= present (current present only), and all 13 agc_driver_recover_* tests still passed. A variant of storage-aged that ages the entry by one present and expects the image to stay would pin the window.
  4. The new skip in recover-storage-proved can hide the StorageImagesCached stamp. At SampledCacheBudget.cpp:1291-1295, the mode returns VulkanTestSkipped when the second Revalidate takes the full walk. On a host where that happens, nothing tests the stamp in StorageImagesCached, and ctest reports a skip, not a failure. Here it took the fast proof and ran. If the fast proof depends only on the fixture (the write-watched surface) and not on the device, a Require would keep the stamp tested everywhere. If it does depend on the device, the skip is fine, but the description should say on which devices the mode skips.
  5. Checklist: GPUs tested. The template asks for vendor, model, driver and OS. The line has NVIDIA GeForce RTX 4070 Ti (Linux) but no driver, and it omits the GeForce GT 1030 (Windows 11 VM) named in Tested. The details are in the Tested section, so this only affects the checklist line.
  6. Perf baseline is not main. AGENTS.md and the bot's comment ask for a main capture. The description explains that main stops early in PPSA02225 on an unimplemented native multisample stencil or depth import, and the baseline ee55f90649 differs from the candidate 229a6c1473 only by this PR's commit, so the comparison isolates the change. The baseline also contains an unpublished local stack, though, so nobody else can rebuild it. Naming the commits in that stack, or pushing the baseline branch next to the release, would make the captures reproducible.

Not verified

  • No title was run, so the Ghost of Tsushima figures (storage images re-created, frame intervals, host placements) were not reproduced. I only confirmed that the linked release holds the captures and digests.
  • Windows, AMD and Intel GPUs, and integrated GPUs, were not tested here. On an integrated GPU the room stays 0, so the stop should never trigger; that follows from #12684's ceiling and I did not run it.
  • The APS5_DRAW_PIPELINE gap the author describes (an epoch-shortcut proof that does not stamp storage images) was not exercised.
  • Each test ran once per tree, not three times.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5696738407 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12786#pullrequestreview-5696738407). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T11:10:47Z. **Review:** APPROVED --- # Reviewed — approved The storage stop matches the sampled stop's condition and records the present at every place that moves a storage entry to the front of the cache. The 25 focused tests pass with Khronos validation and no `VUID-` messages, and the four new "keep" modes fail when this PR's production change is reverted. ## What I ran - PR head: `c81fda17d1bb6aad9fc008f7f1848b6d874a7078` (stacked on #12684's head `ba0eaedff633434f93e03d39a19913ee4b799edd`) - `main`: `ba5b5330b37724bca4b99f30faab504653635a04`, merged with the head into `bc0f5bb2a1`. The `main` baseline below ran at the same commit. - The head was amended during the review, from `08ae978210` to `c81fda17d1`. The amend changes only `SampledCacheBudget.cpp`: `recover-storage-proved` now skips instead of failing when the descriptor set does not take the fast proof. I repeated the merge, the checks, the full build, the focused tests with validation, the `main` baseline and the negative control at `c81fda17d1`. The two extra mutants further down ran at `08ae978210`, whose production code is identical. - Machine: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), Release build with Ninja and BUILD_TESTING=ON, run in a clean worktree. ```sh git fetch -q origin main pull/12786/head:refs/review/12786 git checkout -q --detach origin/main git merge -q --no-ff --no-edit refs/review/12786 git diff --check origin/main...refs/review/12786 python3 tools/check_conventions.py --base origin/main nice -n 10 cmake --build build -j10 --target agc_driver_sampled_cache_budget_tests libs nice -n 10 cmake --build build -j10 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ nice -n 10 ctest --test-dir build -j4 -V --output-on-failure \ -R '^agc_driver_recover_|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_storage_cache|^agc_buffer_pool' # then the same build and ctest on origin/main (ba5b5330b3) # negative control: reverse-apply only this PR's ShaderResources.cpp change git diff ba0eaedff6 c81fda17d1 -- core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp | git apply -R nice -n 10 cmake --build build -j10 --target agc_driver_sampled_cache_budget_tests ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_storage-' -j4 --output-on-failure # mutants, at 08ae978210: keepRecent = false in place of the atomic read at ShaderResources.cpp:1478 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_|^agc_driver_sampled_cache|^agc_sampled_cache' -j4 --output-on-failure # mutant: it->present >= present in place of it->present + 1u >= present at ShaderResources.cpp:1532 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 nice -n 10 ctest --test-dir build -R '^agc_driver_recover_' -j4 --output-on-failure ``` ## Results | Check | Result | |---|---| | Merge onto `main` | Clean (auto-merged `CMakeLists.txt`, the debt file and `USAGE.md`) | | `git diff --check` | Clean | | `tools/check_conventions.py --base origin/main` | `All conventions checks passed.` | | Build: full tree plus `libs` (merged) | Passed | | Focused tests, merged tree, with validation | 25 of 25 passed in 7.6 s, none slower than 5 s; `recover-storage-proved` ran (it took the fast proof here, it was not skipped) | | Same tests on `main`, with validation | 14 of 14 passed | | `VUID-` lines | 0 on the merged tree, 0 on `main` | | `was not found but was requested by env var VK_INSTANCE_LAYERS` | Absent from both logs | | Validation layer loaded | Device layer insertion logged in each of the six new tests (`agc_driver_recover_storage-*`) and on `main` | | Negative control (this PR's production change reverted) | 4 of the 6 new tests fail, as expected (see below) | | Capture assets linked in the description | The release exists and holds the 4 traces, the `trace_digest.py` outputs and both `performance_compare.py` outputs | <details><summary>Merged tree, new tests</summary> ``` 4/25 Test #1664: agc_driver_recover_storage-hit_allocation ........................... Passed 1.30 sec 5/25 Test #1665: agc_driver_recover_storage-repeat_allocation ........................ Passed 1.30 sec 8/25 Test #1661: agc_driver_recover_storage-recent_allocation ........................ Passed 1.30 sec 9/25 Test #1663: agc_driver_recover_storage-aged_allocation .......................... Passed 1.30 sec 10/25 Test #1662: agc_driver_recover_storage-recent-noroom_allocation ................. Passed 1.34 sec 17/25 Test #1666: agc_driver_recover_storage-proved_allocation ........................ Passed 1.57 sec 1666: [gpu] texture caches released 0 MiB of the 256 MiB asked for: 0 sampled entries (cache busy, skipped), 0 storage images (stopped at one used in the last two presents; 1 such releases), 0 with pending results kept 1666: storage used through a fast proof image allocation recovered after 1 injected failures: 0 bytes released 100% tests passed out of 25 ``` </details> ## Negative control The tests depend on #12684's API (`SetSampledSpillForTest`, the room), so restoring production files from `main` would only break the build. Instead I reverse-applied this PR's own `ShaderResources.cpp` diff (`ba0eaedff6..c81fda17d1`) on the merged tree, rebuilt and ran the six new tests. The modes that check old behaviour still pass (`storage-recent-noroom`, `storage-aged`). The four modes that check the stop fail with their messages: <details><summary>Output</summary> ``` 1/6 Test #1661: agc_driver_recover_storage-recent_allocation ..........***Failed 1.64 sec AGC graphics: while the sampled cache was past the device's share, an allocation that could go to host memory evicted a storage image of the current present 2/6 Test #1665: agc_driver_recover_storage-repeat_allocation ..........***Failed 1.68 sec AGC graphics: the recovery evicted a storage image used in the current present through RepeatStorageSurface, while the sampled cache had room past the device's share 3/6 Test #1664: agc_driver_recover_storage-hit_allocation .............***Failed 1.68 sec AGC graphics: the recovery evicted a storage image used in the current present through a storage cache hit, while the sampled cache had room past the device's share 4/6 Test #1662: agc_driver_recover_storage-recent-noroom_allocation ... Passed 1.68 sec 5/6 Test #1663: agc_driver_recover_storage-aged_allocation ............ Passed 1.38 sec 6/6 Test #1666: agc_driver_recover_storage-proved_allocation ..........***Failed 1.38 sec AGC graphics: the recovery evicted a storage image used in the current present through a fast proof of a descriptor set over it, while the sampled cache had room past the device's share 33% tests passed, 4 tests failed out of 6 ``` </details> I also ran two mutants that the description does not cover. The first replaces the atomic read at the top of `ReleaseTextureCaches` ([ShaderResources.cpp:1478](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L1478-L1478)) with `false`. Only `agc_driver_recover_storage-proved_allocation` fails, and its recovery logs `0 sampled entries (cache busy, skipped)`. So the fallback to `sampledRoom` when the sampled half is skipped is covered, but only through the proved fixture (see the second non-blocking finding). The second, which narrows the window, is described in the third non-blocking finding. ## Findings ### Blocking None. I checked these points in the code: - All four storage-cache `splice` sites and the insert stamp `present` under the storage cache mutex: `cachedStorageTexture` hit and insert, `StorageImageCached`, `StorageImagesCached` and `RepeatStorageSurface`. No other site moves a storage entry to the front, so the LRU-order `break` at [ShaderResources.cpp:1532-1535](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L1532-L1535) cannot skip past an older entry that sits behind a recent one. - The storage stop uses the same `present != 0 && it->present + 1u >= present` window and the same `hostFallback && room` condition as the sampled stop. - oneandonlydean's three points are addressed at this head. Point 3 is resolved: when the sampled half runs, `keepRecent` is recomputed from `cache.spill` under the sampled lock ([ShaderResources.cpp:1487](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L1487-L1487)). Point 1 is confirmed by the negative control above. ### Non-blocking 1. **An unrelated wording change in #12684's debt entry.** The "Sampled texture cache room" entry ([docs/dev/debt/libSceAgcDriver.md:91](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/docs/dev/debt/libSceAgcDriver.md#L91-L91) at the PR head, line 96 after the merge) adds the storage stop. It also changes "(an APU's GTT heap under RADV) is the title's own system memory" to "(an APU's GTT heap) is the title's own memory". That sentence is #12684's, and the change drops the driver it was observed on. Suggest leaving that sentence as #12684 has it, or making the change in #12684. 2. **The atomic-room path is covered only incidentally.** The first mutant above shows that `recover-storage-proved` passes only because the sampled half is skipped there and the storage half reads `sampledRoom`. If a later change made the sampled half run in that fixture, the atomic path would lose its only test without any test failing. Suggest a dedicated mode that holds the sampled cache busy (or uses the inherited, non-`newImage` path) with room set, and asserts that the storage image is kept and that the log line says `cache busy, skipped`. 3. **The boundary of the two-present window is not pinned for storage.** `storage-aged` ages the entry by two presents and expects it evicted. The "keep" modes touch it in the current present. Nothing checks an entry last used exactly one present earlier, which `it->present + 1u >= present` keeps. I narrowed the check at [ShaderResources.cpp:1532](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L1532-L1532) to `it->present >= present` (current present only), and all 13 `agc_driver_recover_*` tests still passed. A variant of `storage-aged` that ages the entry by one present and expects the image to stay would pin the window. 4. **The new skip in `recover-storage-proved` can hide the `StorageImagesCached` stamp.** At [SampledCacheBudget.cpp:1291-1295](https://github.com/boykopovar/AnyPS5/blob/c81fda17d1bb6aad9fc008f7f1848b6d874a7078/core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp#L1291-L1295), the mode returns `VulkanTestSkipped` when the second `Revalidate` takes the full walk. On a host where that happens, nothing tests the stamp in `StorageImagesCached`, and ctest reports a skip, not a failure. Here it took the fast proof and ran. If the fast proof depends only on the fixture (the write-watched surface) and not on the device, a `Require` would keep the stamp tested everywhere. If it does depend on the device, the skip is fine, but the description should say on which devices the mode skips. 5. **Checklist: GPUs tested.** The template asks for vendor, model, driver and OS. The line has `NVIDIA GeForce RTX 4070 Ti (Linux)` but no driver, and it omits the GeForce GT 1030 (Windows 11 VM) named in Tested. The details are in the Tested section, so this only affects the checklist line. 6. **Perf baseline is not `main`.** AGENTS.md and the bot's comment ask for a `main` capture. The description explains that `main` stops early in PPSA02225 on an unimplemented native multisample stencil or depth import, and the baseline `ee55f90649` differs from the candidate `229a6c1473` only by this PR's commit, so the comparison isolates the change. The baseline also contains an unpublished local stack, though, so nobody else can rebuild it. Naming the commits in that stack, or pushing the baseline branch next to the release, would make the captures reproducible. ## Not verified - No title was run, so the Ghost of Tsushima figures (storage images re-created, frame intervals, host placements) were not reproduced. I only confirmed that the linked release holds the captures and digests. - Windows, AMD and Intel GPUs, and integrated GPUs, were not tested here. On an integrated GPU the room stays 0, so the stop should never trigger; that follows from #12684's ceiling and I did not run it. - The `APS5_DRAW_PIPELINE` gap the author describes (an epoch-shortcut proof that does not stamp storage images) was not exercised. - Each test ran once per tree, not three times.

Pull request closed

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!12786
No description provided.