diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index b389d6cf83..b21c207e13 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -851,6 +851,30 @@ void GSTextureCache::InvalidateLocalMem(GSOffset* off, const GSVector4i& r) // TODO: ds } +// Hack: remove Target that are strictly included in current rt. Typically uses for FMV +// For example, game is rendered at 0x800->0x1000, fmv will be uploaded to 0x0->0x2800 +// FIXME In theory, we ought to report the data from the sub rt to the main rt. But let's +// postpone it for later. +void GSTextureCache::InvalidateVideoMemSubTarget(GSTextureCache::Target* rt) +{ + if (!rt) + return; + + for(list::iterator i = m_dst[RenderTarget].begin(); i != m_dst[RenderTarget].end(); ) { + list::iterator j = i++; + Target* t = *j; + + if ((t->m_TEX0.TBP0 > rt->m_TEX0.TBP0) && (t->m_end_block < rt->m_end_block) && (t->m_TEX0.TBW == rt->m_TEX0.TBW) + && (t->m_TEX0.TBP0 < t->m_end_block)) { + GL_INS("InvalidateVideoMemSubTarget: rt 0x%x -> 0x%x, sub rt 0x%x -> 0x%x", + rt->m_TEX0.TBP0, rt->m_end_block, t->m_TEX0.TBP0, t->m_end_block); + + m_dst[RenderTarget].erase(j); + delete t; + } + } +} + void GSTextureCache::IncAge() { int maxage = m_src.m_used ? 3 : 30; diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index c14fdca6de..0d1438481c 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -145,6 +145,7 @@ public: Target* LookupTarget(const GIFRegTEX0& TEX0, int w, int h, int real_h); void InvalidateVideoMemType(int type, uint32 bp); + void InvalidateVideoMemSubTarget(GSTextureCache::Target* rt); void InvalidateVideoMem(GSOffset* off, const GSVector4i& r, bool target = true); void InvalidateLocalMem(GSOffset* off, const GSVector4i& r);