From b512162956f3789c47a3866b2cb27e3451e5adbe Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Mon, 20 May 2024 17:15:21 +0100 Subject: [PATCH] GS/HW: Ignore alpha on double half clear if not used --- 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 dc29130c06..033d4ef15d 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -6384,7 +6384,23 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds) const GSLocalMemory::psm_t& frame_psm = GSLocalMemory::m_psm[m_cached_ctx.FRAME.PSM]; const GSLocalMemory::psm_t& zbuf_psm = GSLocalMemory::m_psm[m_cached_ctx.ZBUF.PSM]; if (((m_cached_ctx.FRAME.FBMSK & frame_psm.fmsk) != 0 && (m_cached_ctx.FRAME.FBMSK & zbuf_psm.fmsk) != 0)) - return false; + { + if ((m_cached_ctx.FRAME.FBMSK & frame_psm.fmsk) == (0xFF000000 & frame_psm.fmsk)) + { + // Alpha is masked, if the alpha is black anyways, and Z is writing to alpha, then just allow it. Tony Hawk Pro Skater 4 doesn't use the alpha channel but does this messy double clear. + if (frame_psm.trbpp == 32 && zbuf_psm.trbpp == 32 && m_vt.m_max.c.a == 0 && m_vt.m_max.p.z < 0x1000000) + { + GSTextureCache::Target* frame = g_texture_cache->GetExactTarget(m_cached_ctx.FRAME.Block(), m_cached_ctx.FRAME.FBW, GSTextureCache::RenderTarget, m_cached_ctx.FRAME.Block()); + + if (frame && frame->m_alpha_max > 0) + return false; + } + else + return false; + } + else + return false; + } // Z and color must be constant and the same if (m_vt.m_eq.rgba != 0xFFFF || !m_vt.m_eq.z)