mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-12-05 04:13:34 +01:00
GS: Simplify Overlaps check
This commit is contained in:
1 parent
1fa3c6aa4a
commit
bf94ee1c8e
1 file changed
+14
-45
+14
-45
@@ -512,56 +512,25 @@ GSVector4i GSLocalMemory::GetRectForPageOffset(u32 base_bp, u32 offset_bp, u32 b
|
||||
bool GSLocalMemory::HasOverlap(const u32 src_bp, const u32 src_bw, const u32 src_psm, const GSVector4i src_rect,
|
||||
const u32 dst_bp, const u32 dst_bw, const u32 dst_psm, const GSVector4i dst_rect)
|
||||
{
|
||||
const u32 src_start_bp = GSLocalMemory::GetStartBlockAddress(src_bp, src_bw, src_psm, src_rect) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
const u32 dst_start_bp = GSLocalMemory::GetStartBlockAddress(dst_bp, dst_bw, dst_psm, dst_rect) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
u32 src_start_bp = GSLocalMemory::GetStartBlockAddress(src_bp, src_bw, src_psm, src_rect) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
u32 dst_start_bp = GSLocalMemory::GetStartBlockAddress(dst_bp, dst_bw, dst_psm, dst_rect) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
|
||||
u32 src_end_bp = ((GSLocalMemory::GetEndBlockAddress(src_bp, src_bw, src_psm, src_rect) + 1) + (GS_BLOCKS_PER_PAGE - 1)) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
u32 dst_end_bp = ((GSLocalMemory::GetEndBlockAddress(dst_bp, dst_bw, dst_psm, dst_rect) + 1) + (GS_BLOCKS_PER_PAGE - 1)) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
u32 src_end_bp = ((GSLocalMemory::GetUnwrappedEndBlockAddress(src_bp, src_bw, src_psm, src_rect) + 1) + (GS_BLOCKS_PER_PAGE - 1)) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
u32 dst_end_bp = ((GSLocalMemory::GetUnwrappedEndBlockAddress(dst_bp, dst_bw, dst_psm, dst_rect) + 1) + (GS_BLOCKS_PER_PAGE - 1)) & ~(GS_BLOCKS_PER_PAGE - 1);
|
||||
|
||||
if (src_start_bp == src_end_bp)
|
||||
if (dst_end_bp > GS_MAX_BLOCKS && src_end_bp < dst_start_bp)
|
||||
{
|
||||
src_end_bp = (src_end_bp + GS_BLOCKS_PER_PAGE) & ~(GS_MAX_BLOCKS - 1);
|
||||
src_start_bp += GS_MAX_BLOCKS;
|
||||
src_end_bp += GS_MAX_BLOCKS;
|
||||
}
|
||||
else if (src_end_bp > GS_MAX_BLOCKS && dst_end_bp < src_start_bp)
|
||||
{
|
||||
dst_start_bp += GS_MAX_BLOCKS;
|
||||
dst_end_bp += GS_MAX_BLOCKS;
|
||||
}
|
||||
|
||||
if (dst_start_bp == dst_end_bp)
|
||||
{
|
||||
dst_end_bp = (dst_end_bp + GS_BLOCKS_PER_PAGE) & ~(GS_MAX_BLOCKS - 1);
|
||||
}
|
||||
|
||||
// Source has wrapped, 2 separate checks.
|
||||
if (src_end_bp <= src_start_bp)
|
||||
{
|
||||
// Destination has also wrapped, so they *have* to overlap.
|
||||
if (dst_end_bp <= dst_start_bp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dst_end_bp > src_start_bp)
|
||||
return true;
|
||||
|
||||
if (dst_start_bp < src_end_bp)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else // No wrapping on source.
|
||||
{
|
||||
// Destination wraps.
|
||||
if (dst_end_bp <= dst_start_bp)
|
||||
{
|
||||
if (src_end_bp > dst_start_bp)
|
||||
return true;
|
||||
|
||||
if (src_start_bp < dst_end_bp)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dst_start_bp < src_end_bp && dst_end_bp > src_start_bp)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (src_start_bp < dst_end_bp && dst_start_bp < src_end_bp)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user