mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 13:39:58 -04:00
Try a smaller allocation before giving up on a texture upload when the video memory is used up.
On an integrated Radeon 890M the ASTC scratch buffer failed to allocate and then a staging buffer ended the run. The scratch asks for 32 MiB whatever the upload needs, and the staging pool grows only in 64 MiB blocks of one memory type. When the device reports it is out of memory, the scratch is now tried again at the size the upload needs, and a staging buffer that does not fit the pool is tried again outside it with the same mapping, where a smaller block or another host-visible type may still have room. The menu's own upload flushes what it wrote, since such a buffer may lie in memory that is not coherent. Built and run through the memory probe (96 GPU checks pass); the out-of-memory paths themselves were not reached here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -3679,6 +3679,12 @@ void *vk_staging(VkDeviceSize size, VkBuffer *buf, VmaAllocation *alloc) {
|
||||
VkBuffer b;
|
||||
VmaAllocation a;
|
||||
VkResult r = vmaCreateBuffer(c->vma, &bi, &aci, &b, &a, &info);
|
||||
if (r == VK_ERROR_OUT_OF_DEVICE_MEMORY && aci.pool) {
|
||||
// The staging pool can grow only in 64 MiB blocks of its one memory type. A smaller allocation may
|
||||
// still fit in a default block or another host-visible type. Keep the same mapping requirements.
|
||||
aci.pool = NULL;
|
||||
r = vmaCreateBuffer(c->vma, &bi, &aci, &b, &a, &info);
|
||||
}
|
||||
if (r != VK_SUCCESS) rt_fatal("vk: staging buffer of %llu bytes failed (%d)", (unsigned long long)size, (int)r);
|
||||
vk_texstat_add(VK_TS_STG_NEW, 1, bi.size);
|
||||
*buf = b;
|
||||
|
||||
Reference in New Issue
Block a user