GS/HW: Round up when checking odd width double half clears

This commit is contained in:
refractionpcsx2 2023-08-29 20:07:14 +01:00
parent c4ec841c0f
commit 0a44a81d18
1 changed files with 12 additions and 4 deletions

View File

@ -5684,7 +5684,7 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
const u32 written_pages = w_pages * h_pages;
// If both buffers are side by side we can expect a fast clear in on-going
if (half != (base + written_pages))
if (half > (base + written_pages) || half <= base)
return false;
// Don't allow double half clear to go through when the number of bits written through FRAME and Z are different.
@ -5729,10 +5729,18 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
base * BLOCKS_PER_PAGE, clear_depth ? m_cached_ctx.FRAME.PSM : m_cached_ctx.ZBUF.PSM);
}
u32 end_block = ((half + written_pages) * BLOCKS_PER_PAGE) - 1;
if (tgt)
{
// If the full size is an odd width and it's trying to do half (in the case of FF7 DoC it goes from 7 to 4), we need to recalculate our end check.
if ((m_cached_ctx.FRAME.FBW * 2) == (tgt->m_TEX0.TBW + 1))
end_block = GSLocalMemory::GetUnwrappedEndBlockAddress(tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW + 1, tgt->m_TEX0.PSM, tgt->GetUnscaledRect());
else
end_block = GSLocalMemory::GetUnwrappedEndBlockAddress(tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW, tgt->m_TEX0.PSM, tgt->GetUnscaledRect());
}
// Are we clearing over the middle of this target?
if (!tgt || (((half + written_pages) * BLOCKS_PER_PAGE) - 1) >
GSLocalMemory::GetUnwrappedEndBlockAddress(
tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW, tgt->m_TEX0.PSM, tgt->GetUnscaledRect()))
if (!tgt || (((half + written_pages) * BLOCKS_PER_PAGE) - 1) > end_block)
{
return false;
}