diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 88268de22c..4b3aaa0605 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -1523,8 +1523,12 @@ namespace rsx allocate_rsx_memory(Traits::get(sink)); // Replace with the new one - ensure(copy.target == Traits::get(sink)); + auto new_surface = Traits::get(sink); + ensure(copy.target == new_surface); data.emplace(surface->get_memory_range(), std::move(sink)); + + // Force barrier to reduce VRAM pressure + new_surface->memory_barrier(cmd, rsx::surface_access::memory_read); } }; diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index 47f59381bb..432e8c7e87 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "VKGSRender.h" #include "vkutils/buffer_object.h" +#include "vkutils/memory.h" #include "Emu/RSX/Overlays/overlay_manager.h" #include "Emu/RSX/Overlays/overlay_debug_overlay.h" #include "Emu/Cell/Modules/cellVideoOut.h" @@ -973,7 +974,22 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info) if (active_res_scaling_config != this->resolution_scaling_config) { + // First, try to reclaim any memory since the res scale upgrade is so memory intensive + if (const auto severity = vk::vmm_determine_memory_load_severity(); + severity > rsx::problem_severity::low && m_rtts.handle_memory_pressure(*m_current_command_buffer, severity)) + { + flush_command_queue(true); + } + + // Then apply the change m_rtts.sync_scaling_config(*m_current_command_buffer, active_res_scaling_config); this->resolution_scaling_config = active_res_scaling_config; + + // Finally reclaim any unused resources + if (const auto severity = vk::vmm_determine_memory_load_severity(); + severity > rsx::problem_severity::low && m_rtts.handle_memory_pressure(*m_current_command_buffer, severity)) + { + flush_command_queue(true); + } } }