BPStructs: Ignore malformed efb copies

This commit is contained in:
Scott Mansell 2021-09-17 12:39:06 +12:00
parent a0f7e3110d
commit 7c7609f5b9
1 changed files with 9 additions and 0 deletions

View File

@ -244,6 +244,15 @@ static void BPWritten(const BPCmd& bp)
WARN_LOG_FMT(VIDEO, "Oversized EFB copy: {}x{} (offset {},{} stride {})", srcRect.GetWidth(),
srcRect.GetHeight(), srcRect.left, srcRect.top, destStride);
if (u32(srcRect.left) >= EFB_WIDTH || u32(srcRect.top) >= EFB_HEIGHT)
{
// This is not a sane src rectangle, it doesn't touch any valid image data at all
// Just ignore it
// Apparently Mario Kart Wii in wifi mode can generate a deformed EFB copy of size 4x4
// at offset (328,1020)
return;
}
// Clamp the copy region to fit within EFB. So that we don't end up with a stretched image.
srcRect.right = std::clamp<int>(srcRect.right, 0, EFB_WIDTH);
srcRect.bottom = std::clamp<int>(srcRect.bottom, 0, EFB_HEIGHT);