perf(agc): read a fast-cleared surface's guest bytes only when the import is compared #2699
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2699"
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 alfalfa-star on 2026-10-10T11:21:38Z.
What
#2096 keeps a copy of a storage image's guest bytes so that
Refreshcan compare memory the write watch doesn't cover. Its host-import upload path takes that copy only when the range is unwatched (GuestMemory::Watched). The DCC fast-clear path, however, takes it on every upload:originalValid = falsebecame an unconditionalcaptureGuestBytes(nullptr).Reading the whole surface goes through the flush hook. For a surface a unit shadow covers, every 64 KiB block records a publish and waits for the GPU (
FlushForAccess→PublishShadowsOnly→SyncThrough). Stack from PPSA14632, sampled at those waits:Driver::dispatch→ShaderResources::Revalidate→cachedStorageTexture→StorageTexture::Refresh→upload→captureGuestBytes→ReadCommitted→FlushForAccess.The clear path now resolves the surface's host import first, because creating it can unwatch the range (a compared host-pointer import does). It takes the copy only when the range is unwatched after that, like the import path. Write-watched memory, such as Linux direct memory behind a dma-buf import (which keeps write protection), skips the read. A range that becomes unwatched only later re-uploads instead of comparing, as it did before #2096.
agc_driver_dcc_keys_first_writenow checks that a fast-cleared upload keeps the copy exactly when its range is unwatched at that point. In the default run, the test block's host-pointer import is compared, so it covers the case #2096 needs. WithAPS5_WRITE_WATCH_IMPORTS=watchthe check fails without this change ("a fast-cleared upload of write-watched memory read its guest bytes"). That mode then stops at the existing "an unchanged pending image was uploaded again" check, onmainas well, so it isn't a ctest variant.Tested
Linux (Arch), RX 9070 XT, RADV, Release:
mainb5f5362dplus #861 (Linux guest arena, needed to boot it), udmabufsize_limit_mb1024. Values per 10 s, steady state:mainHow I narrowed it down: on that setup, the merge right before #639 (
2b297842) has about 230 such waits per 10 s, and #2347, the first later merge that boots the title, has about 61,900. Reverting #425, #1309's backing write, #1310, #1410/#1411 or #2575 onmaindidn't change the count. The stack above leads to this line.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-10T15:57:40Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
4f9ddffc, merged ontomain57f96fd2bin one build with 4 other new PRs.agc_driver_dcc_keys_first_write.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-10T16:23:36Z.
The one failing job,
write-watch (macos-15-intel), is a 30 s timeout inwrite_watch_threads. This PR only changeslibSceAgcDriver(Texture.cpp/.hppand its test), which that job does not build, and the same job passed on the 10 other recent runs I checked. Could someone with rights rerun it?Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-10T16:37:31Z.
Tested on Windows with a second title, Hollow Knight: Silksong (PPSA12544).
Setup: Windows 11 Pro (26300), i7-11800H, RTX 3060 Laptop (driver 617.42), WinLibs GCC 15.2.0 r7, Release.
mainde5e541d+ #846 (Silksong needs it for its plugins), with and without this PR merged on top. Each run used the same scripted input for 250 s (title menu, New Game, the opening, into Moss Grotto) withAPS5_PROFILE_DRAW=1.Guest memory reads (
[guestmem] read, cumulative at about 180 s):main, run 1main, run 2main+ #2791 (control)main+ #2792 (control)main+ this PROver the whole 250 s, reads went from 99,548 MiB in 14.7 s to 14,470 MiB in 3.3 s.
WaitForKeyWriters(DCC keys), not from this path.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:43:26Z.
Checked the diff, the build and ctest of libSceAgcDriver on Linux (
agc_driver_dcc_keys_first_writepasses), and the Windows runs from @popcoder565 and @orbz22. The only red job iswrite-watch (macos-15-intel), a timeout in a job that doesn't build this code; I re-ran it. Merging once it is green.