Merge pull request #2122 from PCSX2/target_load

GSdx-TC: Fix load size calculation in target update Fixes #1972 Fixes #2110 Fixes #2138
This commit is contained in:
refractionpcsx2
2018-03-03 03:31:25 +00:00
committed by GitHub
5 changed files with 17 additions and 16 deletions
+6 -11
View File
@@ -1846,18 +1846,13 @@ void GSTextureCache::Target::Update()
// Alternate
// 1/ uses multiple vertex rectangle
GSVector2i t_size = m_texture->GetSize();
GSVector2 t_scale = m_texture->GetScale();
GSVector2i t_size = default_rt_size;
//Avoids division by zero when calculating texture size.
t_scale = GSVector2(std::max(1.0f, t_scale.x), std::max(1.0f, t_scale.y));
t_size.x = lround(static_cast<float>(t_size.x) / t_scale.x);
t_size.y = lround(static_cast<float>(t_size.y) / t_scale.y);
// Don't load above the GS memory
int max_y_blocks = (MAX_BLOCKS - m_TEX0.TBP0) / std::max(1u, m_TEX0.TBW);
int max_y = (max_y_blocks >> 5) * GSLocalMemory::m_psm[m_TEX0.PSM].pgs.y;
t_size.y = std::min(t_size.y, max_y);
// Ensure buffer width is at least of the minimum required value.
// Probably not necessary but doesn't hurt to be on the safe side.
// I've seen some games use buffer sizes over 1024, which might bypass our default limit
int buffer_width = m_TEX0.TBW << 6;
t_size.x = std::max(buffer_width, t_size.x);
GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, t_size);