From 0d87d909c6460858e5bb1b77f04c1d527b6f4667 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 17 Jul 2021 00:36:30 +0300 Subject: [PATCH] vk: Fix double-spill for invalidated resources --- rpcs3/Emu/RSX/Common/surface_store.h | 1 + rpcs3/Emu/RSX/VK/VKRenderTargets.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 911ee11bf..b11ab7bc6 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -501,6 +501,7 @@ namespace rsx ensure(store); new_surface_storage = Traits::create_new_surface(address, format, width, height, pitch, antialias, std::forward(extra_params)...); new_surface = Traits::get(new_surface_storage); + Traits::prepare_surface_for_drawing(command_list, new_surface); allocate_rsx_memory(new_surface); } diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp index b2688d855..dad08ae73 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.cpp @@ -125,6 +125,12 @@ namespace vk // 1. Spill an strip any 'invalidated resources'. At this point it doesn't matter and we donate to the resolve cache which is a plus. for (auto& surface : invalidated_resources) { + if (!surface->value) + { + ensure(!surface->resolve_surface); + continue; + } + // Only spill anything with references. Other surfaces already marked for removal should be inevitably deleted when it is time to free_invalidated if (surface->has_refs() && (surface->resolve_surface || surface->samples() == 1)) { @@ -251,7 +257,8 @@ namespace vk { for (auto& surface : list) { - if (surface.second->value && !surface.second->is_bound) + // NOTE: Check if memory is available instead of value in case we ran out of memory during unspill + if (surface.second->memory && !surface.second->is_bound) { sorted_list.push_back(surface.second.get()); }