diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index d10454675c..06e9798131 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -1230,11 +1230,6 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u if (!src || !dst || src->m_texture->GetScale() != dst->m_texture->GetScale()) return false; - // We don't want to copy "old" data that the game has overwritten with writes, - // so flush any overlapping dirty area. - src->UpdateIfDirtyIntersects(GSVector4i(sx, sy, sx + w, sy + h));; - dst->UpdateIfDirtyIntersects(GSVector4i(dx, dy, dx + w, dy + h)); - // Scale coordinates. const GSVector2 scale(src->m_texture->GetScale()); const int scaled_sx = static_cast(sx * scale.x); @@ -1244,6 +1239,15 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u const int scaled_w = static_cast(w * scale.x); const int scaled_h = static_cast(h * scale.y); + // The source isn't in our texture, otherwise it could falsely expand the texture causing a misdetection later, which then renders black. + if ((scaled_sx + scaled_w) > src->m_texture->GetWidth() || (scaled_sy + scaled_h) > src->m_texture->GetHeight()) + return false; + + // We don't want to copy "old" data that the game has overwritten with writes, + // so flush any overlapping dirty area. + src->UpdateIfDirtyIntersects(GSVector4i(sx, sy, sx + w, sy + h)); + dst->UpdateIfDirtyIntersects(GSVector4i(dx, dy, dx + w, dy + h)); + // Expand the target when we used a more conservative size. const int required_dh = scaled_dy + scaled_h; if ((scaled_dx + scaled_w) <= dst->m_texture->GetWidth() && required_dh > dst->m_texture->GetHeight()) @@ -1259,11 +1263,8 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u } // Make sure the copy doesn't go out of bounds (it shouldn't). - if ((scaled_sx + scaled_w) > src->m_texture->GetWidth() || (scaled_sy + scaled_h) > src->m_texture->GetHeight() || - (scaled_dx + scaled_w) > dst->m_texture->GetWidth() || (scaled_dy + scaled_h) > dst->m_texture->GetHeight()) - { + if ((scaled_dx + scaled_w) > dst->m_texture->GetWidth() || (scaled_dy + scaled_h) > dst->m_texture->GetHeight()) return false; - } g_gs_device->CopyRect(src->m_texture, dst->m_texture, GSVector4i(scaled_sx, scaled_sy, scaled_sx + scaled_w, scaled_sy + scaled_h),