perf(agc): present and keep pending only the drawn slice of an array color target #4935
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4935"
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 nicolasabosch on 2026-10-13T05:27:24Z.
What
A title whose color target is one slice of an array image (
CB_COLOR_VIEWslice of a surface with several slices) now presents from that image and keeps only the slice it drew pending. Before, the whole array image was treated as one unit in two places:ResidentPresentablerefused any pending image with more than one layer, so every flip of such a display buffer went through guest memory: the frame's results were stored, 33 MB were read back and uploaded again, with the GPU mutex held.ResidentPresentSlicenow finds the slice whose bytes are the display buffer, and the blit, the converted path (GpuColorTransfer::DetileImage) and the frame dump read that layer. The pending image is looked up withStorageTexture::FindPendingSlice, which also finds an array image that contains the display buffer past its first slice;FindPendingonly matches an image that starts at the display buffer's address, so alone it served slice 0 only. Only an image the range is exactly one slice of counts, and a range that is a slice of more than one pending array image throws (is a slice of the pending array images ...: which one holds its results is not modeled).StorageTexture::MarkDirtymarked every tracked layer or 64 KiB unit of the target pending. Memory under slices no draw rendered then counted as holding GPU results: any buffer or shader capture over it stored those units back and the next draw waited for the GPU.MarkSliceDirtymarks the units of the rendered slice only. It falls back toMarkDirtyfor volumes, single-layer images and DCC-compressed targets.No change for single-layer targets.
Tested
Windows 11, NVIDIA RTX 4070 Laptop GPU, WinLibs GCC 15.2.0 r7, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=ON. Tests ate7d9ff8ffonmain7e181fcc3; the title runs and traces are from9d53a588f, before the lookup by containment was added, and were not repeated.agc_slice_dirty: clears the two slices of a linear and of a tiled 128x128 array image to different colors, marks slice 0 and stores; slice 0 holds its color and the memory of slice 1 is untouched; after marking slice 1 it is stored too. With the whole image marked instead, the test fails. With slice 0 pending it also checks the lookup presentation uses: a display buffer that is slice 0 or slice 1 finds the image throughFindPendingSliceandResidentPresentSlicenames that layer,FindPendingdoes not find slice 1, and a range past the last slice finds nothing. With two images over the same memory pending, the lookup of slice 1 throws.agc_resident_present(the existing resident presentation tests, which no CTest entry ran): the slice decision (ResidentPresentSlice) and the converted path reading layers 1 and 2 of an array image; with the layer ignored inDetileImageit fails.ctest -j 8: 1037 passed, 8 skipped, 0 failed, out of 1045.VulkanDevice::PresentDisplayBuffer. No test presents to a swapchain (nothing undertestscalls it, and thevideo_out_flip_*tests are skipped here), and this title's display buffers start at their image's address, so its runs exercise slice 0 only.main7e181fcc3. Performance traces (APS5_TRACE_FRAMES=300:600), menu screen, 45 draws per frame:buffer descriptor uses an unsupported typeOn the older
maine51428bf2, where #4820 alone did run, two traces of 200 presents had a p50 of 39.2 and 48.1 ms, with 9.6 to 10 ms per frame inVulkan.Present.pixel_uploadand 7.4 to 8 ms of draws waiting for the GPU mutex; with only the presentation change the p50 was 18.9 ms and the p90 42 ms.Summary lines (
aps5-summary.jsonl). There is none formainitself: the title does not draw without #4820. Before, #4820 ate7cf856f0onmaine51428bf2,APS5_TRACE_FRAMES=150:200:After, #4820 and
9d53a588fmerged locally withmain7e181fcc3(commitab8f91d0e6cb),APS5_TRACE_FRAMES=300:600:The two sets are not the same window or the same
main, so they compare the order of magnitude, not exact numbers.APS5_DUMP_FRAMESafter both changes shows the title's menu with its game thumbnails.maindacd78525, three 60 s runs per build of the same title: with #4820 alone the title's own mean frame time over frames 1 to 600 is 83.41 to 85.76 ms; with this change as well it is 41.46 to 45.43 ms, and 38.81 to 40.05 ms over frames 601 to 1200 (max 84 ms). So the frame time halves there but stays near 40 ms, not 16.7 ms; what limits it on that GPU was not investigated. #4820 alone did not stop in those runs.Not tested here: Linux, AMD and Intel GPUs, lavapipe, other titles, and why #4820 alone stops here on
main7e181fcc3(not investigated; it does not stop with this change, and it did not stop on the Radeon 860M on a latermain). The AMD result above is the reporter's own.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-13T05:33:40Z.
Me volvi loco con esta mierda, horas de laburo espero sirva de algo
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T09:42:01Z.
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main
2a2a3dc65together with nine other open GPU PRs (their own commits applied, no merge commits; one further PR, #5024, conflicted with them and was left out), so only the tests that belong to this PR say something about it:tests/Recorder.cpp(targetagc_driver_recorder_tests;agc_pipeline_cache,agc_pipeline_cache_file,agc_pipeline_library,_off,_fast_only,agc_unchanged_cpu_stamps,agc_storage_*,agc_recorder_read_list,agc_host_import_unmapand the other tests of that target): 3 of 3 runs passed for each.Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T23:06:03Z.
StorageTexture::FindPendingonly returns an image whose base address is the display buffer's (Texture.cpp:3061), so a display buffer in slice 1 or later never reachesResidentPresentSliceand still goes through guest memory. The new test callsResidentPresentSlicedirectly, so it doesn't catch this. Please find the image by containment and present slice 1 throughPresentDisplayBufferin the test, or say in the description that only slice 0 is served.Please also add the
GPUs testedline and the summary lines of the traces you compared. And what makesbuffer descriptor uses an unsupported typego away with this change on7e181fcc3?Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-13T23:26:40Z.
@oneandonlydean you are right, thank you.
FindPendingonly matches an image that starts at the display buffer's address, so at9d53a588fonly slice 0 was served and a display buffer in a later slice still went through guest memory.71c74b10daddsStorageTexture::FindPendingSlice: the lookup by base address first, then an array image that contains the range past its first slice.PresentableResidentuses it, andResidentPresentSlicestill decides whether the range is exactly one slice.agc_slice_dirtynow checks, on a pending two-slice image (linear and tiled), that a display buffer that is slice 0 or slice 1 finds the image and gets that layer, thatFindPendingdoes not find slice 1, and that a range past the last slice finds nothing. It does not go throughPresentDisplayBuffer: no test in the tree presents to a swapchain, so I could not add that without a new harness. The description says so, and that this title only exercises slice 0.GPUs testedand the summary lines are in the description. There is no summary line formainitself, because the title does not draw without #4820; the "before" lines are #4820 alone on an oldermain. I can attach the trace files if you want them.buffer descriptor uses an unsupported typegoes away: I do not know. I did not trace it. My guess is that marking the whole array pending made the store-back write stale units of the slice no draw rendered over the memory where the title uploads its per-draw data, but that is unverified, and LeandroLP23's runs on a latermaindid not hit the stop without this change. The description lists it as not investigated.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T23:27:08Z.
Thanks, slice 1 finds its image now. If more than one pending array image contains the range,
FindPendingSlicereturns whichever it meets first; please throw there instead of picking one.Imported from boykopovar/AnyPS5. Originally posted by nicolasabosch on 2026-10-13T23:41:00Z.
@oneandonlydean done in
e7d9ff8ff:FindPendingSlicethrows when the range is a slice of more than one pending array image. It also only counts an image the range is exactly one slice of, so an image that merely contains the range no longer hides the one it is a slice of.agc_slice_dirtymarks two images over the same memory pending and checks the throw.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:42:19Z.
Rebased onto main after #5311: its one-pass present now takes the drawn slice, so a display buffer in slice 1 or later presents through it too.
agc_driver_presentation_passnow presents each slice of a two-slice image through the pass and checks it, and its frame dump, against the convert path.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T04:51:54Z.
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/CMakeLists.txtL1003, L1005core/libs/prx/libSceAgcDriver/CMakeLists.txtL1005core/libs/prx/libSceAgcDriver/CMakeLists.txtL1003, L1005core/libs/prx/libSceAgcDriver/CMakeLists.txtL1005core/libs/prx/libSceAgcDriver/CMakeLists.txtL1003, L1005core/libs/prx/libSceAgcDriver/CMakeLists.txtL1003, L1005