@@ -512,56 +512,25 @@ GSVector4i GSLocalMemory::GetRectForPageOffset(u32 base_bp, u32 offset_bp, u32 b
512512bool GSLocalMemory::HasOverlap (const u32 src_bp, const u32 src_bw, const u32 src_psm, const GSVector4i src_rect,
513513 const u32 dst_bp, const u32 dst_bw, const u32 dst_psm, const GSVector4i dst_rect)
514514{
515- const u32 src_start_bp = GSLocalMemory::GetStartBlockAddress (src_bp, src_bw, src_psm, src_rect) & ~(GS_BLOCKS_PER_PAGE - 1 );
516- const u32 dst_start_bp = GSLocalMemory::GetStartBlockAddress (dst_bp, dst_bw, dst_psm, dst_rect) & ~(GS_BLOCKS_PER_PAGE - 1 );
515+ u32 src_start_bp = GSLocalMemory::GetStartBlockAddress (src_bp, src_bw, src_psm, src_rect) & ~(GS_BLOCKS_PER_PAGE - 1 );
516+ u32 dst_start_bp = GSLocalMemory::GetStartBlockAddress (dst_bp, dst_bw, dst_psm, dst_rect) & ~(GS_BLOCKS_PER_PAGE - 1 );
517517
518- 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 );
519- 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 );
518+ 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 );
519+ 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 );
520520
521- if (src_start_bp == src_end_bp)
521+ if (dst_end_bp > GS_MAX_BLOCKS && src_end_bp < dst_start_bp )
522522 {
523- src_end_bp = (src_end_bp + GS_BLOCKS_PER_PAGE) & ~(GS_MAX_BLOCKS - 1 );
523+ src_start_bp += GS_MAX_BLOCKS;
524+ src_end_bp += GS_MAX_BLOCKS;
524525 }
525-
526- if (dst_start_bp == dst_end_bp)
526+ else if (src_end_bp > GS_MAX_BLOCKS && dst_end_bp < src_start_bp)
527527 {
528- dst_end_bp = (dst_end_bp + GS_BLOCKS_PER_PAGE) & ~(GS_MAX_BLOCKS - 1 );
529- }
530-
531- // Source has wrapped, 2 separate checks.
532- if (src_end_bp <= src_start_bp)
533- {
534- // Destination has also wrapped, so they *have* to overlap.
535- if (dst_end_bp <= dst_start_bp)
536- {
537- return true ;
538- }
539- else
540- {
541- if (dst_end_bp > src_start_bp)
542- return true ;
543-
544- if (dst_start_bp < src_end_bp)
545- return true ;
546- }
528+ dst_start_bp += GS_MAX_BLOCKS;
529+ dst_end_bp += GS_MAX_BLOCKS;
547530 }
548- else // No wrapping on source.
549- {
550- // Destination wraps.
551- if (dst_end_bp <= dst_start_bp)
552- {
553- if (src_end_bp > dst_start_bp)
554- return true ;
555531
556- if (src_start_bp < dst_end_bp)
557- return true ;
558- }
559- else
560- {
561- if (dst_start_bp < src_end_bp && dst_end_bp > src_start_bp)
562- return true ;
563- }
564- }
532+ if (src_start_bp < dst_end_bp && dst_start_bp < src_end_bp)
533+ return true ;
565534
566535 return false ;
567536}
0 commit comments