perf(agc): retile storage write-back windows straight into their unit-shadow slabs #6490
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6490"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T17:17:45Z.
What
A storage write-back retiled each window into a device scratch buffer and then copied the kept bytes from the scratch into the import's unit-shadow slabs, so every stored byte was written twice (plus a padding copy into the scratch and the barriers between them). Now a window retiles straight into its slabs when:
savebuffer.A window that crosses a slab boundary gets one dispatch per slab piece, with its range narrowed to that piece. This is exact: the retile writes only the elements inside the window's range, and every other byte the scratch copy would have stored is padding, which is copied into the slab from its current source before the retile, or left alone when the slab already holds it at that offset. Every other window keeps the scratch path.
Tested
Windows 10 19045, MinGW-w64 GCC 15.2, NVIDIA 617.42.
Minecraft Dungeons II (PPSA16064), title screen, same relinked executable and libraries on a lab build with a switch for the old path, alternating 2 × 240 s,
APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1; box 1 withAPS5_TEXTURE_CACHE_MIB=3072on both sides so storage-cache eviction doesn't mask it:[gputime]storage-writeback per presentStorage write-back GPU time drops about 45 % on both cards. The frame rate moves 2–3 % at this title because the frame isn't purely GPU-bound there; the saving applies to every title that writes storage images back. In isolation the detile/retile dispatch itself runs at 150–280 GB/s on the RTX 4060, so the copies, not the shader, were the cost.
ctest -R '^agc_' -j 6on RTX 4060:upstream/main0029e62f93 failed of 598, this branch 3 failed of 599, the same three (agc_shader_disk_cache,agc_driver_preparation_scope_settle, andagc_driver_gpu_indirect_arguments_misaligned_writer_ahead, which doesn't compile with this toolchain onmaineither). The newagc_storage_write_backpasses.agc_storage_write_back(--storage-write-back-only): runs the storage refresh, write-back padding and single-pass tests, and the padding test gains three watched surfaces written back twice each (512x512 with 3 mips and no padding, 1000x700 padded, 1900x1100 across two 8 MiB slabs) plus the existing 520x260 case, all required to go direct, with exact texel and untouched-byte checks after each write-back.tools/check_conventions.py --base upstream/mainpasses;git diff --checkclean.Found while working on Minecraft Dungeons II in the working group with @AlxcBTW (AlxcBTW/AnyPS5#56), where storage write-back is our side of the split.
Performance capture (as the Performance report form describes): Minecraft Dungeons II (PPSA16064) title screen, RTX 3060 12 GB (i5-12400F), NVIDIA 617.42, Windows 10.0.19045, 3840x2160 output. Only
APS5_TRACE_SECONDS=120:12set, caches warm (the title ran once on the build and was restarted), stderr not redirected.main48d61f53b4against this PR's headb4cb4f8dbd:Frame and GPU times (ms):
Top phases (ms per frame):
Traces:
aps5-trace-48d61f53b46f-9720.json.gz(main) andaps5-trace-b4cb4f8dbdf6-2632.json.gz(this PR), attached below.trace_digest.py, main
seconds 120:12 from present 2158: 99 presents, frame p50 117.2 / p90 145.0 / p99 158.4 / max 158.4 ms, GPU busy 100.7 ms per present
NVIDIA GeForce RTX 3060, NVIDIA 617.42, Windows 10.0.19045, 3840x2160, commit
48d61f53b4, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 235.3, batch 100.7, Driver.Packet.dispatch 86.1, Driver.Dispatch 85.2, Driver.Packet.memory_wait 68.0, Vulkan.Dispatch 39.4, Vulkan.Dispatch.shader_resources 37.1, Driver.Packet.device_lock 32.2, Driver.Packet.prepare_memory 27.8, Recorder.Sync 20.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, this PR
seconds 120:12 from present 2200: 106 presents, frame p50 109.0 / p90 142.6 / p99 156.7 / max 157.3 ms, GPU busy 92.3 ms per present
NVIDIA GeForce RTX 3060, NVIDIA 617.42, Windows 10.0.19045, 3840x2160, commit
b4cb4f8dbd, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 219.3, batch 92.3, Driver.Packet.dispatch 78.9, Driver.Dispatch 78.0, Driver.Packet.memory_wait 64.0, Vulkan.Dispatch 35.0, Vulkan.Dispatch.shader_resources 32.4, Driver.Packet.device_lock 30.9, Driver.Packet.prepare_memory 24.4, Recorder.WaitSerial 20.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T17:29:27Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppL3143core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppL3243-3245Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppImported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T18:13:43Z.
Same measurement on this PR's exact head (
bde6e2f17) against its merge base (0029e62f9), both built from the same tree, same relinked executables, alternating,APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1:main0029e62f9APS5_TEXTURE_CACHE_MIB=3072both sides), 2 × 240 sNo faults in any of the 14 runs. So a second title (Sword of the Sea) gains as well, and on the RTX 3060 both titles move about 5 %. @AlxcBTW is running the same pair on an RTX 5070 Laptop.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-15T19:10:53Z.
Third card, as @parl0v asked in the working group: RTX 5070 Laptop 8 GB, Ryzen AI 9 365, NVIDIA 617.42, Windows 11, on AC. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input,
APS5_TEXTURE_CACHE_MIB=3072on both sides so the storage cache does not evict. Base = this PR's merge base0029e62f9, PR =bde6e2f17, both built on our fork CI with the default configuration. Each side ran from its own run directory with a warm shader cache: one cold row per side after the relink, then alternating warm rows of 200 s. Numbers are the means of the title windows (10 s each, after the splash).Storage write-back halves on this card too (−50 %, same bytes), GPU busy drops by ~5.3 ms, and the title gains ~4 % (warm rows 7.93-7.99 against 8.27-8.29). The frame is not GPU-bound here either (~44 ms of idle gaps per frame on both sides), so most of the GPU saving does not show as frame rate at this scene; the other classes (draw ~25 ms, copy ~5.3 ms, shadow-publish ~5.7 ms) are unchanged within noise. The last screenshot of both warm PR rows shows the title image as on main (logo, campfire, lighting); the other shots were not reviewed one by one. Not run: the test target, Linux, gameplay.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T02:51:27Z.
@AlxcBTW thanks for the third card: write-back −50 % (11.8 → 5.9 ms per present, same bytes) and +4 % at the title on the RTX 5070 Laptop, no timeouts or fatals, matching the RTX 3060 / 4060 rows. With ~44 ms of CPU-side idle per frame on all three, that's about what this scene can show.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T16:22:09Z.
Fresh numbers on current
main(452494439, 60 commits past the base of my earlier rows); the head (bde6e2f17) still merges cleanly. RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, Minecraft Dungeons II (PPSA16064 01.100.100) title screen, no input,APS5_PROFILE_DRAW=1, automatic budgets, 200 s rows alternating. FPS is the mean of the last 10[present]windows, GPU busy and idle gaps per frame over the last 8.main452494439The gain is GPU time only (-7.7 ms per frame, idle gaps unchanged), the same signature as on the three cards in the description. Write-back volume is unchanged (53.4 vs 55.6 GB of storage write-backs per 10 s, ~all of them retiled through the unit shadow on both sides); the difference is the per-window scratch copy this PR removes. 0 fatal, 0 wait timeouts.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T20:48:27Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-18T22:09:12Z.
Traces of the performance capture in the description (they open in ui.perfetto.dev):
main48d61f53b: aps5-trace-48d61f53b46f-9720.json.gz