From 7c243756bccecf08e2c7e3b7a1572e10cad91344 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 28 May 2022 03:04:21 +0100 Subject: [PATCH] GS: Better swapped draw direction detection on scissor opt --- pcsx2/GS/GSState.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index edae87a044..1138340ad5 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -3212,12 +3212,14 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c const GSVertex* vert_first = &m_vertex.buff[m_index.buff[0]]; const GSVertex* vert_second = &m_vertex.buff[m_index.buff[1]]; - const bool swap_x = vert_first->U > vert_second->U; - const bool swap_y = vert_first->V > vert_second->V; - // we need to check that it's not going to repeat over the non-clipped part if (wms != CLAMP_REGION_REPEAT && (wms != CLAMP_REPEAT || (static_cast(st.x) & ~tw_mask) == (static_cast(st.z) & ~tw_mask))) { + // Check if the UV coords are going in a different direction to the verts, if they match direction, no need to swap + const bool u_forward = vert_first->U < vert_second->U; + const bool x_forward = vert_first->XYZ.X < vert_second->XYZ.X; + const bool swap_x = u_forward != x_forward; + if (int_rc.left < scissored_rc.left) { if(!swap_x) @@ -3235,6 +3237,11 @@ GSState::TextureMinMaxResult GSState::GetTextureMinMax(const GIFRegTEX0& TEX0, c } if (wmt != CLAMP_REGION_REPEAT && (wmt != CLAMP_REPEAT || (static_cast(st.y) & ~th_mask) == (static_cast(st.w) & ~th_mask))) { + // Check if the UV coords are going in a different direction to the verts, if they match direction, no need to swap + const bool v_forward = vert_first->U < vert_second->U; + const bool y_forward = vert_first->XYZ.Y < vert_second->XYZ.Y; + const bool swap_y = v_forward != y_forward; + if (int_rc.top < scissored_rc.top) { if (!swap_y)