fix(agc): keep resident linear color target results pending on the GPU #9276
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9276"
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 KarthikeyaAnna on 2026-10-21T17:17:51Z.
What
Keep resident linear color target results pending on the GPU until explicitly accessed, presented, or idle, matching the behavior of tiled resident targets.
PR #6892 added a resident image for linear color targets over imported memory, but
keepRecordedDrawunconditionally calledStorageTexture::FlushPendingafter every single draw. In titles such as METAL GEAR SOLID Master Collection Vol. 1 (PPSA14363) whose PS1 emulator draws into three 24 MiB linear targets with up to 80 draws per frame, this forced thousands of unnecessary whole-target write-backs over PCIe (72-76 GB per 10 s) and repeated pending-write synchronizations, dropping framerates from 60 to 10 FPS (#9217). Furthermore, eager per-draw whole-target write-backs could overwrite CPU stores made afterDrawreturned (#8152).Resident linear targets now keep their drawn results pending on the GPU rather than flushing eagerly on every draw. They are stored to guest memory as needed by existing access paths, waits, flips, and idle stores.
Expands
tests/execution/LinearTargetResident.cppwith 15 comprehensive edge-case tests:ExpectSingleDraw).ExpectConsecutiveDraws).ExpectDrawAcrossBatches).ExpectMultipleSequentialDraws).StoreIdleResults) flushing pending storage textures to guest memory (ExpectStoreIdleResults).GuestMemory::Writepreserved alongside preceding and subsequent draws (ExpectCpuWritesWithGuestMemory).ExpectDirectCpuWriteAfterDraw).VK_ATTACHMENT_LOAD_OP_LOADand GPU blend math (ExpectAdditiveBlending).colorWriteMask) preserving unmasked channels without corruption (ExpectColorWriteMask).ExpectOverlappingScissors).ExpectMultipleLinearTargets).ExpectPartialGuestRead).ExpectEmptyScissorDraw).ExpectTargetReallocationWithoutRead).ExpectDirectCpuInterleavedDraw).Tested
python3 tools/check_conventions.py --base origin/mainpasses with zero violations.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R agc_driver_linear_target_resident -Vpasses with 0 validation errors on NVIDIA GeForce RTX 2050 (Vulkan 1.3, driver 570.86.16).linear_display_bufferand related resident tests pass.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-21T17:18:05Z.
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 CnRJay on 2026-10-21T17:29:33Z.
Review: COMMENTED
The diagnosis in #9217 is a real cost (72-76 GB per 10 s of write-backs from a flush after every draw), but the change as submitted is one deleted loop in
keepRecordedDrawplus tests, and it moves the correctness burden to a place that can't carry it on every host.FlushPendingafter each draw was the guarantee that a CPU reader of a resident linear target sees the results. The description says the results are now stored "as needed by existing access paths, waits, flips and idle stores". Those paths are triggered by the write watch and the read hook. On Windows, host imports sit outside the write watch (that is the premise of #6960 and thedecideImportWatchrule), so a CPU read of the target's memory cannot be intercepted and nothing causes the store. For a PS1 emulator that draws into linear targets, the question is whether anything reads those targets back on the CPU (readback for effects, screenshots, savestates, its own VRAM view). Please say what a CPU read of an unwatched linear target does after this change, with a test for it on a host-imported (unwatched) block; the new cases build their memory withBlock, which followsWriteWatched(), and the description doesn't say that any of them runs over an unwatched import.aps5-summary.jsonllines of main and this PR from the same scene in PPSA14363, and the bytes written back per 10 s, per the Performance report form.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T17:49:03Z.
Some 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/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/execution/LinearTargetResident.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppPull request closed