Avoid a potential divide by zero.

This commit is contained in:
Unknown W. Brackets 2015-04-08 11:44:45 -07:00
parent 8a3a67dc5b
commit 10626e356d
3 changed files with 3 additions and 3 deletions

View File

@ -590,7 +590,7 @@ void FramebufferManagerCommon::FindTransferFramebuffers(VirtualFramebuffer *&dst
}
if (match) {
dstYOffset = yOffset;
dstXOffset = (byteOffset / bpp) % dstStride;
dstXOffset = dstStride == 0 ? 0 : (byteOffset / bpp) % dstStride;
dstBuffer = vfb;
}
}

View File

@ -364,7 +364,7 @@ bool TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, Virtu
const u32 bitOffset = (texaddr - addr) * 8;
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
fbInfo.yOffset = pixelOffset / entry->bufw;
fbInfo.yOffset = entry->bufw == 0 ? 0 : pixelOffset / entry->bufw;
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
if (framebuffer->fb_stride != entry->bufw) {

View File

@ -357,7 +357,7 @@ bool TextureCache::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualF
const u32 bitOffset = (texaddr - addr) * 8;
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
fbInfo.yOffset = pixelOffset / entry->bufw;
fbInfo.yOffset = entry->bufw == 0 ? 0 : pixelOffset / entry->bufw;
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
if (framebuffer->fb_stride != entry->bufw) {