From 99f0d5c6852056fee5a9bcd43ebd150bf33f01af Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Fri, 4 Feb 2022 23:28:24 +0100 Subject: [PATCH] GS-hw: Properly enable/disable each channel based on fbmask, adjust fbmask detection when to do blending for 16bit/24bit. Optimization. --- pcsx2/GS/Renderers/HW/GSRendererNew.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSRendererNew.cpp b/pcsx2/GS/Renderers/HW/GSRendererNew.cpp index 1eff4611e8..b4fe71674c 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererNew.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererNew.cpp @@ -301,11 +301,11 @@ void GSRendererNew::EmulateTextureShuffleAndFbmask() // Don't allow only unused bits on 16bit format to enable fbmask, // let's set the mask to 0 in such cases. int fbmask = static_cast(m_context->FRAME.FBMSK); - if (!(fbmask & 0x80F8F8F8) && fbmask != 0x0 && m_conf.ps.dfmt == 2) - fbmask = 0x0; - + const int fbmask_r = m_conf.ps.dfmt == 2 ? 0x80F8F8F8 : m_conf.ps.dfmt == 1 ? 0x00FFFFFF : 0xFFFFFFFF; + fbmask &= fbmask_r; const GSVector4i fbmask_v = GSVector4i::load(fbmask); - const int ff_fbmask = fbmask_v.eq8(GSVector4i::xffffffff()).mask(); + const GSVector4i fbmask_vr = GSVector4i::load(fbmask_r); + const int ff_fbmask = fbmask_v.eq8(fbmask_vr).mask(); const int zero_fbmask = fbmask_v.eq8(GSVector4i::zero()).mask(); m_conf.colormask.wrgba = ~ff_fbmask; // Enable channel if at least 1 bit is 0 @@ -527,8 +527,9 @@ void GSRendererNew::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER) const bool AA1 = PRIM->AA1 && (m_vt.m_primclass == GS_LINE_CLASS); // PABE: Check condition early as an optimization. const bool PABE = PRIM->ABE && m_env.PABE.PABE && (GetAlphaMinMax().max < 128); - // FBMASK: Only alpha is written, no need to do blending. - const bool FBMASK = m_context->FRAME.FBMSK == 0x00FFFFFF; + // FBMASK: Color is not written, no need to do blending. + const int temp_fbmask = m_conf.ps.dfmt == 2 ? 0x00F8F8F8 : 0x00FFFFFF; + const bool FBMASK = (m_context->FRAME.FBMSK & temp_fbmask) == temp_fbmask; // No blending or coverage anti-aliasing so early exit if (FBMASK || PABE || !(PRIM->ABE || AA1))