diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 2cc3303bc..accf1791e 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -113,14 +113,15 @@ namespace rsx } } - const bool is_new_surface = !sink; - Traits::clone_surface(cmd, sink, region.source, new_address, region); - - if (is_new_surface) + if (sink) { - allocate_rsx_memory(Traits::get(sink)); + // Memory requirements can be altered when cloning + free_rsx_memory(Traits::get(sink)); } + Traits::clone_surface(cmd, sink, region.source, new_address, region); + allocate_rsx_memory(Traits::get(sink)); + if (invalidated) [[unlikely]] { // Halfplement the merge by crude inheritance. Should recursively split the memory blocks instead. @@ -509,9 +510,9 @@ namespace rsx } new_surface = Traits::get(new_surface_storage); - allocate_rsx_memory(new_surface); Traits::invalidate_surface_contents(command_list, new_surface, address, pitch); Traits::prepare_surface_for_drawing(command_list, new_surface); + allocate_rsx_memory(new_surface); break; } }