@@ -3933,6 +3933,8 @@ GSTextureCache::Target* GSTextureCache::LookupDisplayTarget(GIFRegTEX0 TEX0, con
39333933 // Didn't find a target, check if the frame was uploaded.
39343934
39353935 bool can_create = is_feedback;
3936+ bool exact_match = false ;
3937+ u32 exact_match_psm = 0 ;
39363938 GSVector2i new_size = size;
39373939
39383940 if (!is_feedback && GSRendererHW::GetInstance ()->m_draw_transfers .size () > 0 )
@@ -3970,6 +3972,8 @@ GSTextureCache::Target* GSTextureCache::LookupDisplayTarget(GIFRegTEX0 TEX0, con
39703972
39713973 if (iter->blit .DBP == TEX0.TBP0 && transfer_end == rect_end)
39723974 {
3975+ exact_match = true ;
3976+ exact_match_psm = iter->blit .DPSM ;
39733977 iter = std::vector<GSState::GSUploadQueue>::reverse_iterator (GSRendererHW::GetInstance ()->m_draw_transfers .erase (iter.base () - 1 ));
39743978 }
39753979 // Double buffers, usually FMV's, if checking for the upper buffer, creating another target could mess things up.
@@ -4001,7 +4005,32 @@ GSTextureCache::Target* GSTextureCache::LookupDisplayTarget(GIFRegTEX0 TEX0, con
40014005 }
40024006 }
40034007
4004- return can_create ? CreateTarget (TEX0, new_size, new_size, scale, RenderTarget, true , 0 , true ) : nullptr ;
4008+ if (can_create)
4009+ {
4010+ Target* tgt = CreateTarget (TEX0, new_size, new_size, scale, RenderTarget, true , 0 , true );
4011+ if (tgt && exact_match)
4012+ {
4013+ // Exact match, so it's likely that the game uploaded the whole frame to memory.
4014+ // Since we will be loading this from memory, flag the data as valid.
4015+ // Needed in case the game draws on top of the frame (e.g. for a pause screen) to prevent
4016+ // the loaded data from being nuked because it's assumed to be invalid.
4017+ const u32 channel_mask = GSUtil::GetChannelMask (exact_match_psm);
4018+ if (channel_mask & 7 )
4019+ {
4020+ tgt->m_valid_rgb = true ;
4021+ }
4022+ if (channel_mask & 8 )
4023+ {
4024+ tgt->m_valid_alpha_low = true ;
4025+ tgt->m_valid_alpha_high = true ;
4026+ }
4027+ }
4028+ return tgt;
4029+ }
4030+ else
4031+ {
4032+ return nullptr ;
4033+ }
40054034}
40064035
40074036void GSTextureCache::Target::ScaleRTAlpha ()
0 commit comments