GS/TC: Ignore horizontal offset in invalidation start position

This commit is contained in:
refractionpcsx2 2023-09-07 22:53:58 +01:00
parent ce90d81a2f
commit 8552a89838
1 changed files with 4 additions and 3 deletions

View File

@ -408,9 +408,6 @@ void GSTextureCache::DirtyRectByPage(u32 sbp, u32 spsm, u32 sbw, Target* t, GSVe
GSVector4i in_rect = src_r; GSVector4i in_rect = src_r;
u32 target_bp = t->m_TEX0.TBP0; u32 target_bp = t->m_TEX0.TBP0;
int block_offset = static_cast<int>(sbp) - static_cast<int>(target_bp); int block_offset = static_cast<int>(sbp) - static_cast<int>(target_bp);
int page_offset = (block_offset) >> 5;
const int start_page = page_offset + (src_r.x / src_info->pgs.x) + ((src_r.y / src_info->pgs.y) * std::max(static_cast<int>(sbw), 1));
// Different format needs to be page aligned, unless the block layout matches, then we can block align // Different format needs to be page aligned, unless the block layout matches, then we can block align
// Might be able to translate the original rect. // Might be able to translate the original rect.
if (!(src_info->bpp == dst_info->bpp)) if (!(src_info->bpp == dst_info->bpp))
@ -454,6 +451,10 @@ void GSTextureCache::DirtyRectByPage(u32 sbp, u32 spsm, u32 sbw, Target* t, GSVe
const int src_pg_width = std::max((src_width + (src_info->pgs.x - 1)) / src_info->pgs.x, 1); const int src_pg_width = std::max((src_width + (src_info->pgs.x - 1)) / src_info->pgs.x, 1);
const int dst_pg_width = std::max((dst_width + (dst_info->pgs.x - 1)) / dst_info->pgs.x, 1); const int dst_pg_width = std::max((dst_width + (dst_info->pgs.x - 1)) / dst_info->pgs.x, 1);
int page_offset = (block_offset) >> 5;
// remove any hoizontal offset, this is added back on later.
const int start_page = (page_offset - (page_offset % src_pg_width)) + (src_r.x / src_info->pgs.x) + ((src_r.y / src_info->pgs.y) * std::max(static_cast<int>(sbw), 1));
// Pages aligned. // Pages aligned.
const GSVector4i page_mask(GSVector4i((src_info->pgs.x - 1), (src_info->pgs.y - 1)).xyxy()); const GSVector4i page_mask(GSVector4i((src_info->pgs.x - 1), (src_info->pgs.y - 1)).xyxy());
const GSVector4i page_masked_rect(in_rect & ~page_mask); const GSVector4i page_masked_rect(in_rect & ~page_mask);