Skip to content

Commit 490e153

Browse files
committed
GS/HW: Set valid flags if display target has exact match with recent transfer.
1 parent c1aa19c commit 490e153

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

pcsx2/GS/Renderers/Common/GSRenderer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ void GSRenderer::VSync(u32 field, bool registers_written, bool idle_frame)
840840
}
841841
}
842842
}
843+
844+
if (GSConfig.ShouldDump(s_n, g_perfmon.GetFrame()) && GSConfig.SaveTransferImages)
845+
DumpTransferImages();
843846
}
844847

845848
void GSRenderer::QueueSnapshot(const std::string& path, const u32 gsdump_frames)

pcsx2/GS/Renderers/HW/GSTextureCache.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

40074036
void GSTextureCache::Target::ScaleRTAlpha()

0 commit comments

Comments
 (0)