diff --git a/pcsx2/GS/Renderers/SW/GSDrawScanline.cpp b/pcsx2/GS/Renderers/SW/GSDrawScanline.cpp index 4accabe8f1..22cb1b3406 100644 --- a/pcsx2/GS/Renderers/SW/GSDrawScanline.cpp +++ b/pcsx2/GS/Renderers/SW/GSDrawScanline.cpp @@ -479,6 +479,9 @@ void GSDrawScanline::CDrawScanline(int pixels, int left, int top, const GSVertex { zs = VectorI(z); } + + if (sel.zclamp) + zs = zs.min_u32(VectorI::xffffffff().srl32(sel.zpsm * 8)); } else { @@ -505,15 +508,12 @@ void GSDrawScanline::CDrawScanline(int pixels, int left, int top, const GSVertex VectorI zso = zs; VectorI zdo = zd; - if (sel.zoverflow || sel.zpsm == 0) + if (sel.zpsm == 0) { zso -= VectorI::x80000000(); zdo -= VectorI::x80000000(); } - if (sel.zclamp) - zso = zso.min_u32(VectorI::xffffffff().srl32(sel.zpsm * 8)); - switch (sel.ztst) { case ZTST_GEQUAL: test |= zso < zdo; break; @@ -1201,9 +1201,6 @@ void GSDrawScanline::CDrawScanline(int pixels, int left, int top, const GSVertex zs = zs.blend8(zd, zm); } - if (sel.zclamp) - zs = zs.min_u32(VectorI::xffffffff().srl32(sel.zpsm * 8)); - bool fast = sel.ztest ? sel.zpsm < 2 : sel.zpsm == 0 && sel.notest; if (sel.notest) diff --git a/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.all.cpp b/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.all.cpp index 0093e7419d..1bd11b07ff 100644 --- a/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.all.cpp +++ b/pcsx2/GS/Renderers/SW/GSDrawScanlineCodeGenerator.all.cpp @@ -1089,6 +1089,7 @@ void GSDrawScanlineCodeGenerator2::TestZ(const XYm& temp1, const XYm& temp2) cvttps2dq(xym0, z); } + // Clamp Z to ZPSM_FMT_MAX if (m_sel.zclamp) { const u8 amt = (u8)((m_sel.zpsm & 0x3) * 8); @@ -1124,7 +1125,7 @@ void GSDrawScanlineCodeGenerator2::TestZ(const XYm& temp1, const XYm& temp2) psrld(temp2, static_cast(m_sel.zpsm * 8)); } - if (m_sel.zoverflow || m_sel.zpsm == 0) + if (m_sel.zpsm == 0) { // GSVector4i o = GSVector4i::x80000000(); @@ -2552,15 +2553,6 @@ void GSDrawScanlineCodeGenerator2::WriteZBuf() } } - // Clamp Z to ZPSM_FMT_MAX - if (m_sel.zclamp) - { - const u8 amt = (u8)((m_sel.zpsm & 0x3) * 8); - pcmpeqd(xym7, xym7); - psrld(xym7, amt); - pminsd(xym1, xym7); - } - bool fast = m_sel.ztest ? m_sel.zpsm < 2 : m_sel.zpsm == 0 && m_sel.notest; #if USING_XMM