TextureCache: Check for out-of-range partial copy rect after scaling

This commit is contained in:
Stenzek 2019-04-21 12:52:07 +10:00
parent 3791262d96
commit b09a0e1a60
1 changed files with 12 additions and 12 deletions

View File

@ -393,18 +393,6 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, u8* pale
dst_y = 0;
}
// If the source rectangle is outside of what we actually have in VRAM, skip the copy.
// The backend doesn't do any clamping, so if we don't, we'd pass out-of-range coordinates
// to the graphics driver, which can cause GPU resets.
if (static_cast<u32>(src_x) >= entry->native_width ||
static_cast<u32>(src_y) >= entry->native_height ||
static_cast<u32>(dst_x) >= entry_to_update->native_width ||
static_cast<u32>(dst_y) >= entry_to_update->native_height)
{
++iter.first;
continue;
}
u32 copy_width =
std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x);
u32 copy_height =
@ -429,6 +417,18 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, u8* pale
copy_height = g_renderer->EFBToScaledY(copy_height);
}
// If the source rectangle is outside of what we actually have in VRAM, skip the copy.
// The backend doesn't do any clamping, so if we don't, we'd pass out-of-range coordinates
// to the graphics driver, which can cause GPU resets.
if (static_cast<u32>(src_x + copy_width) > entry->GetWidth() ||
static_cast<u32>(src_y + copy_height) > entry->GetHeight() ||
static_cast<u32>(dst_x + copy_width) > entry_to_update->GetWidth() ||
static_cast<u32>(dst_y + copy_height) > entry_to_update->GetHeight())
{
++iter.first;
continue;
}
MathUtil::Rectangle<int> srcrect, dstrect;
srcrect.left = src_x;
srcrect.top = src_y;