Merge pull request #10106 from phire/fix-negative-efb-copies

BPStructs: Ignore malformed efb copies
This commit is contained in:
JMC47 2021-09-16 21:04:03 -04:00 committed by GitHub
commit 2d1ec6332b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(), WARN_LOG_FMT(VIDEO, "Oversized EFB copy: {}x{} (offset {},{} stride {})", srcRect.GetWidth(),
srcRect.GetHeight(), srcRect.left, srcRect.top, destStride); 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. // 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.right = std::clamp<int>(srcRect.right, 0, EFB_WIDTH);
srcRect.bottom = std::clamp<int>(srcRect.bottom, 0, EFB_HEIGHT); srcRect.bottom = std::clamp<int>(srcRect.bottom, 0, EFB_HEIGHT);