GSdx-hw TC: invalidate Source with Target TEX0

Fixes eyes blinking in Jak games with tex in rt search
enabled.

- Target TEX0 in Source is Source TEX0 if the Source is
not build from Target, otherwise it is the Target TEX0,
allowing improved Source invalidation
This commit is contained in:
Alessandro Vetere 2019-08-11 14:42:29 +02:00 committed by lightningterror
parent 68cfc5d953
commit 7c42928b57
2 changed files with 10 additions and 1 deletions

View File

@ -154,6 +154,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
src->m_shared_texture = true;
src->m_target = true; // So renderer can check if a conversion is required
src->m_from_target = dst->m_texture; // avoid complex condition on the renderer
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_32_bits_fmt = dst->m_32_bits_fmt;
src->m_valid_rect = dst->m_valid;
@ -698,7 +699,8 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b
Source* s = *i;
++i;
if(GSUtil::HasSharedBits(bp, psm, s->m_TEX0.TBP0, s->m_TEX0.PSM))
if (GSUtil::HasSharedBits(bp, psm, s->m_TEX0.TBP0, s->m_TEX0.PSM) ||
GSUtil::HasSharedBits(bp, psm, s->m_from_target_TEX0.TBP0, s->m_TEX0.PSM))
{
m_src.RemoveAt(s);
}
@ -805,6 +807,8 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b
// render target used as input texture
// TODO
b |= bp == s->m_from_target_TEX0.TBP0;
if(b)
{
m_src.RemoveAt(s);
@ -1156,6 +1160,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
src->m_texture = dTex;
src->m_target = true;
src->m_from_target = dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_texture->SetScale(scale);
if (psm.pal > 0) {
@ -1182,6 +1187,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
src->m_texture = dTex;
src->m_target = true;
src->m_from_target = dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
// Even if we sample the framebuffer directly we might need the palette
// to handle the format conversion on GPU
@ -1213,6 +1219,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture
src->m_target = true;
src->m_from_target = dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_valid_rect = dst->m_valid;
dst->Update();
@ -1547,6 +1554,7 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
, m_complete(false)
, m_p2t(NULL)
, m_from_target(NULL)
, m_from_target_TEX0(TEX0)
{
m_TEX0 = TEX0;
m_TEXA = TEXA;

View File

@ -113,6 +113,7 @@ public:
// still be valid on future. However it ought to be good when the source is created
// so it can be used to access un-converted data for the current draw call.
GSTexture* m_from_target;
GIFRegTEX0 m_from_target_TEX0; // TEX0 of the target texture, if any, else equal to texture TEX0
GIFRegTEX0 m_layer_TEX0[7]; // Detect already loaded value
// Keep a GSTextureCache::SourceMap::m_map iterator to allow fast erase
std::array<uint16, MAX_PAGES> m_erase_it;