GS/HW: Fix false positive on shared bits with double-half clears

This commit is contained in:
Stenzek 2024-01-20 14:09:15 +10:00 committed by Connor McLaughlin
parent dfac1f034b
commit e3ca5833d0
1 changed files with 6 additions and 0 deletions

View File

@ -5931,7 +5931,11 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
if (half > (base + written_pages) || half <= base)
return false;
// CoD: World at War draws a shadow map with RGB masked at the same page as the depth buffer, which is
// 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 && half_point->m_age <= 1)
return false;
@ -5978,10 +5982,12 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
// Check for a target matching the starting point. It might be in Z or FRAME...
GSTextureCache::Target* tgt = g_texture_cache->GetTargetWithSharedBits(
base * BLOCKS_PER_PAGE, clear_depth ? m_cached_ctx.ZBUF.PSM : m_cached_ctx.FRAME.PSM);
tgt = (tgt && tgt->m_valid_rgb && tgt->HasValidAlpha() == req_valid_alpha) ? tgt : nullptr;
if (!tgt)
{
tgt = g_texture_cache->GetTargetWithSharedBits(
base * BLOCKS_PER_PAGE, clear_depth ? m_cached_ctx.FRAME.PSM : m_cached_ctx.ZBUF.PSM);
tgt = (tgt && tgt->m_valid_rgb && tgt->HasValidAlpha() == req_valid_alpha) ? tgt : nullptr;
}
u32 end_block = ((half + written_pages) * BLOCKS_PER_PAGE) - 1;