summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2019-04-21 12:52:07 +1000
committerStenzek <stenzek@gmail.com>2019-04-21 12:54:32 +1000
commitb09a0e1a603732dc91856418f874ac8033790f57 (patch)
tree4b9e99f688bcd56cc0c5e0182fefadacbbaaa73b /Source/Core/VideoCommon/TextureCacheBase.cpp
parent3791262d9610d711ed5e157951feedade1c2eb43 (diff)
TextureCache: Check for out-of-range partial copy rect after scaling
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index 0d4c599d3d..4e0d2547f2 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -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;