Skip to content

Commit

Permalink
gs-hw: fix invalid reference to target texture.
Browse files Browse the repository at this point in the history
if the target texture changes after the source
lookup, correctly propagate the texture update.

fixes tales of abyss fullscreen blur when upscaling.
  • Loading branch information
iMineLink authored and lightningterror committed May 22, 2022
1 parent 4f20a68 commit 73eea20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Expand Up @@ -1626,6 +1626,12 @@ void GSRendererHW::Draw()
}
}

if (m_src && m_src->m_shared_texture && m_src->m_texture != *m_src->m_from_target)
{
// Target texture changed, update reference.
m_src->m_texture = *m_src->m_from_target;
}

if (s_dump)
{
const u64 frame = g_perfmon.GetFrame();
Expand Down Expand Up @@ -2160,7 +2166,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
GL_INS("Gran Turismo RGB Channel");
m_conf.ps.channel = ChannelFetch_RGB;
m_context->TEX0.TFX = TFX_DECAL;
m_conf.rt = tex->m_from_target;
m_conf.rt = *tex->m_from_target;
}
else if (m_game.title == CRC::Tekken5)
{
Expand All @@ -2173,7 +2179,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
// 12 pages: 2 calls by channel, 3 channels, 1 blit
// Minus current draw call
m_skip = 12 * (3 + 3 + 1) - 1;
m_conf.rt = tex->m_from_target;
m_conf.rt = *tex->m_from_target;
}
else
{
Expand Down Expand Up @@ -2279,7 +2285,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
// Effect is really a channel shuffle effect so let's cheat a little
if (m_channel_shuffle)
{
m_conf.tex = tex->m_from_target;
m_conf.tex = *tex->m_from_target;
if (m_conf.tex)
{
if (m_conf.tex == m_conf.rt)
Expand Down
8 changes: 4 additions & 4 deletions pcsx2/GS/Renderers/HW/GSTextureCache.cpp
Expand Up @@ -145,7 +145,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
src->m_texture = dst->m_texture;
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 = &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;
Expand Down Expand Up @@ -1258,7 +1258,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture
src->m_texture = dTex;
src->m_target = true;
src->m_from_target = dst->m_texture;
src->m_from_target = &dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_texture->SetScale(scale);
src->m_end_block = dst->m_end_block;
Expand Down Expand Up @@ -1287,7 +1287,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture
src->m_texture = dTex;
src->m_target = true;
src->m_from_target = dst->m_texture;
src->m_from_target = &dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_end_block = dst->m_end_block;

Expand Down Expand Up @@ -1323,7 +1323,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 = &dst->m_texture;
src->m_from_target_TEX0 = dst->m_TEX0;
src->m_valid_rect = dst->m_valid;
src->m_end_block = dst->m_end_block;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GS/Renderers/HW/GSTextureCache.h
Expand Up @@ -164,7 +164,7 @@ class GSTextureCache
// Keep a trace of the target origin. There is no guarantee that pointer will
// 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;
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
HashType m_layer_hash[7];
Expand Down

0 comments on commit 73eea20

Please sign in to comment.