From 9dc06cef7fb8482d15483904157fec99a574f786 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 1 Sep 2019 17:20:52 +0300 Subject: [PATCH] rsx: Do not include ro data when attempting to do section merge - Avoids crazy situations like trying to merge from a 3d or cubemap in memory --- rpcs3/Emu/RSX/Common/texture_cache.h | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 71784a623f..d24c87c9e7 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -2059,8 +2059,7 @@ namespace rsx else { // Check shader_read storage. In a given scene, reads from local memory far outnumber reads from the surface cache - const u32 lookup_mask = (is_compressed_format) ? rsx::texture_upload_context::shader_read : - rsx::texture_upload_context::shader_read | rsx::texture_upload_context::blit_engine_dst | rsx::texture_upload_context::blit_engine_src; + const u32 lookup_mask = rsx::texture_upload_context::shader_read | rsx::texture_upload_context::blit_engine_dst | rsx::texture_upload_context::blit_engine_src; auto lookup_range = tex_range; if (LIKELY(extended_dimension <= rsx::texture_dimension_extended::texture_dimension_2d)) @@ -2074,7 +2073,9 @@ namespace rsx } } - const auto overlapping_locals = find_texture_from_range(lookup_range, tex_height > 1? tex_pitch : 0, lookup_mask); + auto overlapping_locals = find_texture_from_range(lookup_range, tex_height > 1? tex_pitch : 0, lookup_mask); + + // Search for exact match if possible for (auto& cached_texture : overlapping_locals) { if (cached_texture->matches(texaddr, format, tex_width, tex_height, depth, 0)) @@ -2087,6 +2088,28 @@ namespace rsx // Blit sources contain info from any shader-read stuff in range // NOTE: Compressed formats require a reupload, facilitated by blit synchronization and/or WCB and are not handled here + if (!overlapping_locals.empty()) + { + if (tex.get_exact_mipmap_count() > 1 && !linear) + { + // Investigate if this is possible; it can work for disjoint sections, but the gather code cannot handle this at the moment + LOG_TODO(RSX, "Mipmap gather of swizzled texture requested but not implemented"); + overlapping_locals.clear(); + } + else + { + // Remove everything that is not a transfer target + overlapping_locals.erase + ( + std::remove_if(overlapping_locals.begin(), overlapping_locals.end(), [](const auto& e) + { + return (e->get_context() != rsx::texture_upload_context::blit_engine_dst); + }), + overlapping_locals.end() + ); + } + } + const auto bpp = get_format_block_size_in_bytes(format); const auto overlapping_fbos = m_rtts.get_merged_texture_memory_region(cmd, texaddr, tex_width, required_surface_height, tex_pitch, bpp, rsx::surface_access::read);