gs-hw: fix invalid reference to target texture.

if the target texture changes after the source
lookup, correctly propagate the texture update.

fixes tales of abyss fullscreen blur when upscaling.
This commit is contained in:
iMineLink 2022-05-22 12:07:33 +02:00 committed by lightningterror
parent 4f20a68b33
commit 73eea20fcc
3 changed files with 14 additions and 8 deletions

View File

@ -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) if (s_dump)
{ {
const u64 frame = g_perfmon.GetFrame(); const u64 frame = g_perfmon.GetFrame();
@ -2160,7 +2166,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
GL_INS("Gran Turismo RGB Channel"); GL_INS("Gran Turismo RGB Channel");
m_conf.ps.channel = ChannelFetch_RGB; m_conf.ps.channel = ChannelFetch_RGB;
m_context->TEX0.TFX = TFX_DECAL; 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) else if (m_game.title == CRC::Tekken5)
{ {
@ -2173,7 +2179,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
// 12 pages: 2 calls by channel, 3 channels, 1 blit // 12 pages: 2 calls by channel, 3 channels, 1 blit
// Minus current draw call // Minus current draw call
m_skip = 12 * (3 + 3 + 1) - 1; m_skip = 12 * (3 + 3 + 1) - 1;
m_conf.rt = tex->m_from_target; m_conf.rt = *tex->m_from_target;
} }
else else
{ {
@ -2279,7 +2285,7 @@ void GSRendererHW::EmulateChannelShuffle(const GSTextureCache::Source* tex)
// Effect is really a channel shuffle effect so let's cheat a little // Effect is really a channel shuffle effect so let's cheat a little
if (m_channel_shuffle) 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)
{ {
if (m_conf.tex == m_conf.rt) if (m_conf.tex == m_conf.rt)

View File

@ -145,7 +145,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
src->m_texture = dst->m_texture; src->m_texture = dst->m_texture;
src->m_shared_texture = true; src->m_shared_texture = true;
src->m_target = true; // So renderer can check if a conversion is required 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_from_target_TEX0 = dst->m_TEX0;
src->m_32_bits_fmt = dst->m_32_bits_fmt; src->m_32_bits_fmt = dst->m_32_bits_fmt;
src->m_valid_rect = dst->m_valid; src->m_valid_rect = dst->m_valid;
@ -1258,7 +1258,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture // Keep a trace of origin of the texture
src->m_texture = dTex; src->m_texture = dTex;
src->m_target = true; 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_from_target_TEX0 = dst->m_TEX0;
src->m_texture->SetScale(scale); src->m_texture->SetScale(scale);
src->m_end_block = dst->m_end_block; src->m_end_block = dst->m_end_block;
@ -1287,7 +1287,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture // Keep a trace of origin of the texture
src->m_texture = dTex; src->m_texture = dTex;
src->m_target = true; 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_from_target_TEX0 = dst->m_TEX0;
src->m_end_block = dst->m_end_block; src->m_end_block = dst->m_end_block;
@ -1323,7 +1323,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// Keep a trace of origin of the texture // Keep a trace of origin of the texture
src->m_target = true; 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_from_target_TEX0 = dst->m_TEX0;
src->m_valid_rect = dst->m_valid; src->m_valid_rect = dst->m_valid;
src->m_end_block = dst->m_end_block; src->m_end_block = dst->m_end_block;

View File

@ -164,7 +164,7 @@ public:
// Keep a trace of the target origin. There is no guarantee that pointer will // 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 // 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. // 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_from_target_TEX0; // TEX0 of the target texture, if any, else equal to texture TEX0
GIFRegTEX0 m_layer_TEX0[7]; // Detect already loaded value GIFRegTEX0 m_layer_TEX0[7]; // Detect already loaded value
HashType m_layer_hash[7]; HashType m_layer_hash[7];