gsdx tc: avoid to load data outside of the GS memory

Avoid crash in Kungfu panda
This commit is contained in:
Gregory Hainaut 2016-05-06 21:46:29 +02:00
parent c540840cd4
commit 265ea82780
1 changed files with 7 additions and 2 deletions

View File

@ -1744,8 +1744,13 @@ void GSTextureCache::Target::Update()
GSVector2i t_size = m_texture->GetSize();
GSVector2 t_scale = m_texture->GetScale();
t_size.x = t_size.x/t_scale.x;
t_size.y = t_size.y/t_scale.y;
t_size.x = (int)((float)t_size.x/t_scale.x);
t_size.y = (int)((float)t_size.y/t_scale.y);
// Don't load above the GS memory
int max_y_blocks = (MAX_BLOCKS - m_TEX0.TBP0) / 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);
GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, t_size);