From 94bd7c96b90b462415e6fa95ee26a4ebfec5f41d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 26 May 2024 13:42:39 +1000 Subject: [PATCH] GS/HW: Use valid rect over size in CopyRGBFromDepthToColor() Avoids a copy. --- pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index db65007e1c710..398baada9feb6 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -2872,7 +2872,7 @@ bool GSTextureCache::CopyRGBFromDepthToColor(Target* dst, Target* depth_src) dst->m_TEX0.TBP0, psm_str(dst->m_TEX0.PSM)); // The depth target might be larger (Driv3r). - const GSVector2i new_size = depth_src->GetUnscaledSize().max(dst->GetUnscaledSize()); + const GSVector2i new_size = dst->GetUnscaledSize().max(GSVector2i(depth_src->m_valid.z, depth_src->m_valid.w)); const GSVector2i new_scaled_size = ScaleRenderTargetSize(new_size, dst->GetScale()); const bool needs_new_tex = (new_size != dst->m_unscaled_size); GSTexture* tex = dst->m_texture; @@ -2884,6 +2884,9 @@ bool GSTextureCache::CopyRGBFromDepthToColor(Target* dst, Target* depth_src) return false; m_target_memory_usage = (m_target_memory_usage - dst->m_texture->GetMemUsage()) + tex->GetMemUsage(); + + // Inject new size into hash cache to avoid future resizes. + GetTargetSize(dst->m_TEX0.TBP0, dst->m_TEX0.TBW, dst->m_TEX0.PSM, new_size.x, new_size.y); } // Remove any dirty rectangles contained by this update, we don't want to pull from local memory.