From 1668ec2fc6887c23c47b971798c9eeed288fefd3 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Mon, 18 Sep 2023 15:48:29 +0100 Subject: [PATCH] GS/HW: Improve half right detection on shuffles --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 097b24cdb0..1d57836761 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -431,7 +431,23 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba, GS // No super source of truth here, since the width can get batted around, the valid is probably our best bet. const int tex_width = tex->m_target ? tex->m_from_target->m_valid.z : (tex->m_TEX0.TBW * 64); const int tex_tbw = tex->m_target ? tex->m_from_target_TEX0.TBW : tex->m_TEX0.TBW; - if ((static_cast(m_cached_ctx.TEX0.TBW * 64) >= std::min(tex_width * 2, 1024) && tex_tbw != m_cached_ctx.TEX0.TBW) || (m_cached_ctx.TEX0.TBW * 64) < floor(m_vt.m_max.t.x)) + const int clamp_minu = m_context->CLAMP.MINU; + const int clamp_maxu = m_context->CLAMP.MAXU; + int max_tex_draw_width = std::min(static_cast(m_vt.m_max.t.x), 1 << m_cached_ctx.TEX0.TW); + + switch (m_context->CLAMP.WMS) + { + case CLAMP_REGION_CLAMP: + max_tex_draw_width = std::min(max_tex_draw_width, clamp_maxu); + break; + case CLAMP_REGION_REPEAT: + max_tex_draw_width = std::min(max_tex_draw_width, (clamp_maxu | clamp_minu)); + break; + default: + break; + } + + if ((static_cast(m_cached_ctx.TEX0.TBW * 64) >= std::min(tex_width * 2, 1024) && tex_tbw != m_cached_ctx.TEX0.TBW) || (m_cached_ctx.TEX0.TBW * 64) < floor(max_tex_draw_width)) { half_right_uv = false; half_right_vert = false;