fix(agc): release pooled buffers and image mirrors before the device #849
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/849"
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 meh7an on 2026-10-06T09:37:52Z.
What
Closing a title crashes in the device teardown:
Driver::Shutdowndestroys theVulkanDevice,State::~StatecallsvkDestroyDevice, and only then are the members it still holds destroyed. One of them ispatternBuffers, the cache of non-uniform fill pattern buffers. TheirDeviceBufferdestructors then destroy buffers and free memory of a device that no longer exists.Two other holders keep buffers of the device past
vkDestroyDevicein the same way:copiedWriters, theShaderResourcesof dispatches whose copied buffers are listed, is also aStatemember.Mirrors()in GuestBufferMemory.cpp) are a function-local static, so their buffers live until static destruction.The teardown now clears
copiedWritersbefore the resource cache, and drops the image mirrors and the pattern buffers right after the cached textures, while the buffer pool and the device still exist.ClearImageMirrorsempties the registry for the given device and destroys the mirrors after releasing its lock.Tested
Windows 11, MinGW GCC 15.2, RTX 2080 Ti, Sonic Origins Plus (PPSA05324), closing the window with
WM_CLOSEon the main menu:0xc0000005in nvoglv64 underDeviceBuffer::release<-DeviceBuffer::~DeviceBuffer<-VulkanDevice::~VulkanDevice<-Driver::Shutdown, called from the VideoOut thread.WM_CLOSE, without a crash report.Both runs used my working branch (this change on top of other driver work). This branch builds on Windows and the 165 agc driver, recompiler and execution test targets pass.
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)