diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index d4733bea24..66bed568d9 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -579,7 +579,8 @@ void GSRendererHW::Draw() if(fm != 0xffffffff && rt) { - rt->m_valid = rt->m_valid.runion(r); + //rt->m_valid = rt->m_valid.runion(r); + rt->UpdateValidity(r); m_tc->InvalidateVideoMem(context->offset.fb, r, false); @@ -588,7 +589,8 @@ void GSRendererHW::Draw() if(zm != 0xffffffff && ds) { - ds->m_valid = ds->m_valid.runion(r); + //ds->m_valid = ds->m_valid.runion(r); + ds->UpdateValidity(r); m_tc->InvalidateVideoMem(context->offset.zb, r, false); diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 09d1988953..704a4fb35e 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -424,7 +424,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int { dst = t; - GL_CACHE("TC: Lookup Frame %dx%d, perfect hit: %d (0x%x)", w, h, dst->m_texture->GetID(), bp); + GL_CACHE("TC: Lookup Frame %dx%d, perfect hit: %d (0x%x -> 0x%x)", w, h, dst->m_texture->GetID(), bp, t->m_end_block); break; } @@ -434,7 +434,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int if(t->m_TEX0.TBP0 <= bp && bp < t->m_TEX0.TBP0 + 0xe00UL && (!dst || t->m_TEX0.TBP0 >= dst->m_TEX0.TBP0)) { - GL_CACHE("TC: Lookup Frame %dx%d, close hit: %d (0x%x, took 0x%x)", w, h, t->m_texture->GetID(), bp, t->m_TEX0.TBP0); + GL_CACHE("TC: Lookup Frame %dx%d, close hit: %d (0x%x, took 0x%x -> 0x%x)", w, h, t->m_texture->GetID(), bp, t->m_TEX0.TBP0, t->m_end_block); dst = t; } } @@ -1615,6 +1615,16 @@ void GSTextureCache::Target::Update() m_renderer->m_dev->Recycle(t); } +void GSTextureCache::Target::UpdateValidity(const GSVector4i& r) +{ + m_valid = m_valid.runion(r); + + // TODO: assumption: format is 32 bits + uint32 nb_block = m_TEX0.TBW * m_valid.height(); + m_end_block = m_TEX0.TBP0 + nb_block; + //fprintf(stderr, "S: 0x%x E:0x%x\n", m_TEX0.TBP0, m_end_block); +} + // GSTextureCache::SourceMap void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, const GSOffset* off) diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index dbd9a430eb..1ce916a521 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -83,10 +83,13 @@ public: GSVector4i m_valid; bool m_depth_supported; bool m_dirty_alpha; + uint32 m_end_block; // Hint of the target area public: Target(GSRenderer* r, const GIFRegTEX0& TEX0, uint8* temp, bool depth_supported); + void UpdateValidity(const GSVector4i& r); + virtual void Update(); };