GS-HW: Check for CLUT upload before invalidating or running on GPU.

Clean up some preload code and improve the detection.
This commit is contained in:
refractionpcsx2 2023-01-31 11:49:00 +00:00
parent 8ac21357c3
commit 4c7ad66bd7
2 changed files with 17 additions and 7 deletions

View File

@ -209,6 +209,7 @@ void GSRendererHW::VSync(u32 field, bool registers_written)
else
m_force_preload = false;
m_draw_transfers.clear();
if (GSConfig.LoadTextureReplacements)
GSTextureReplacements::ProcessAsyncLoadedTextures();
@ -4002,6 +4003,12 @@ GSRendererHW::CLUTDrawTestResult GSRendererHW::PossibleCLUTDraw()
// If we have GPU CLUT enabled, don't do a CPU draw when it would result in a download.
if (GSConfig.UserHacks_GPUTargetCLUTMode != GSGPUTargetCLUTMode::Disabled)
{
for (auto upload : m_draw_transfers)
{
if (upload.DBP == m_context->TEX0.TBP0 && GSUtil::HasSharedBits(upload.DPSM, m_context->TEX0.PSM))
return CLUTDrawTestResult::CLUTDrawOnCPU;
}
GSTextureCache::Target* tgt = m_tc->GetExactTarget(m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM);
if (tgt)
{
@ -4021,6 +4028,14 @@ GSRendererHW::CLUTDrawTestResult GSRendererHW::PossibleCLUTDraw()
}
}
}
else
{
for (auto upload : m_draw_transfers)
{
if (upload.DBP == m_context->TEX0.TBP0 && GSUtil::HasSharedBits(upload.DPSM, m_context->TEX0.PSM))
return CLUTDrawTestResult::CLUTDrawOnCPU;
}
}
GIFRegBITBLTBUF BITBLTBUF = {};
BITBLTBUF.SBP = m_context->TEX0.TBP0;

View File

@ -706,12 +706,9 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, con
{
if (!is_frame && !forced_preload)
{
// Check for an EE transfer that matches our RT.
while (static_cast<GSRendererHW*>(g_gs_renderer.get())->m_draw_transfers.size() > 0)
for (auto transfer : static_cast<GSRendererHW*>(g_gs_renderer.get())->m_draw_transfers)
{
const GIFRegBITBLTBUF* transfer = &static_cast<GSRendererHW*>(g_gs_renderer.get())->m_draw_transfers.front();
if (transfer->DBP == TEX0.TBP0 && GSUtil::HasSharedBits(transfer->DPSM, TEX0.PSM))
if (transfer.DBP == TEX0.TBP0 && GSUtil::HasSharedBits(transfer.DPSM, TEX0.PSM))
{
GL_INS("Preloading the RT DATA");
const GSVector4i newrect = GSVector4i(0, 0, real_w, real_h);
@ -719,7 +716,6 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, con
dst->Update(true);
break;
}
static_cast<GSRendererHW*>(g_gs_renderer.get())->m_draw_transfers.pop_front();
}
}
else
@ -729,7 +725,6 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, con
AddDirtyRectTarget(dst, newrect, TEX0.PSM, TEX0.TBW);
dst->Update(true);
}
static_cast<GSRendererHW*>(g_gs_renderer.get())->m_draw_transfers.clear();
}
}
if (used)