fix(agc): hold a guest allocation lease while a queue stores idle results #6246
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6246"
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 screamm on 2026-10-15T07:07:15Z.
What
Once every queue has been idle for 50 ms, the queue 0 worker stores pending storage image results on its own (#3777, #4410). That store took no lease of the guest allocations, so a guest unmap could run alongside it, and the compare of memory outside the write watch (
StorageTexture::compareUntracked,Texture.cpp:2106) read memory the unmap had released: the driver forgets its cached page states only when the unmap's registry mutation ends (GuestAllocationsEnd→ForgetPages), after the memory is gone, soAccessible()still answered yes.StoreIdleResults(VulkanDevice.cpp:1916) now holds aGuestAllocationsAcquirelease under the GPU mutex, in the order the driver's other lease holders use. An unmap waits inGuestAllocationsRequireUnpinneduntil the store is done; a store that starts during an unmap waits for the mutation to end, finds the range no longer registered and drops its results through the existing path. One line in the driver plus a new GPU test,agc_driver_idle_store_over_unmap(about 1 s), which unmaps an untracked arena surface with a pending result while the GPU mutex is released; it faults at the same compare 3 of 3 without the lease and passes 3 of 3 with it.Title: ProsperoEden PPSA99008 (homebrew catalog, #1578), relinked with
--trap-sdk-syscall-stubsand run withoutapp0/eboot.bin. Its launcher cannot read its font, quits, and its GL driver unmaps its direct memory at0x200000000+0x14000000while both 1920x1080 color buffers there still have results pending. Onmaind92a8dad3, 3 of 3 cold runs:Order of events with
APS5_TRACE_MEMORY=1 APS5_TRACE_FLUSH=1:With this change the title exits with code 0 in 6 of 6 runs (3 cold, 3 traced) and logs
storage image 0x200000000+0x10e0000: memory no longer registered; 1 pending ranges droppedfor both images. Withapp0/eboot.binstaged the launcher shows its menu and renders at 59.9 FPS for 60 s with and without the change (3454 vs 3325 frames).For reviewers: the lease pins every registered range, so a guest unmap or heap free waits a few ms while an idle write-back runs. Write-backs on other workers that already run without a lease are unchanged. A guest that unmaps a surface and maps new memory at the same address before the idle store runs still gets the stale results written over the new memory; that was already the case and is not addressed here.
Tested
Windows 11 Pro 26220, Ryzen 7 5700X, NVIDIA RTX 4070 (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs, onmaind92a8dad3.agc_driver_idle_store_over_unmap: 3 of 3 pass with the change; 3 of 3 fault at the same address and frames against unfixedmain's driver.agc_driver_store_idle_results,agc_driver_store_over_untracked: 3 of 3.agc_driver_*andvideo_out_flip*: 440 of 440 passed, 12 skipped.ctest -j8 --timeout 120 -E "^agc_driver_|^video_out_flip": 811 of 814 passed, 2 skipped;hardware_oracle_comparetimed out under load and passes alone in 8.7 s.python tools/check_conventions.py --base main,git diff --check: pass.agc_driver_idle_store_over_unmap3 of 3 pass with the change on both GPUs and crashes 3 of 3 without it on both.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:25Z.
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/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppImported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-17T13:10:14Z.
Intel and AMD Windows data: the new test passes on both GPUs with this change and crashes on both without it, as on the RTX 4070.
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. "Without" means this PR's test files onmainc9e6c45de, with none of its other changes.e3ce9bac0merged intomain673f7406c:agc_driver_idle_store_over_unmap, ×3SegFault)Full CTest (
--parallel 4) onmainc9e6c45dewith seven open GPU PRs merged (#6258, #6657, #6324, #6246, #6174, #6360, #6598): UHD 770 1381 of 1389, RX 9070 XT 1383 of 1389.mainalone passes 1378 of 1385 and 1381 of 1385. The merge adds only two failures:agc_buffer_pool(#6174, both GPUs) andagc_driver_indirect_dispatch_limit(#6360, RX 9070 XT).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-18T11:55:09Z.
Thanks @savvaniss for the Intel UHD 770 and RX 9070 XT runs, including the without-fix crash on both. I added them to Tested and GPUs tested, and added the
Fixes: noneline the template now asks for. @oneandonlydean, thelinuxandwindowsCI jobs were skipped on this PR's runs; could a full CI run be dispatched one3ce9bac0when you have time?