From 7025985c0d2b07dac2919fdbb2fa4ada0fe4fd7f Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 14 Mar 2020 23:23:19 +0300 Subject: [PATCH] rsx: Improve section scanning when updating surface cache resources in blit engine. --- rpcs3/Emu/RSX/Common/texture_cache.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index fc0bfc46ed..66805420bf 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -2681,13 +2681,27 @@ namespace rsx // Reset this object's synchronization status if it is locked lock.upgrade(); - if (const auto found = find_cached_texture(dst_subres.surface->get_memory_range(), 0, false, false)) + if (const auto found = find_cached_texture(dst_subres.surface->get_memory_range(), RSX_GCM_FORMAT_IGNORED, false, false)) { if (found->is_locked()) { - verify(HERE), found->is_flushable(); - found->touch(m_cache_update_tag); - update_cache_tag(); + if (found->get_rsx_pitch() == dst.pitch) + { + // It is possible for other resource types to overlap this fbo if it only covers a small section of its max width. + // Blit engine read and write resources do not allow clipping and would have been recreated at the same address. + // TODO: In cases of clipped data, generate the blit resources in the surface cache instead. + if (found->get_context() == rsx::texture_upload_context::framebuffer_storage) + { + found->touch(m_cache_update_tag); + update_cache_tag(); + } + } + else + { + // Unlikely situation, but the only one which would allow re-upload from CPU to overlap this section. + verify(HERE), !found->is_flushable(); + found->discard(true); + } } }