From ff74c241c7a359c183fb88bba5d3d4cdfe445ee2 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 11 Apr 2020 13:07:37 +0300 Subject: [PATCH] rsx: Fix get_optimal_blit_target_properties for local memory --- rpcs3/Emu/Cell/lv2/sys_rsx.h | 5 +++++ rpcs3/Emu/RSX/Common/texture_cache_helpers.h | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.h b/rpcs3/Emu/Cell/lv2/sys_rsx.h index 3edb8b0c38..6e4285f62e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.h +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.h @@ -117,6 +117,11 @@ struct RsxDisplayInfo be_t pitch; be_t width; be_t height; + + bool valid() const + { + return height != 0u && width != 0u; + } }; struct lv2_rsx_config diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index 1451646062..22f88ee665 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -189,13 +189,21 @@ namespace rsx for (u32 i = 0; i < renderer->display_buffers_count; ++i) { const auto& buffer = renderer->display_buffers[i]; - const u32 pitch = buffer.pitch? static_cast(buffer.pitch) : g_fxo->get()->get_bpp() * buffer.width; + + if (!buffer.valid()) + { + continue; + } + + const u32 bpp = g_fxo->get()->get_bpp(); + + const u32 pitch = buffer.pitch ? +buffer.pitch : bpp * buffer.width; if (pitch != dst_pitch) { continue; } - const auto buffer_range = address_range::start_length(rsx::constants::local_mem_base + buffer.offset, pitch * buffer.height); + const auto buffer_range = address_range::start_length(rsx::get_address(buffer.offset, CELL_GCM_LOCATION_LOCAL, HERE), pitch * (buffer.height - 1) + (buffer.width * bpp)); if (dst_range.inside(buffer_range)) { // Match found