Skip to content

Commit

Permalink
GSdx-hw: lookup source before target.
Browse files Browse the repository at this point in the history
- this avoids the currently used target to
become the MRU in its cache and correctly keeps
the target used by the previous draw as the MRU
during the lookup source call.
  • Loading branch information
iMineLink committed Dec 13, 2020
1 parent fde7e91 commit 977e492
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions plugins/GSdx/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,34 +1201,12 @@ void GSRendererHW::Draw()
m_channel_shuffle = false;
}

GIFRegTEX0 TEX0;

TEX0.TBP0 = context->FRAME.Block();
TEX0.TBW = context->FRAME.FBW;
TEX0.PSM = context->FRAME.PSM;

GSTextureCache::Target* rt = NULL;
GSTexture* rt_tex = NULL;
if (!no_rt) {
rt = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::RenderTarget, true, fm);
rt_tex = rt->m_texture;
}

TEX0.TBP0 = context->ZBUF.Block();
TEX0.TBW = context->FRAME.FBW;
TEX0.PSM = context->ZBUF.PSM;

GSTextureCache::Target* ds = NULL;
GSTexture* ds_tex = NULL;
if (!no_ds) {
ds = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::DepthStencil, context->DepthWrite());
ds_tex = ds->m_texture;
}

m_src = nullptr;
m_texture_shuffle = false;

if(PRIM->TME)
GIFRegTEX0 TEX0;

if (PRIM->TME)
{
GIFRegCLAMP MIP_CLAMP = context->CLAMP;
int mxl = std::min<int>((int)m_context->TEX1.MXL, 6);
Expand Down Expand Up @@ -1256,12 +1234,14 @@ void GSRendererHW::Draw()
if (lcm == 1) {
m_lod.x = std::max<int>(k, 0);
m_lod.y = m_lod.x;
} else {
}
else {
// Not constant but who care !
if (interpolation == 2) {
// Mipmap Linear. Both layers are sampled, only take the big one
m_lod.x = std::max<int>((int)floor(m_vt.m_lod.x), 0);
} else {
}
else {
// On GS lod is a fixed float number 7:4 (4 bit for the frac part)
#if 0
m_lod.x = std::max<int>((int)round(m_vt.m_lod.x + 0.0625), 0);
Expand Down Expand Up @@ -1295,7 +1275,8 @@ void GSRendererHW::Draw()
}

GL_CACHE("Mipmap LOD %d %d (%f %f) new size %dx%d (K %d L %u)", m_lod.x, m_lod.y, m_vt.m_lod.x, m_vt.m_lod.y, 1 << TEX0.TW, 1 << TEX0.TH, m_context->TEX1.K, m_context->TEX1.L);
} else {
}
else {
TEX0 = GetTex0Layer(0);
}

Expand Down Expand Up @@ -1371,10 +1352,34 @@ void GSRendererHW::Draw()
if (m_src->m_target && m_context->TEX0.PSM == PSM_PSMT8 && single_page && draw_sprite_tex) {
GL_INS("Channel shuffle effect detected (2nd shot)");
m_channel_shuffle = true;
} else {
}
else {
m_channel_shuffle = false;
}
}

TEX0.TBP0 = context->FRAME.Block();
TEX0.TBW = context->FRAME.FBW;
TEX0.PSM = context->FRAME.PSM;

GSTextureCache::Target* rt = NULL;
GSTexture* rt_tex = NULL;
if (!no_rt) {
rt = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::RenderTarget, true, fm);
rt_tex = rt->m_texture;
}

TEX0.TBP0 = context->ZBUF.Block();
TEX0.TBW = context->FRAME.FBW;
TEX0.PSM = context->ZBUF.PSM;

GSTextureCache::Target* ds = NULL;
GSTexture* ds_tex = NULL;
if (!no_ds) {
ds = m_tc->LookupTarget(TEX0, m_width, m_height, GSTextureCache::DepthStencil, context->DepthWrite());
ds_tex = ds->m_texture;
}

if (rt) {
// Be sure texture shuffle detection is properly propagated
// Otherwise set or clear the flag (Code in texture cache only set the flag)
Expand Down

0 comments on commit 977e492

Please sign in to comment.