diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index ac677ddcd0..55c2584344 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -403,6 +403,9 @@ namespace rsx bool do_intersection_test = true; bool store = true; + // Workaround. Preserve new surface tag value because pitch convert is unimplemented + u64 new_content_tag = 0; + address_range *storage_bounds; surface_ranged_map *primary_storage, *secondary_storage; if constexpr (depth) @@ -425,16 +428,27 @@ namespace rsx surface_storage_type &surface = It->second; const bool pitch_compatible = Traits::surface_is_pitch_compatible(surface, pitch); + if (!pitch_compatible) + { + // This object should be pitch-converted and re-intersected with + if (old_surface_storage = Traits::convert_pitch(command_list, surface, pitch)) + { + old_surface = Traits::get(old_surface_storage); + } + else + { + // Preserve content age. This is hacky, but matches previous behavior + // TODO: Remove when pitch convert is implemented + new_content_tag = Traits::get(surface)->last_use_tag; + } + } + if (Traits::surface_matches_properties(surface, format, width, height, antialias)) { - if (!pitch_compatible) + if (old_surface) { - // This object should be pitch-converted and re-intersected with - if (old_surface_storage = Traits::convert_pitch(command_list, surface, pitch)) - { - old_surface = Traits::get(old_surface_storage); - Traits::invalidate_surface_contents(command_list, Traits::get(surface), address, pitch); - } + ensure(!pitch_compatible); + Traits::invalidate_surface_contents(command_list, Traits::get(surface), address, pitch); } Traits::notify_surface_persist(surface); @@ -556,6 +570,11 @@ namespace rsx if (do_intersection_test) { + if (new_content_tag) + { + new_surface->last_use_tag = new_content_tag; + } + intersect_surface_region(command_list, address, new_surface, old_surface); } diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index 20f737dc8b..77e32f34b6 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -242,6 +242,7 @@ struct gl_render_target_traits { // TODO src->set_rsx_pitch(static_cast(out_pitch)); + src->state_flags = rsx::surface_state_flags::erase_bkgnd; return {}; } diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index a06bc81643..f966830a43 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -336,6 +336,7 @@ namespace vk { // TODO src->rsx_pitch = static_cast(out_pitch); + src->state_flags = rsx::surface_state_flags::erase_bkgnd; return {}; }