fix(agc): save pending storage images before a partly watched import unwatches them #7687
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7687"
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 HamSyria on 2026-10-18T23:21:17Z.
What
GuestMemory::ImportWatchedran the unwatch hook (StorageTexture::SaveBeforeUnwatch) only for imports that leave the write watch. An import that stays watched over memory the watch covers only in part fails its write walk and unwatches the whole range, without the hook. Storage images with results pending in that range then had no saved guest bytes, and their store threwstoring storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented.The hook now also runs, before the import, when a stays-watched import is not fully covered by the watch. The debt entry for pending results outside the write watch names this case among the ones that save the bytes.
Tested
Windows 11 (10.0.26300), GCC 15.2.0 UCRT Release.
CheckPartlyWatchedImportSavesFirstinagc_write_tracking: unwatches the middle block of three, then imports all three withstaysWatched. Without the change the unwatch hook sees none of the watched blocks (0 calls) and the test fails; with it, it passes.ctest -R '^agc_'on this branch (rebased on main8b8edc561): 737 of 737 passed.a0f3dc401withAPS5_TEXTURE_CACHE_MIB=7168-11264: it stopped on the error above after about 60 s, after a 0x18b74000-byte import at 0x11e128c000 withstaysWatchedandcovered=0. With the change it ran on past that point (180 s and more) without the error. Not yet repeated on this branch's main.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 github-actions[bot] on 2026-10-18T23:39:31Z.
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)docs/dev/debt/libSceAgcDriver.mdL95-96docs/dev/debt/libSceAgcDriver.mdL96docs/dev/debt/libSceAgcDriver.mdL96Some 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.
docs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T03:55:11Z.
Review: COMMENTED
Apple GPU / MoltenVK run. On macOS,
agc_write_trackingstops at an earlier check, soCheckPartlyWatchedImportSavesFirstnever runs there. Run on its own, it fails without the fix and passes with it.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head
3724e31d6, PR diff applied cleanly. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). Also in the same build: #7707, #7698, #7687, #7691 and #7705 (they touch different files and applied cleanly together), plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branchjotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704.agc_write_trackingalready fails on that tree before reaching the new check. It stops inCheckImportWindowwitha block the import window did not touch reads as written. The cause is how the macOS series'ImportWatchedopens the range on Apple, not this PR. The failure is the same with and without the PR, on both drivers.To reach the new check I patched the test locally to run only
CheckPartlyWatchedImportSavesFirst:GuestMemory.cppback to the base: fails 3 of 3 withthe watched blocks of a partly watched import left the watch without the unwatch hook seeing them (0 calls).So the fix also holds on the macOS path of
ImportWatched. Here the write watch reportshost imports resolve write protection: no, so imports stay watched.Full
^agcsuite with the stack: the base failures on each driver, plusagc_driver_pooled_buffer_rangeandagc_performance_overlay, which only run because of the loader patch. Nothing from this PR.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T09:35:09Z.
Intel and AMD Windows data: with this PR's test changes,
agc_write_trackingfails onmainand passes with the PR, on an Intel UHD 770 and an AMD RX 9070 XT.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head3724e31d6merged intomain6b8228b2b. "Without" means only this PR's diff totests/WriteTracking.cpp, applied tomain6b8228b2b.agc_write_trackingthe watched blocks of a partly watched import left the watch without the unwatch hook seeing them (0 calls)AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by HamSyria on 2026-10-19T16:47:19Z.
Closing as a duplicate of #6308, which fixes the same stop and covers more: it runs the unwatch hook whenever the write walk fails before the range is unwatched, while this PR only covered a stays-watched import over partly watched memory. #7505 takes a similar approach. I missed both when checking for overlap, sorry for the noise. For #6308: Marvel's Wolverine (PPSA03671) hits this stop on Windows with an RTX 5070 Ti, at a 0x18b74000-byte import at 0x11e128c000 with
staysWatchedandcovered=0.Pull request closed