From 0e3abee97440930b864981d87d6443a42e69bc1a Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Mon, 5 Oct 2026 19:13:33 +0100 Subject: [PATCH] GS/HW: Ignore invalid sized Z buffers on double half clear --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 9645c96ae2..72073db760 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -10124,7 +10124,13 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds) // double-half cleared. For testing, ignore any targets that don't have the bits we're drawing to. const bool req_valid_alpha = ((frame_psm.fmsk & zbuf_psm.fmsk) & 0xFF000000u) != 0; GSTextureCache::Target* half_point = g_texture_cache->GetExactTarget(half << 5, m_cached_ctx.FRAME.FBW, clear_depth ? GSTextureCache::RenderTarget : GSTextureCache::DepthStencil, half << 5); - half_point = (half_point && half_point->m_valid_rgb && half_point->HasValidAlpha() == req_valid_alpha) ? half_point : nullptr; + if (half_point) + { + int half_point_pages = 0; + half_point_pages = (half_point->m_valid.z + (zbuf_psm.pgs.x - 1)) / zbuf_psm.pgs.x; + half_point_pages *= (half_point->m_valid.w + (zbuf_psm.pgs.y - 1)) / zbuf_psm.pgs.y; + half_point = (half_point && half_point->m_valid_rgb && half_point->HasValidAlpha() == req_valid_alpha && half_point_pages >= written_pages) ? half_point : nullptr; + } if (half_point && half_point->m_age <= 1) return false;