fix(agc): flush depth planes only over the layers an array target's lookup refreshes #9443

Merged
janzezno merged 1 commit from upstream-pr/9443 into main 2026-10-24 14:59:50 +00:00
janzezno commented 2026-10-21 22:20:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-21T22:20:00Z.


What

Pulse (PPSA99993, ps5-opengl) runs its title menu at 17 FPS on main, with the GPU busy 41 ms per frame on a scene that needs under 1 ms. Every color draw stores the game's depth plane to guest memory and waits for it.

The cause is the leftover half of the phantom-slice problem from #6189. ps5-opengl declares each color target as a 2-slice array and only renders slice 0, and Pulse's depth buffer sits in the memory of the unused slice 1 (color target 0x255600000, depth plane 0x256600000, 16 MiB apart, each slice 8.4 MiB). #6202, carried by #6718, made the target's lookup refresh only the layers the draw uses, which removed the per-draw whole-image uploads. But cachedStorageTexture still runs FlushDepthPlanes over the whole declared array before the lookup. That line came in with #7154 (@DavidSamir bisected the regression to its merge 50e0624d7 in this comment). So each draw into slice 0 stores the depth plane over slice 1, which the previous draw left stale on the GPU, then syncs on that store. On main 0c6a5bd593, 59,819 [flush] image 0x256600000+0x870000 for depth plane store lines were logged in 35 s, one per draw. A 6 s perf profile (taken on that main with #9402, which does not touch this path) had a third of the process's CPU samples under FlushDepthPlanes called from CachedStorageLayers.

With this change, a layered lookup (CachedStorageLayers) no longer flushes over the whole array in cachedStorageTexture. RefreshLayers flushes the depth planes itself, before anything can return early:

  • On the scoped path, it flushes over the tracked layers it is about to refresh, before refresh(first, last). That has to come first: refresh() returns early when its refresh proof holds, and the proof only looks at guest memory, which a depth plane the GPU just wrote has not changed yet.
  • Every fallback to a full Refresh() flushes the whole image's depth planes first. That covers the same proof shortcut, and a full refresh that hands over DCC clear keys, which skips FlushPending.
  • A new cache entry already flushes the whole range in FlushPending(..., "storage image creation").

Lookups without layers, written lookups and APS5_NO_TEXTURE_CACHE keep the whole-range flush.

agc_driver_depth_plane_partial_store gains a case: a cached 3-layer array image with a GPU-written depth plane over its second layer, looked up with the GPU mutex held as the draw path does. Where guest memory is write-watched, repeated lookups first take a refresh proof (the test requires one), so the lookups after the depth write go through that shortcut.

  • A lookup of layer 0 must store nothing and leave the plane stale. On main this fails with a lookup of the first layer of an array stored the depth plane over its second layer.
  • A scoped lookup of layers 0 and 1 must store the plane. Without the flush before refresh(), this fails under the refresh proof with a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer.
  • A lookup of all three layers, which takes the full-refresh fallback, must store it as well.

The lookup imports the array. Where the host import probe finds that imports lose their write protection (RADV, and lavapipe as @jotitadev found), imported ranges are compared instead of watched, so the refresh-proof half is skipped there; only drivers that keep imports watched (NVIDIA) would run it. So the same test is also registered as agc_driver_depth_plane_partial_store_unimported, with APS5_NO_HOST_IMPORT=1, as agc_driver_array_layer_target_cpu is. Without host imports the guest memory stays in the write watch on any driver, so both write-watched cases run there. Forcing APS5_WRITE_WATCH_IMPORTS=watch instead would not be sound on those drivers, since a GPU read clears the protection.

Overlap: pr_overlap on 1e20650e84 reports no pull request it could compare. #6743 adds a test registration next to agc_driver_array_layer_target_cpu; the new registration sits before that block, so the two do not touch. Of the 80 pull requests it could not compare, two change these functions: #6202, whose change is already on main through #6718, and #6194, which counts evictions in the eviction loop of cachedStorageTexture, away from the flush line this change edits.

Tested

Arch Linux, AMD Radeon RX 7900 GRE (RADV NAVI31, Mesa 26.2.5), Ryzen 5 7500F, Release, on main 1e20650e84.

Pulse PPSA99993 (homebrew catalog, sha256 9103d3d6…), title menu, no input, run with tools/title_run.py from #7264, trace window seconds 15–25 after the first present (APS5_TRACE_SECONDS=15:10):

main this PR
FPS, 3 runs of 60 s 17.2 / 17.2 / 17.2 59.9 / 59.9 / 59.9 (vsync)
presents in the 10 s window 172 600
frame p50 / p99 58.3 / 60.0 ms 16.7 / 16.7 ms
GPU busy per present 41.2 ms 0.6 ms
queue worker busy 97.7 % 20.2 %

Summary lines:

{"commit":"1e20650e8458","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":259,"ms":10036.713},"presents":172,"frame_ms":{"p50":58.269,"p90":59.077,"p99":60.018,"max":64.043},"gpu_busy_ms_per_present":41.178,"worker_busy_pct":{"queue worker 0x0":97.741},"top_phases_ms_per_frame":{"Driver.Packet":55.152,"Graphics.Draw":54.382,"Graphics.Draw.draw_and_resource_release":54.188,"Driver.Packet.draw":50.193,"Driver.Draw":50.164,"Driver.Draw.draw_enqueued":49.547,"Recorder.Sync":47.374,"Recorder.Submit":2.229},"trace_dropped":false,"trace":"aps5-trace-1e20650e8458-220371.json.gz"}
{"commit":"26f67793623d","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":900,"ms":10009.995},"presents":600,"frame_ms":{"p50":16.683,"p90":16.687,"p99":16.713,"max":16.861},"gpu_busy_ms_per_present":0.571,"worker_busy_pct":{"queue worker 0x0":20.201},"top_phases_ms_per_frame":{"VideoOut.Flip":15.801,"VideoOut.Flip.vblank_wait":15.372,"Driver.Packet":2.487,"Graphics.Draw":1.662,"Graphics.Draw.draw_and_resource_release":1.597,"Recorder.Sync":1.195,"Driver.Packet.draw":1.12,"Driver.Draw":1.101},"trace_dropped":false,"trace":"aps5-trace-26f67793623d-252043.json.gz"}

tools/trace_digest.py of both traces (attached):

main

seconds 15:10 from present 259: 172 presents, frame p50 58.3 / p90 59.1 / p99 60.0 / max 64.0 ms, GPU busy 41.2 ms per present
AMD Radeon RX 7900 GRE (RADV NAVI31), radv Mesa 26.2.5-arch1.1, Linux 7.2.11-arch1-1, 1920x1080, commit 1e20650e84, dropped: no

{"commit":"1e20650e8458","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":259,"ms":10036.713},"presents":172,"frame_ms":{"p50":58.269,"p90":59.077,"p99":60.018,"max":64.043},"gpu_busy_ms_per_present":41.178,"worker_busy_pct":{"queue worker 0x0":97.741},"top_phases_ms_per_frame":{"Driver.Packet":55.152,"Graphics.Draw":54.382,"Graphics.Draw.draw_and_resource_release":54.188,"Driver.Packet.draw":50.193,"Driver.Draw":50.164,"Driver.Draw.draw_enqueued":49.547,"Recorder.Sync":47.374,"Recorder.Submit":2.229},"trace_dropped":false,"trace":"aps5-trace-1e20650e8458-220371.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 350: 64.0 ms at 5299 ms: Graphics.Draw (draw committer) 59.8, Driver.Packet (queue worker 0x0) 59.8, Graphics.Draw.draw_and_resource_release (draw committer) 59.6, Driver.Packet.draw (queue worker 0x0) 54.8
  • present 344: 60.0 ms at 4950 ms: Graphics.Draw (draw committer) 56.0, Driver.Packet (queue worker 0x0) 55.9, Graphics.Draw.draw_and_resource_release (draw committer) 55.8, Driver.Packet.draw (queue worker 0x0) 51.3
  • present 422: 59.9 ms at 9511 ms: Graphics.Draw (draw committer) 55.8, Driver.Packet (queue worker 0x0) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.6, Driver.Packet.draw (queue worker 0x0) 51.2
  • present 413: 59.8 ms at 8981 ms: Graphics.Draw (draw committer) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.5, Driver.Packet (queue worker 0x0) 55.4, Driver.Packet.draw (queue worker 0x0) 50.9
  • present 406: 59.7 ms at 8571 ms: Graphics.Draw (draw committer) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.5, Driver.Packet (queue worker 0x0) 55.4, Driver.Packet.draw (queue worker 0x0) 50.9

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 56.4 (97 %) 1.2 (2 %) 0.8 2.0 Driver.Packet 54.5, Driver.EndSubmission 1.9
draw committer 56.2 (96 %) 0.0 (0 %) 2.2 1.7 Graphics.Draw 54.4, Recorder.Sync 1.8
presenter 0.1 (0 %) 0.0 (0 %) 58.2 0.1 VideoOut.Flip 0.2
gpu 41.2 (71 %) 0.0 (0 %) 17.2 0.0 batch 41.2

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 54.5, Graphics.Draw 54.4, Graphics.Draw.draw_and_resource_release 54.2, Driver.Packet.draw 50.1, Driver.Draw 50.0, Driver.Draw.draw_enqueued 49.5, Recorder.Sync 47.4, batch 41.2, Driver.EndSubmission 1.9, Driver.WorkerWait 1.2

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 1.2 ms at 7524 ms, present 388
  • Driver.WorkerWait (queue worker 0x0) 1.2 ms at 9630 ms, present 424
  • Driver.WorkerWait (queue worker 0x0) 1.2 ms at 5184 ms, present 348
  • Driver.WorkerWait (queue worker 0x0) 1.2 ms at 7117 ms, present 381
  • Driver.WorkerWait (queue worker 0x0) 1.2 ms at 5241 ms, present 349
  • Driver.WorkerWait (queue worker 0x0) 1.1 ms at 3433 ms, present 318
  • Driver.WorkerWait (queue worker 0x0) 1.1 ms at 4657 ms, present 339
  • Driver.WorkerWait (queue worker 0x0) 1.1 ms at 5832 ms, present 359
  • Driver.WorkerWait (queue worker 0x0) 1.1 ms at 6242 ms, present 366
  • Driver.WorkerWait (queue worker 0x0) 1.1 ms at 4540 ms, present 337

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 48008: 0.5 ms at 9980 ms, present 430: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0
  • batch 30923: 0.5 ms at 1052 ms, present 277: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0
  • batch 46333: 0.5 ms at 9100 ms, present 415: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0
  • batch 32820: 0.5 ms at 2039 ms, present 294: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0
  • batch 31705: 0.5 ms at 1461 ms, present 284: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0
this PR

seconds 15:10 from present 900: 600 presents, frame p50 16.7 / p90 16.7 / p99 16.7 / max 16.9 ms, GPU busy 0.6 ms per present
AMD Radeon RX 7900 GRE (RADV NAVI31), radv Mesa 26.2.5-arch1.1, Linux 7.2.11-arch1-1, 1920x1080, commit 26f6779362, dropped: no

{"commit":"26f67793623d","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":900,"ms":10009.995},"presents":600,"frame_ms":{"p50":16.683,"p90":16.687,"p99":16.713,"max":16.861},"gpu_busy_ms_per_present":0.571,"worker_busy_pct":{"queue worker 0x0":20.201},"top_phases_ms_per_frame":{"VideoOut.Flip":15.801,"VideoOut.Flip.vblank_wait":15.372,"Driver.Packet":2.487,"Graphics.Draw":1.662,"Graphics.Draw.draw_and_resource_release":1.597,"Recorder.Sync":1.195,"Driver.Packet.draw":1.12,"Driver.Draw":1.101},"trace_dropped":false,"trace":"aps5-trace-26f67793623d-252043.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1124: 16.9 ms at 3737 ms: VideoOut.Flip (presenter) 15.2, VideoOut.Flip.vblank_wait (presenter) 14.7, Driver.WorkerWait (queue worker 0x0) 13.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.3
  • present 1356: 16.8 ms at 7608 ms: VideoOut.Flip (presenter) 15.7, VideoOut.Flip.vblank_wait (presenter) 15.6, Driver.WorkerWait (queue worker 0x0) 13.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.8
  • present 1494: 16.8 ms at 9910 ms: VideoOut.Flip (presenter) 16.0, VideoOut.Flip.vblank_wait (presenter) 15.7, Driver.WorkerWait (queue worker 0x0) 13.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.0
  • present 1263: 16.7 ms at 6056 ms: VideoOut.Flip (presenter) 15.9, VideoOut.Flip.vblank_wait (presenter) 15.3, Driver.WorkerWait (queue worker 0x0) 13.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.8
  • present 1295: 16.7 ms at 6590 ms: VideoOut.Flip (presenter) 15.7, VideoOut.Flip.vblank_wait (presenter) 15.0, Driver.WorkerWait (queue worker 0x0) 13.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.2

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 1.9 (12 %) 13.2 (79 %) 1.6 4.6 Driver.Packet 1.1, Driver.EndSubmission 0.9
draw committer 1.9 (11 %) 0.0 (0 %) 14.8 2.3 Recorder.Sync 1.2, Graphics.Draw 0.6
presenter 0.3 (2 %) 15.5 (93 %) 0.9 0.1 VideoOut.Flip 15.8
gpu 0.6 (3 %) 0.0 (0 %) 16.1 0.0 batch 0.6

Largest slices (ms per frame, inclusive, all threads): VideoOut.Flip 15.8, VideoOut.Flip.vblank_wait 15.4, Driver.WorkerWait 13.2, Driver.WorkerWait.idle_and_completion_poll 13.2, Recorder.Sync 1.2, Driver.Packet 1.1, Driver.EndSubmission 0.9, Graphics.Draw 0.6, Graphics.Draw.draw_and_resource_release 0.6, batch 0.6

Longest waits

  • VideoOut.Flip.vblank_wait (presenter) 16.4 ms at 7708 ms, present 1362
  • VideoOut.Flip.vblank_wait (presenter) 16.4 ms at 4388 ms, present 1163
  • VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 201 ms, present 912
  • VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 9577 ms, present 1474
  • VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 2636 ms, present 1058
  • VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 9710 ms, present 1482
  • VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 5890 ms, present 1253
  • VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 7892 ms, present 1373
  • VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 2136 ms, present 1028
  • VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 7391 ms, present 1343

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 13974: 0.2 ms at 1406 ms, present 984: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.7, Recorder.Submit (draw committer) 0.0
  • batch 12966: 0.1 ms at 221 ms, present 913: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1
  • batch 15735: 0.1 ms at 3474 ms, present 1108: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.9, Graphics.Draw.draw_and_resource_release (draw committer) 0.8, Recorder.Submit (draw committer) 0.0
  • batch 13363: 0.1 ms at 687 ms, present 941: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1
  • batch 15508: 0.1 ms at 3207 ms, present 1092: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0

Also tested:

  • ctest --test-dir build -R 'agc|shader|recompiler' -V -j6 with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, on main and on this change: 970 of 971 and 971 of 972 (the new _unimported entry), with the agc_driver_tessellation segfault (#5444) on both. Both logs have the same two VUIDs with the same counts (VkPipelineColorBlendStateCreateInfo-pAttachments-00605 ×26, VkWriteDescriptorSet-descriptorType-00337 ×32), so the change adds no validation errors, and neither log reports the validation layer missing. A first run of the change also failed agc_shader_disk_cache_large_file: its 2 GiB write failed on a nearly full tmpfs /tmp. After freeing space the whole suite was rerun with the result above.
  • The test cases on 1e20650e84: with only the test on main, both entries fail at the lookup of layer 0. With this change but without the flush before the scoped refresh(), agc_driver_depth_plane_partial_store passes (it reports both write-watched cases as not exercised) and _unimported fails at the lookup of layers 0 and 1. With this change both pass, also with APS5_DRAW_PIPELINE=1, whose epoch proofs in StorageTexture::refresh() are new on main since the previous base; the flush runs before that check.
  • On the previous base 0c6a5bd593: the DEMO song, entered with tools/pad_input.py (down, cross), ran at about 38–40 presents/s on main and 60 with this PR, with notes, sabers, score and combo rendering the same; the last menu frame was identical pixel for pixel; and the other ps5-opengl titles were unchanged over 40 s per side: OliSe Player PPSA01153 (60 FPS, 0.1 ms GPU) and PS5MC PPSA99420 (60 FPS, 5.3 ms GPU), with no depth-plane stores on either side, and OpenNOW PPSA99082, which idles on its sign-in screen and presents only on input.
  • python3 tools/check_conventions.py --base upstream/main passes.

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: AMD Radeon RX 7900 GRE (RADV NAVI31, Mesa 26.2.5), Arch Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959134066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-21T22:20:00Z. --- ### What Pulse (PPSA99993, ps5-opengl) runs its title menu at 17 FPS on `main`, with the GPU busy 41 ms per frame on a scene that needs under 1 ms. Every color draw stores the game's depth plane to guest memory and waits for it. The cause is the leftover half of the phantom-slice problem from #6189. ps5-opengl declares each color target as a 2-slice array and only renders slice 0, and Pulse's depth buffer sits in the memory of the unused slice 1 (color target `0x255600000`, depth plane `0x256600000`, 16 MiB apart, each slice 8.4 MiB). #6202, carried by #6718, made the target's lookup refresh only the layers the draw uses, which removed the per-draw whole-image uploads. But `cachedStorageTexture` still runs `FlushDepthPlanes` over the whole declared array before the lookup. That line came in with #7154 (@DavidSamir bisected the regression to its merge `50e0624d7` in [this comment](https://github.com/boykopovar/AnyPS5/pull/6202#issuecomment-6311977706)). So each draw into slice 0 stores the depth plane over slice 1, which the previous draw left stale on the GPU, then syncs on that store. On `main` `0c6a5bd593`, 59,819 `[flush] image 0x256600000+0x870000 for depth plane store` lines were logged in 35 s, one per draw. A 6 s `perf` profile (taken on that `main` with #9402, which does not touch this path) had a third of the process's CPU samples under `FlushDepthPlanes` called from `CachedStorageLayers`. With this change, a layered lookup (`CachedStorageLayers`) no longer flushes over the whole array in `cachedStorageTexture`. `RefreshLayers` flushes the depth planes itself, before anything can return early: - On the scoped path, it flushes over the tracked layers it is about to refresh, before `refresh(first, last)`. That has to come first: `refresh()` returns early when its refresh proof holds, and the proof only looks at guest memory, which a depth plane the GPU just wrote has not changed yet. - Every fallback to a full `Refresh()` flushes the whole image's depth planes first. That covers the same proof shortcut, and a full refresh that hands over DCC clear keys, which skips `FlushPending`. - A new cache entry already flushes the whole range in `FlushPending(..., "storage image creation")`. Lookups without layers, written lookups and `APS5_NO_TEXTURE_CACHE` keep the whole-range flush. `agc_driver_depth_plane_partial_store` gains a case: a cached 3-layer array image with a GPU-written depth plane over its second layer, looked up with the GPU mutex held as the draw path does. Where guest memory is write-watched, repeated lookups first take a refresh proof (the test requires one), so the lookups after the depth write go through that shortcut. - A lookup of layer 0 must store nothing and leave the plane stale. On `main` this fails with `a lookup of the first layer of an array stored the depth plane over its second layer`. - A scoped lookup of layers 0 and 1 must store the plane. Without the flush before `refresh()`, this fails under the refresh proof with `a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer`. - A lookup of all three layers, which takes the full-refresh fallback, must store it as well. The lookup imports the array. Where the host import probe finds that imports lose their write protection (RADV, and lavapipe as @jotitadev found), imported ranges are compared instead of watched, so the refresh-proof half is skipped there; only drivers that keep imports watched (NVIDIA) would run it. So the same test is also registered as `agc_driver_depth_plane_partial_store_unimported`, with `APS5_NO_HOST_IMPORT=1`, as `agc_driver_array_layer_target_cpu` is. Without host imports the guest memory stays in the write watch on any driver, so both write-watched cases run there. Forcing `APS5_WRITE_WATCH_IMPORTS=watch` instead would not be sound on those drivers, since a GPU read clears the protection. Overlap: `pr_overlap` on `1e20650e84` reports no pull request it could compare. #6743 adds a test registration next to `agc_driver_array_layer_target_cpu`; the new registration sits before that block, so the two do not touch. Of the 80 pull requests it could not compare, two change these functions: #6202, whose change is already on `main` through #6718, and #6194, which counts evictions in the eviction loop of `cachedStorageTexture`, away from the flush line this change edits. ### Tested Arch Linux, AMD Radeon RX 7900 GRE (RADV NAVI31, Mesa 26.2.5), Ryzen 5 7500F, Release, on `main` `1e20650e84`. Pulse PPSA99993 (homebrew catalog, sha256 `9103d3d6…`), title menu, no input, run with `tools/title_run.py` from #7264, trace window seconds 15–25 after the first present (`APS5_TRACE_SECONDS=15:10`): | | `main` | this PR | |---|---|---| | FPS, 3 runs of 60 s | 17.2 / 17.2 / 17.2 | 59.9 / 59.9 / 59.9 (vsync) | | presents in the 10 s window | 172 | 600 | | frame p50 / p99 | 58.3 / 60.0 ms | 16.7 / 16.7 ms | | GPU busy per present | 41.2 ms | 0.6 ms | | queue worker busy | 97.7 % | 20.2 % | Summary lines: ```json {"commit":"1e20650e8458","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":259,"ms":10036.713},"presents":172,"frame_ms":{"p50":58.269,"p90":59.077,"p99":60.018,"max":64.043},"gpu_busy_ms_per_present":41.178,"worker_busy_pct":{"queue worker 0x0":97.741},"top_phases_ms_per_frame":{"Driver.Packet":55.152,"Graphics.Draw":54.382,"Graphics.Draw.draw_and_resource_release":54.188,"Driver.Packet.draw":50.193,"Driver.Draw":50.164,"Driver.Draw.draw_enqueued":49.547,"Recorder.Sync":47.374,"Recorder.Submit":2.229},"trace_dropped":false,"trace":"aps5-trace-1e20650e8458-220371.json.gz"} ``` ```json {"commit":"26f67793623d","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":900,"ms":10009.995},"presents":600,"frame_ms":{"p50":16.683,"p90":16.687,"p99":16.713,"max":16.861},"gpu_busy_ms_per_present":0.571,"worker_busy_pct":{"queue worker 0x0":20.201},"top_phases_ms_per_frame":{"VideoOut.Flip":15.801,"VideoOut.Flip.vblank_wait":15.372,"Driver.Packet":2.487,"Graphics.Draw":1.662,"Graphics.Draw.draw_and_resource_release":1.597,"Recorder.Sync":1.195,"Driver.Packet.draw":1.12,"Driver.Draw":1.101},"trace_dropped":false,"trace":"aps5-trace-26f67793623d-252043.json.gz"} ``` `tools/trace_digest.py` of both traces (attached): <details><summary>main</summary> **seconds 15:10** from present 259: 172 presents, frame p50 58.3 / p90 59.1 / p99 60.0 / max 64.0 ms, GPU busy 41.2 ms per present AMD Radeon RX 7900 GRE (RADV NAVI31), radv Mesa 26.2.5-arch1.1, Linux 7.2.11-arch1-1, 1920x1080, commit 1e20650e8458, dropped: no ```json {"commit":"1e20650e8458","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":259,"ms":10036.713},"presents":172,"frame_ms":{"p50":58.269,"p90":59.077,"p99":60.018,"max":64.043},"gpu_busy_ms_per_present":41.178,"worker_busy_pct":{"queue worker 0x0":97.741},"top_phases_ms_per_frame":{"Driver.Packet":55.152,"Graphics.Draw":54.382,"Graphics.Draw.draw_and_resource_release":54.188,"Driver.Packet.draw":50.193,"Driver.Draw":50.164,"Driver.Draw.draw_enqueued":49.547,"Recorder.Sync":47.374,"Recorder.Submit":2.229},"trace_dropped":false,"trace":"aps5-trace-1e20650e8458-220371.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 350: 64.0 ms at 5299 ms: Graphics.Draw (draw committer) 59.8, Driver.Packet (queue worker 0x0) 59.8, Graphics.Draw.draw_and_resource_release (draw committer) 59.6, Driver.Packet.draw (queue worker 0x0) 54.8 - present 344: 60.0 ms at 4950 ms: Graphics.Draw (draw committer) 56.0, Driver.Packet (queue worker 0x0) 55.9, Graphics.Draw.draw_and_resource_release (draw committer) 55.8, Driver.Packet.draw (queue worker 0x0) 51.3 - present 422: 59.9 ms at 9511 ms: Graphics.Draw (draw committer) 55.8, Driver.Packet (queue worker 0x0) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.6, Driver.Packet.draw (queue worker 0x0) 51.2 - present 413: 59.8 ms at 8981 ms: Graphics.Draw (draw committer) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.5, Driver.Packet (queue worker 0x0) 55.4, Driver.Packet.draw (queue worker 0x0) 50.9 - present 406: 59.7 ms at 8571 ms: Graphics.Draw (draw committer) 55.7, Graphics.Draw.draw_and_resource_release (draw committer) 55.5, Driver.Packet (queue worker 0x0) 55.4, Driver.Packet.draw (queue worker 0x0) 50.9 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 56.4 (97 %) | 1.2 (2 %) | 0.8 | 2.0 | Driver.Packet 54.5, Driver.EndSubmission 1.9 | | draw committer | 56.2 (96 %) | 0.0 (0 %) | 2.2 | 1.7 | Graphics.Draw 54.4, Recorder.Sync 1.8 | | presenter | 0.1 (0 %) | 0.0 (0 %) | 58.2 | 0.1 | VideoOut.Flip 0.2 | | gpu | 41.2 (71 %) | 0.0 (0 %) | 17.2 | 0.0 | batch 41.2 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 54.5, Graphics.Draw 54.4, Graphics.Draw.draw_and_resource_release 54.2, Driver.Packet.draw 50.1, Driver.Draw 50.0, Driver.Draw.draw_enqueued 49.5, Recorder.Sync 47.4, batch 41.2, Driver.EndSubmission 1.9, Driver.WorkerWait 1.2 **Longest waits** - Driver.WorkerWait (queue worker 0x0) 1.2 ms at 7524 ms, present 388 - Driver.WorkerWait (queue worker 0x0) 1.2 ms at 9630 ms, present 424 - Driver.WorkerWait (queue worker 0x0) 1.2 ms at 5184 ms, present 348 - Driver.WorkerWait (queue worker 0x0) 1.2 ms at 7117 ms, present 381 - Driver.WorkerWait (queue worker 0x0) 1.2 ms at 5241 ms, present 349 - Driver.WorkerWait (queue worker 0x0) 1.1 ms at 3433 ms, present 318 - Driver.WorkerWait (queue worker 0x0) 1.1 ms at 4657 ms, present 339 - Driver.WorkerWait (queue worker 0x0) 1.1 ms at 5832 ms, present 359 - Driver.WorkerWait (queue worker 0x0) 1.1 ms at 6242 ms, present 366 - Driver.WorkerWait (queue worker 0x0) 1.1 ms at 4540 ms, present 337 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 48008: 0.5 ms at 9980 ms, present 430: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 - batch 30923: 0.5 ms at 1052 ms, present 277: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 - batch 46333: 0.5 ms at 9100 ms, present 415: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 - batch 32820: 0.5 ms at 2039 ms, present 294: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 - batch 31705: 0.5 ms at 1461 ms, present 284: GPU no ranges; recorded by Recorder.Sync (draw committer) 0.7, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 </details> <details><summary>this PR</summary> **seconds 15:10** from present 900: 600 presents, frame p50 16.7 / p90 16.7 / p99 16.7 / max 16.9 ms, GPU busy 0.6 ms per present AMD Radeon RX 7900 GRE (RADV NAVI31), radv Mesa 26.2.5-arch1.1, Linux 7.2.11-arch1-1, 1920x1080, commit 26f67793623d, dropped: no ```json {"commit":"26f67793623d","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 7900 GRE (RADV NAVI31)","driver":"radv Mesa 26.2.5-arch1.1","os":"Linux 7.2.11-arch1-1","cpu":"AMD Ryzen 5 7500F 6-Core Processor","cpu_threads":12,"memory_mib":31744,"title_id":"PPSA99993","title":"Pulse","content_version":"01.000.000","resolution":"1920x1080","window":{"spec":"seconds 15:10","first_present":900,"ms":10009.995},"presents":600,"frame_ms":{"p50":16.683,"p90":16.687,"p99":16.713,"max":16.861},"gpu_busy_ms_per_present":0.571,"worker_busy_pct":{"queue worker 0x0":20.201},"top_phases_ms_per_frame":{"VideoOut.Flip":15.801,"VideoOut.Flip.vblank_wait":15.372,"Driver.Packet":2.487,"Graphics.Draw":1.662,"Graphics.Draw.draw_and_resource_release":1.597,"Recorder.Sync":1.195,"Driver.Packet.draw":1.12,"Driver.Draw":1.101},"trace_dropped":false,"trace":"aps5-trace-26f67793623d-252043.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1124: 16.9 ms at 3737 ms: VideoOut.Flip (presenter) 15.2, VideoOut.Flip.vblank_wait (presenter) 14.7, Driver.WorkerWait (queue worker 0x0) 13.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.3 - present 1356: 16.8 ms at 7608 ms: VideoOut.Flip (presenter) 15.7, VideoOut.Flip.vblank_wait (presenter) 15.6, Driver.WorkerWait (queue worker 0x0) 13.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.8 - present 1494: 16.8 ms at 9910 ms: VideoOut.Flip (presenter) 16.0, VideoOut.Flip.vblank_wait (presenter) 15.7, Driver.WorkerWait (queue worker 0x0) 13.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.0 - present 1263: 16.7 ms at 6056 ms: VideoOut.Flip (presenter) 15.9, VideoOut.Flip.vblank_wait (presenter) 15.3, Driver.WorkerWait (queue worker 0x0) 13.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.8 - present 1295: 16.7 ms at 6590 ms: VideoOut.Flip (presenter) 15.7, VideoOut.Flip.vblank_wait (presenter) 15.0, Driver.WorkerWait (queue worker 0x0) 13.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 13.2 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 1.9 (12 %) | 13.2 (79 %) | 1.6 | 4.6 | Driver.Packet 1.1, Driver.EndSubmission 0.9 | | draw committer | 1.9 (11 %) | 0.0 (0 %) | 14.8 | 2.3 | Recorder.Sync 1.2, Graphics.Draw 0.6 | | presenter | 0.3 (2 %) | 15.5 (93 %) | 0.9 | 0.1 | VideoOut.Flip 15.8 | | gpu | 0.6 (3 %) | 0.0 (0 %) | 16.1 | 0.0 | batch 0.6 | **Largest slices** (ms per frame, inclusive, all threads): VideoOut.Flip 15.8, VideoOut.Flip.vblank_wait 15.4, Driver.WorkerWait 13.2, Driver.WorkerWait.idle_and_completion_poll 13.2, Recorder.Sync 1.2, Driver.Packet 1.1, Driver.EndSubmission 0.9, Graphics.Draw 0.6, Graphics.Draw.draw_and_resource_release 0.6, batch 0.6 **Longest waits** - VideoOut.Flip.vblank_wait (presenter) 16.4 ms at 7708 ms, present 1362 - VideoOut.Flip.vblank_wait (presenter) 16.4 ms at 4388 ms, present 1163 - VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 201 ms, present 912 - VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 9577 ms, present 1474 - VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 2636 ms, present 1058 - VideoOut.Flip.vblank_wait (presenter) 16.3 ms at 9710 ms, present 1482 - VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 5890 ms, present 1253 - VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 7892 ms, present 1373 - VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 2136 ms, present 1028 - VideoOut.Flip.vblank_wait (presenter) 16.2 ms at 7391 ms, present 1343 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 13974: 0.2 ms at 1406 ms, present 984: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.7, Graphics.Draw.draw_and_resource_release (draw committer) 0.7, Recorder.Submit (draw committer) 0.0 - batch 12966: 0.1 ms at 221 ms, present 913: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1 - batch 15735: 0.1 ms at 3474 ms, present 1108: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.9, Graphics.Draw.draw_and_resource_release (draw committer) 0.8, Recorder.Submit (draw committer) 0.0 - batch 13363: 0.1 ms at 687 ms, present 941: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1 - batch 15508: 0.1 ms at 3207 ms, present 1092: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0 </details> Also tested: - `ctest --test-dir build -R 'agc|shader|recompiler' -V -j6` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, on `main` and on this change: 970 of 971 and 971 of 972 (the new `_unimported` entry), with the `agc_driver_tessellation` segfault (#5444) on both. Both logs have the same two VUIDs with the same counts (`VkPipelineColorBlendStateCreateInfo-pAttachments-00605` ×26, `VkWriteDescriptorSet-descriptorType-00337` ×32), so the change adds no validation errors, and neither log reports the validation layer missing. A first run of the change also failed `agc_shader_disk_cache_large_file`: its 2 GiB write failed on a nearly full tmpfs `/tmp`. After freeing space the whole suite was rerun with the result above. - The test cases on `1e20650e84`: with only the test on `main`, both entries fail at the lookup of layer 0. With this change but without the flush before the scoped `refresh()`, `agc_driver_depth_plane_partial_store` passes (it reports both write-watched cases as not exercised) and `_unimported` fails at the lookup of layers 0 and 1. With this change both pass, also with `APS5_DRAW_PIPELINE=1`, whose epoch proofs in `StorageTexture::refresh()` are new on `main` since the previous base; the flush runs before that check. - On the previous base `0c6a5bd593`: the DEMO song, entered with `tools/pad_input.py` (down, cross), ran at about 38–40 presents/s on `main` and 60 with this PR, with notes, sabers, score and combo rendering the same; the last menu frame was identical pixel for pixel; and the other ps5-opengl titles were unchanged over 40 s per side: OliSe Player PPSA01153 (60 FPS, 0.1 ms GPU) and PS5MC PPSA99420 (60 FPS, 5.3 ms GPU), with no depth-plane stores on either side, and OpenNOW PPSA99082, which idles on its sign-in screen and presents only on input. - `python3 tools/check_conventions.py --base upstream/main` passes. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 7900 GRE (RADV NAVI31, Mesa 26.2.5), Arch Linux - [x] AI-assisted: yes
janzezno commented 2026-10-21 22:22:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-21T22:22:02Z.


Traces of the two windows whose summary lines are in the description, Pulse PPSA99993 title menu, seconds 15–25 after the first present (APS5_TRACE_SECONDS=15:10), RX 7900 GRE (RADV, Mesa 26.2.5):

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327841791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#issuecomment-6327841791). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-21T22:22:02Z. --- Traces of the two windows whose summary lines are in the description, Pulse PPSA99993 title menu, seconds 15–25 after the first present (`APS5_TRACE_SECONDS=15:10`), RX 7900 GRE (RADV, Mesa 26.2.5): - `main` (`0c6a5bd593`): [aps5-trace-0c6a5bd5938f-790477.json.gz](https://github.com/user-attachments/files/33791613/aps5-trace-0c6a5bd5938f-790477.json.gz) - this PR (`9fa9b10a5b`): [aps5-trace-9fa9b10a5b08-840854.json.gz](https://github.com/user-attachments/files/33791614/aps5-trace-9fa9b10a5b08-840854.json.gz)
MarcZX10 commented 2026-10-22 04:39:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:39:24Z.

Review: DISMISSED


The implementation moves the flush to the layer ranges actually refreshed and preserves full-range handling for whole refreshes, written lookups, missing/unsafe layer metadata and APS5_NO_TEXTURE_CACHE. I checked the same-file overlap warning with #9012: its ShaderResources.cpp edits concern periodic template audits at separate hunks. The PR’s before/after Pulse traces and summaries are attached, and its 31-test same-GPU main/change Vulkan run confirms the validation layer loaded and no new VUID- errors; the extra write-watch run documents the branch that CTest cannot exercise by default. The reported 3-game checks and unchanged titles are clearly scoped.

The tested head is based on 0c6a5bd593, while current main is 110a18ba01. Please update the branch and refresh the focused validation comparison, trace pair, conventions and overlap check against current main before treating the current-main checklist as satisfied. Hosted full product jobs are skipped. I did not run local performance or GPU tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609333997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#pullrequestreview-5609333997). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:39:24Z. **Review:** DISMISSED --- The implementation moves the flush to the layer ranges actually refreshed and preserves full-range handling for whole refreshes, written lookups, missing/unsafe layer metadata and `APS5_NO_TEXTURE_CACHE`. I checked the same-file overlap warning with #9012: its `ShaderResources.cpp` edits concern periodic template audits at separate hunks. The PR’s before/after Pulse traces and summaries are attached, and its 31-test same-GPU main/change Vulkan run confirms the validation layer loaded and no new `VUID-` errors; the extra write-watch run documents the branch that CTest cannot exercise by default. The reported 3-game checks and unchanged titles are clearly scoped. The tested head is based on `0c6a5bd593`, while current main is `110a18ba01`. Please update the branch and refresh the focused validation comparison, trace pair, conventions and overlap check against current main before treating the current-main checklist as satisfied. Hosted full product jobs are skipped. I did not run local performance or GPU tests.
jotitadev commented 2026-10-22 07:52:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:52:13Z.

Review: COMMENTED


Ran this on NVIDIA and lavapipe. One thing worth knowing: on lavapipe, which is what CI uses, the second new assertion never runs.

Setup: Ubuntu 26.04, GCC 15.2, Release, head 9fa9b10a5 merged onto main d6eafa54d. ANYPS5_GPU picks the device, ANYPS5_REQUIRE_VULKAN=1, ctest -j1.

  • Red (main plus only the new DepthPlanePartialStore.cpp): agc_driver_depth_plane_partial_store fails on both GPUs with a lookup of the first layer of an array stored the depth plane over its second layer.
  • Green (the PR): passes 10 of 10 on each GPU. ^agc.*(depth_plane|array|storage) (40 tests) also passes on both.
  • Flush before refresh(): I took the PR and removed only the new FlushDepthPlanes call before refresh(firstLayer, lastLayer) in RefreshLayers. On the 3070 the test then fails with a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer. On lavapipe it passes 3 of 3, and the log shows guest memory is not write-watched here: lookups of array layers through a refresh proof are not exercised, plus the matching skip line for the older partly-stored-plane case. So WriteWatched() or Watched() over the array is false on that device, and the refresh-proof branch is skipped.

So the test does guard both halves of the fix, but the second half only on a device where guest memory is write-watched (here, the 3070). The Linux CI job runs the GPU tests on lavapipe. If its lavapipe behaves like mine, CI would not catch someone removing that flush.

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

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5610884957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#pullrequestreview-5610884957). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T07:52:13Z. **Review:** COMMENTED --- Ran this on NVIDIA and lavapipe. One thing worth knowing: on lavapipe, which is what CI uses, the second new assertion never runs. **Setup:** Ubuntu 26.04, GCC 15.2, Release, head `9fa9b10a5` merged onto `main` `d6eafa54d`. `ANYPS5_GPU` picks the device, `ANYPS5_REQUIRE_VULKAN=1`, ctest `-j1`. - **Red** (main plus only the new `DepthPlanePartialStore.cpp`): `agc_driver_depth_plane_partial_store` fails on both GPUs with `a lookup of the first layer of an array stored the depth plane over its second layer`. - **Green** (the PR): passes 10 of 10 on each GPU. `^agc.*(depth_plane|array|storage)` (40 tests) also passes on both. - **Flush before `refresh()`:** I took the PR and removed only the new `FlushDepthPlanes` call before `refresh(firstLayer, lastLayer)` in `RefreshLayers`. On the 3070 the test then fails with `a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer`. On lavapipe it passes 3 of 3, and the log shows `guest memory is not write-watched here: lookups of array layers through a refresh proof are not exercised`, plus the matching skip line for the older partly-stored-plane case. So `WriteWatched()` or `Watched()` over the array is false on that device, and the refresh-proof branch is skipped. So the test does guard both halves of the fix, but the second half only on a device where guest memory is write-watched (here, the 3070). The Linux CI job runs the GPU tests on lavapipe. If its lavapipe behaves like mine, CI would not catch someone removing that flush. GPUs tested: NVIDIA GeForce RTX 3070 (driver 595.99.02), Mesa lavapipe 26.0.3 (LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
janzezno commented 2026-10-22 15:23:53 +00:00 (Migrated from github.com)

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


Traces of the two windows whose summary lines are in the description, Pulse PPSA99993 title menu, seconds 15–25 after the first present (APS5_TRACE_SECONDS=15:10), RX 7900 GRE (RADV, Mesa 26.2.5), on main b7d1d47a5f:

main (b7d1d47a5f): aps5-trace-b7d1d47a5f9f-61358.json.gz
this PR (593daedbc7): aps5-trace-593daedbc702-93127.json.gz

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6344445578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#issuecomment-6344445578). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-22T15:23:53Z. --- Traces of the two windows whose summary lines are in the description, Pulse PPSA99993 title menu, seconds 15–25 after the first present (`APS5_TRACE_SECONDS=15:10`), RX 7900 GRE (RADV, Mesa 26.2.5), on `main` `b7d1d47a5f`: `main` (`b7d1d47a5f`): [aps5-trace-b7d1d47a5f9f-61358.json.gz](https://github.com/user-attachments/files/33828607/aps5-trace-b7d1d47a5f9f-61358.json.gz) this PR (`593daedbc7`): [aps5-trace-593daedbc702-93127.json.gz](https://github.com/user-attachments/files/33828619/aps5-trace-593daedbc702-93127.json.gz)
janzezno commented 2026-10-22 15:24:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-22T15:24:16Z.


@jotitadev thanks, that's a real gap, and not only on lavapipe: RADV here skips that branch too. The lookup imports the array, and where the import probe reports that host imports resolve write protection (RADV here: 4 of 4 scratch pages written after a GPU read), imported ranges are compared instead of watched, so Watched() is false over the array. Your 3070 keeps imports watched, which is why only it ran the refresh-proof half.

Forcing APS5_WRITE_WATCH_IMPORTS=watch is not sound on those drivers, since a GPU read clears the protection. That is also why the older case failed under it in the description. So the test now also runs as agc_driver_depth_plane_partial_store_unimported, with APS5_NO_HOST_IMPORT=1, the same way agc_driver_array_layer_target_cpu does. Without host imports the guest memory stays in the write watch on any driver, so both write-watched cases run and neither skip line is printed. On RADV, on current main b7d1d47a5f:

  • main plus only the test: both entries fail with a lookup of the first layer of an array stored the depth plane over its second layer.
  • This PR without the flush before refresh(): agc_driver_depth_plane_partial_store still passes (both skip lines), while _unimported fails with a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer.
  • This PR: both pass.

If you have a moment, could you run _unimported on lavapipe? It should print neither guest memory is not write-watched here line there.

@MarcZX10 rebased onto b7d1d47a5f (no conflicts); the head is now 593daedbc7. The validation-layer comparison, the Pulse trace pair (attached above), check_conventions and pr_overlap were redone on that base, and the description is updated with the results. pr_overlap also showed #6743 adding a test registration where the new one first went, so the new one now sits before agc_driver_array_layer_target_cpu instead.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6344454688 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#issuecomment-6344454688). Originally posted by [janzezno](https://github.com/janzezno) on 2026-10-22T15:24:16Z. --- @jotitadev thanks, that's a real gap, and not only on lavapipe: RADV here skips that branch too. The lookup imports the array, and where the import probe reports that host imports resolve write protection (RADV here: `4 of 4 scratch pages written after a GPU read`), imported ranges are compared instead of watched, so `Watched()` is false over the array. Your 3070 keeps imports watched, which is why only it ran the refresh-proof half. Forcing `APS5_WRITE_WATCH_IMPORTS=watch` is not sound on those drivers, since a GPU read clears the protection. That is also why the older case failed under it in the description. So the test now also runs as `agc_driver_depth_plane_partial_store_unimported`, with `APS5_NO_HOST_IMPORT=1`, the same way `agc_driver_array_layer_target_cpu` does. Without host imports the guest memory stays in the write watch on any driver, so both write-watched cases run and neither skip line is printed. On RADV, on current `main` `b7d1d47a5f`: - `main` plus only the test: both entries fail with `a lookup of the first layer of an array stored the depth plane over its second layer`. - This PR without the flush before `refresh()`: `agc_driver_depth_plane_partial_store` still passes (both skip lines), while `_unimported` fails with `a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer`. - This PR: both pass. If you have a moment, could you run `_unimported` on lavapipe? It should print neither `guest memory is not write-watched here` line there. @MarcZX10 rebased onto `b7d1d47a5f` (no conflicts); the head is now `593daedbc7`. The validation-layer comparison, the Pulse trace pair (attached above), `check_conventions` and `pr_overlap` were redone on that base, and the description is updated with the results. `pr_overlap` also showed #6743 adding a test registration where the new one first went, so the new one now sits before `agc_driver_array_layer_target_cpu` instead.
jotitadev commented 2026-10-23 02:06:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T02:06:46Z.

Review: COMMENTED


Apple GPU / MoltenVK run of 593daedbc7, following up on my lavapipe note. MoltenVK keeps host imports watched, as NVIDIA does. So here the refresh-proof half runs in both registrations, and both catch the missing flush before refresh(). (I couldn't rerun lavapipe for _unimported on this machine.)

Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and again against MoltenVK main + SPIRV-Cross #2704. Release, BUILD_TESTING=ON.

Base/method: PR #8658 feat/macos-port @ c5fa39620a (current main plus the macOS port), not main, because main does not build on macOS. This PR's diff at 593daedbc7 (git diff merge-base..head -- . ':!docs') applied cleanly. Full rebuild before each stage.

Import probe on this device, both drivers:

[write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import); imported ranges stay watched

With this PR (--repeat until-fail:3, both drivers): agc_driver_depth_plane_partial_store and agc_driver_depth_plane_partial_store_unimported pass 3/3. In -V output, neither one prints guest memory is not write-watched here. (For this stage the tree also had #7705 and #9717/#9533. They touch other tests.)

Mutation (this PR alone, with the FlushDepthPlanes(scopeBegin, ...) line before refresh(firstLayer, lastLayer) removed from RefreshLayers): both registrations fail on both drivers:

AGC graphics: a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer

So on Apple, unlike RADV and lavapipe, the original agc_driver_depth_plane_partial_store catches it too. _unimported catches it the same way.

Full ^agc suite (877 tests), both drivers: the same failures as the #8658 base for this PR's tests. The other new failures in that tree come from #7705's and #9533's tests, which I reported on those PRs.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; and MoltenVK main + SPIRV-Cross #2704).

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623098586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9443#pullrequestreview-5623098586). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-23T02:06:46Z. **Review:** COMMENTED --- Apple GPU / MoltenVK run of `593daedbc7`, following up on my lavapipe note. MoltenVK keeps host imports watched, as NVIDIA does. So here the refresh-proof half runs in both registrations, and both catch the missing flush before `refresh()`. (I couldn't rerun lavapipe for `_unimported` on this machine.) **Machine:** Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and again against MoltenVK main + SPIRV-Cross #2704. Release, `BUILD_TESTING=ON`. **Base/method:** PR #8658 `feat/macos-port` @ `c5fa39620a` (current `main` plus the macOS port), not `main`, because `main` does not build on macOS. This PR's diff at `593daedbc7` (`git diff merge-base..head -- . ':!docs'`) applied cleanly. Full rebuild before each stage. **Import probe on this device**, both drivers: ``` [write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 0 after the import); imported ranges stay watched ``` **With this PR** (`--repeat until-fail:3`, both drivers): `agc_driver_depth_plane_partial_store` and `agc_driver_depth_plane_partial_store_unimported` pass 3/3. In `-V` output, neither one prints `guest memory is not write-watched here`. (For this stage the tree also had #7705 and #9717/#9533. They touch other tests.) **Mutation** (this PR alone, with the `FlushDepthPlanes(scopeBegin, ...)` line before `refresh(firstLayer, lastLayer)` removed from `RefreshLayers`): both registrations fail on both drivers: ``` AGC graphics: a lookup of the first two layers of a three-layer array did not store the depth plane over its second layer ``` So on Apple, unlike RADV and lavapipe, the original `agc_driver_depth_plane_partial_store` catches it too. `_unimported` catches it the same way. **Full `^agc` suite** (877 tests), both drivers: the same failures as the #8658 base for this PR's tests. The other new failures in that tree come from #7705's and #9533's tests, which I reported on those PRs. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; and MoltenVK main + SPIRV-Cross #2704). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!9443
No description provided.