From 6bf5b9a8e3c4c17475a004a0dd50eabeedd186dd Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 27 Feb 2023 14:29:47 +1000 Subject: [PATCH] GS/HW: Fix incorrect size of region mipmap levels --- pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index ef019a66f9..15143a2dc0 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -4056,17 +4056,18 @@ GSVector4i GSTextureCache::SourceRegion::GetOffset(int tw, int th) const GSTextureCache::SourceRegion GSTextureCache::SourceRegion::AdjustForMipmap(u32 level) const { + // Texture levels must be at least one pixel wide/high. SourceRegion ret = {}; if (HasX()) { const u32 new_minx = GetMinX() >> level; - const u32 new_maxx = ((GetMaxX() - 1) >> level) + 1; + const u32 new_maxx = std::max(GetMaxX() >> level, new_minx + 1); ret.SetX(new_minx, new_maxx); } if (HasY()) { const u32 new_miny = GetMinY() >> level; - const u32 new_maxy = ((GetMaxY() - 1) >> level) + 1; + const u32 new_maxy = std::max(GetMaxY() >> level, new_miny + 1); ret.SetY(new_miny, new_maxy); } return ret;