mirror of https://github.com/PCSX2/pcsx2.git
gsdx tc: move code to allow to lookup an older target if none was found
Next step is to enable it by uncommenting line 452
This commit is contained in:
parent
24684033ca
commit
7bb201a1d2
|
@ -437,35 +437,41 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||||
} else if (CanConvertDepth()) {
|
} else if (CanConvertDepth()) {
|
||||||
|
|
||||||
int rev_type = (type == DepthStencil) ? RenderTarget : DepthStencil;
|
int rev_type = (type == DepthStencil) ? RenderTarget : DepthStencil;
|
||||||
GSVector4 sRect(0, 0, 1, 1);
|
|
||||||
GSVector4 dRect(0, 0, w, h);
|
|
||||||
|
|
||||||
// Depth stencil/RT can be an older RT/DS but only check recent RT/DS to avoid to pick
|
// Depth stencil/RT can be an older RT/DS but only check recent RT/DS to avoid to pick
|
||||||
// some bad data.
|
// some bad data.
|
||||||
|
Target* dst_match = nullptr;
|
||||||
for(list<Target*>::iterator i = m_dst[rev_type].begin(); i != m_dst[rev_type].end(); ++i)
|
for(list<Target*>::iterator i = m_dst[rev_type].begin(); i != m_dst[rev_type].end(); ++i) {
|
||||||
{
|
|
||||||
Target* t = *i;
|
Target* t = *i;
|
||||||
|
|
||||||
if(!t->m_age && bp == t->m_TEX0.TBP0)
|
if (bp == t->m_TEX0.TBP0) {
|
||||||
{
|
if (t->m_age == 0) {
|
||||||
dst = CreateTarget(TEX0, w, h, type);
|
dst_match = t;
|
||||||
dst->m_32_bits_fmt = t->m_32_bits_fmt;
|
break;
|
||||||
|
} else if (t->m_age == 1) {
|
||||||
int shader;
|
//dst_match = t;
|
||||||
bool fmt_16_bits = (psm_s.bpp == 16 && GSLocalMemory::m_psm[t->m_TEX0.PSM].bpp == 16);
|
|
||||||
if (type == DepthStencil) {
|
|
||||||
GL_CACHE("TC: Lookup Target(Depth) %dx%d, hit Color (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(t->m_TEX0.PSM));
|
|
||||||
shader = (fmt_16_bits) ? ShaderConvert_RGB5A1_TO_FLOAT16 : ShaderConvert_RGBA8_TO_FLOAT32 + psm_s.fmt;
|
|
||||||
} else {
|
|
||||||
GL_CACHE("TC: Lookup Target(Color) %dx%d, hit Depth (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(t->m_TEX0.PSM));
|
|
||||||
shader = (fmt_16_bits) ? ShaderConvert_FLOAT16_TO_RGB5A1 : ShaderConvert_FLOAT32_TO_RGBA8;
|
|
||||||
}
|
}
|
||||||
m_renderer->m_dev->StretchRect(t->m_texture, sRect, dst->m_texture, dRect, shader, false);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dst_match) {
|
||||||
|
GSVector4 sRect(0, 0, 1, 1);
|
||||||
|
GSVector4 dRect(0, 0, w, h);
|
||||||
|
|
||||||
|
dst = CreateTarget(TEX0, w, h, type);
|
||||||
|
dst->m_32_bits_fmt = dst_match->m_32_bits_fmt;
|
||||||
|
|
||||||
|
int shader;
|
||||||
|
bool fmt_16_bits = (psm_s.bpp == 16 && GSLocalMemory::m_psm[dst_match->m_TEX0.PSM].bpp == 16);
|
||||||
|
if (type == DepthStencil) {
|
||||||
|
GL_CACHE("TC: Lookup Target(Depth) %dx%d, hit Color (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(dst_match->m_TEX0.PSM));
|
||||||
|
shader = (fmt_16_bits) ? ShaderConvert_RGB5A1_TO_FLOAT16 : ShaderConvert_RGBA8_TO_FLOAT32 + psm_s.fmt;
|
||||||
|
} else {
|
||||||
|
GL_CACHE("TC: Lookup Target(Color) %dx%d, hit Depth (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(dst_match->m_TEX0.PSM));
|
||||||
|
shader = (fmt_16_bits) ? ShaderConvert_FLOAT16_TO_RGB5A1 : ShaderConvert_FLOAT32_TO_RGBA8;
|
||||||
|
}
|
||||||
|
m_renderer->m_dev->StretchRect(dst_match->m_texture, sRect, dst->m_texture, dRect, shader, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dst == NULL)
|
if(dst == NULL)
|
||||||
|
@ -489,7 +495,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||||
if (type == DepthStencil) {
|
if (type == DepthStencil) {
|
||||||
// It is safer to always clear a new depth buffer. Core optimization might create some shortcut
|
// It is safer to always clear a new depth buffer. Core optimization might create some shortcut
|
||||||
// on the rendering. Texture cache only search old depth data in RT of current frame. Which
|
// on the rendering. Texture cache only search old depth data in RT of current frame. Which
|
||||||
// can cause flickering (Jak2 FMV)
|
// can cause flickering (Jak2 cutscene)
|
||||||
m_renderer->m_dev->ClearDepth(dst->m_texture);
|
m_renderer->m_dev->ClearDepth(dst->m_texture);
|
||||||
} else if (m_preload_frame && TEX0.TBW > 0) {
|
} else if (m_preload_frame && TEX0.TBW > 0) {
|
||||||
GL_INS("Preloading the RT DATA");
|
GL_INS("Preloading the RT DATA");
|
||||||
|
|
Loading…
Reference in New Issue