Skip to content

Commit

Permalink
GS/HW: Use valid rect over size in CopyRGBFromDepthToColor()
Browse files Browse the repository at this point in the history
Avoids a copy.
  • Loading branch information
stenzek committed May 28, 2024
1 parent e863da9 commit 94bd7c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pcsx2/GS/Renderers/HW/GSTextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down

0 comments on commit 94bd7c9

Please sign in to comment.