fix(agc): avoid host allocations when returning slab slots #6943
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6943"
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 Ondra97 on 2026-10-16T20:41:41Z.
What
Returning a slot to a full buffer slab can grow
Slab::availableinsidenoexceptcleanup. Host allocation failure can therefore also break resource release.Count all live blocks in each slab class and reserve return-list capacity before publishing another block, including full blocks. Decrement the count when an empty block is retired or reclaimed. Returning a slot then needs no new C++ allocation.
Rebased onto
mainatc9e6c45de9ccccc4f714e153252a8fa48efbf367; head5001f87bc97e95335dcb45a59ed0818691ec7e0e. Prerequisites #6882 and #6452 are merged; this PR now contains only the slab-return fix and its regression tests. The test dispatcher also preserves the small-device mode added by merged #7056. Range-diff review found only the required dispatcher adaptation; the production patch is unchanged. Manual inspection of the remaining shared-file PRs found no equivalent return-path fix.Tested
Release builds,
BUILD_TESTING=ON, SPIRV-Tools disabled. Fresh validation below targets the rebased head above.Windows (native host)
AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742, Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7.
relinker,libs) and all selected test executables: passed, using--parallel 2.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andANYPS5_GPU=NVIDIA GeForce RTX 4070 Ti SUPER.--slab-return-deviceand--slab-return-hostprobes passed in the CPU and NVIDIA fixtures, each completing 26 protected returns per memory type.Linux (VirtualBox)
Ubuntu 24.04.5 LTS, kernel 7.0.0-38-generic, GCC 13.3.0, 4 vCPU and 8 GiB assigned RAM, VirtualBox 7.2.20r175154 on the Windows host above. Graphics: not exercised.
relinker,libs) and GPU-fixture compilation: passed. The selected CPU executables andagc_driver_pooled_buffer_range_testswere built with--parallel 2.--slab-return-deviceand--slab-return-hostprobes also passed, each completing 26 protected returns.Conventions, whitespace, test registration and clean-main integration checks passed on both Windows (native host) and Linux (VirtualBox).
Historical regression comparison — original revisions
The following measurements are from the original validation, not new measurements of the rebased head. Original production base:
ea4cc112a04e6144740756bcd6494bbab5377331; original fixed head:42fb6584d43c6a49332adb56d7b8cc1516ce5b95.On the same Windows host above, the regression filled 512 KiB slots across 4, 6 and 3 blocks, armed failure of the next C++ allocation during returns, then checked reuse without loss or duplication, live mapped siblings and empty-block retirement. Injection targeted host metadata without exhausting physical memory. The base failed in the first return batch; the fix completed 26 protected returns per memory type.
Both
agc_buffer_pool_tests.exeandagc_driver_pooled_buffer_range_tests.exeused--slab-return-deviceand--slab-return-host. NVIDIA probes identified vendor0x10de, device0x2705, and exercised Vulkan allocation, mapping and cleanup. This establishes the synthetic cleanup regression; no retail-title run or FPS measurement was performed.Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation.
Native/bare-metal Linux was not tested.
Native Linux GPU validation: not tested.
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-16T20:53:34Z.
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/include/BufferPool.hppcore/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cppcore/libs/prx/libSceAgcDriver/tests/BufferPool.cppcore/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hppcore/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hppcore/libs/prx/libSceAgcDriver/tests/execution/PooledBufferRange.cppcore/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hppcore/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cppcore/libs/prx/libSceAgcDriver/tests/BufferPool.cppImported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T09:21:43Z.
AMD / Windows run of this PR at 42fb6584d: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.
agc_buffer_pool: pass (slab metadata failures checked: 4, 0.12 s)agc_driver_pooled_buffer_range: pass (slab metadata total leaked bytes=0, 0.19 s)AI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T14:21:34Z.
Checked the invariant
available.capacity() >= blocksacross TakeSlot, PutSlot and trim: full blocks are no longer a hidden growth point in thenoexceptreturn path. The new test fails on main (returning 4 full blocks growsavailableunder the allocation-failure countdown) and covers device and host memory types; merged.