From 3a97688804e964fab5871ab04ccabcc3010b5d9e Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Thu, 5 May 2022 22:22:02 -0500 Subject: [PATCH] GS: Fix TextureMinMax when coordinates are completely outside of min/max --- pcsx2/GS/GSState.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 5226b20ab8..9dfc454107 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -3275,9 +3275,9 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c case CLAMP_CLAMP: case CLAMP_REGION_CLAMP: if (vr.x < uv.x) - vr.x = uv.x; + vr.x = std::min(uv.x, vr.z - 1); if (vr.z > (uv.z + 1)) - vr.z = uv.z + 1; + vr.z = std::max(uv.z, vr.x) + 1; break; case CLAMP_REGION_REPEAT: if (UsesRegionRepeat(maxu, minu, uv.x, uv.z, &vr.x, &vr.z) || maxu >= tw) @@ -3297,9 +3297,9 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c case CLAMP_CLAMP: case CLAMP_REGION_CLAMP: if (vr.y < uv.y) - vr.y = uv.y; + vr.y = std::min(uv.y, vr.w - 1); if (vr.w > (uv.w + 1)) - vr.w = uv.w + 1; + vr.w = std::max(uv.w, vr.y) + 1; break; case CLAMP_REGION_REPEAT: if (UsesRegionRepeat(maxv, minv, uv.y, uv.w, &vr.y, &vr.w) || maxv >= th)