From 0e320d17c1a5254d8c28b98ffaef2cffd0a1a597 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 28 Jan 2022 17:39:45 +0300 Subject: [PATCH] vk: Fix 'grow' behavior when we reach the size limit - Just swap out the current heap ptr and spawn a fresh one. Chances are, we can spare 1GB of host memory. --- rpcs3/Emu/RSX/VK/vkutils/data_heap.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/vkutils/data_heap.cpp b/rpcs3/Emu/RSX/VK/vkutils/data_heap.cpp index 21d96064a0..826b7a268c 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/data_heap.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/data_heap.cpp @@ -51,22 +51,24 @@ namespace vk bool data_heap::grow(usz size) { - // Create new heap. All sizes are aligned up by 64M, upto 1GiB - const usz size_limit = 1024 * 0x100000; - const usz aligned_new_size = utils::align(m_size + size, 64 * 0x100000); - - if (aligned_new_size >= size_limit) - { - // Too large - return false; - } - if (shadow) { // Shadowed. Growing this can be messy as it requires double allocation (macOS only) + rsx_log.error("[%s] Auto-grow of shadowed heaps is not currently supported. This error should typically only be seen on MacOS.", m_name); return false; } + // Create new heap. All sizes are aligned up by 64M, upto 1GiB + const usz size_limit = 1024 * 0x100000; + usz aligned_new_size = utils::align(m_size + size, 64 * 0x100000); + + if (aligned_new_size >= size_limit) + { + // Too large, try to swap out the heap instead of growing. + rsx_log.error("[%s] Pool limit was reached. Will attempt to swap out the current heap.", m_name); + aligned_new_size = size_limit; + } + // Wait for DMA activity to end g_fxo->get().sync();