From 8552a8983835612169a05398dac97b58c38bd983 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Thu, 7 Sep 2023 22:53:58 +0100 Subject: [PATCH] GS/TC: Ignore horizontal offset in invalidation start position --- pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index f171f371176b2..85647feada97e 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -408,9 +408,6 @@ void GSTextureCache::DirtyRectByPage(u32 sbp, u32 spsm, u32 sbw, Target* t, GSVe GSVector4i in_rect = src_r; u32 target_bp = t->m_TEX0.TBP0; int block_offset = static_cast(sbp) - static_cast(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(sbw), 1)); - // 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. 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 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(sbw), 1)); + // Pages aligned. 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);