GS/TextureCache: Fix non-mipmap sources conflicting with mipmap sources

Fixes building flicker in Burnout 3 with Full mipmapping, as the first
draws don't use mipmapping, but the others do, resulting in the texture
having whatever was last left in it before it was recycled.
This commit is contained in:
Connor McLaughlin 2022-09-28 20:25:02 +10:00 committed by refractionpcsx2
parent 7d1e7f2b58
commit f1cb13fd94
2 changed files with 10 additions and 0 deletions

View File

@ -207,6 +207,7 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
auto& m = m_src.m_map[TEX0.TBP0 >> 5];
const GSVector2i compare_lod(lod ? *lod : GSVector2i(0, 0));
for (auto i = m.begin(); i != m.end(); ++i)
{
Source* s = *i;
@ -227,6 +228,11 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
// the CPU. We need to check that TEXA is identical
if (psm_s.pal == 0 && psm_s.fmt > 0 && s->m_TEXA.U64 != TEXA.U64)
continue;
// Same base mip texture, but we need to check that MXL was the same as well.
// When mipmapping is off, this will be 0,0 vs 0,0.
if (s->m_lod != compare_lod)
continue;
}
m.MoveFront(i.Index());
@ -1556,6 +1562,8 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM];
Source* src = new Source(TEX0, TEXA, false);
if (lod)
src->m_lod = *lod;
int tw = 1 << TEX0.TW;
int th = 1 << TEX0.TH;
@ -2276,6 +2284,7 @@ GSTextureCache::Source::Source(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, b
: m_palette_obj(nullptr)
, m_palette(nullptr)
, m_valid_rect(0, 0)
, m_lod(0, 0)
, m_target(false)
, m_p2t(NULL)
, m_from_target(NULL)

View File

@ -159,6 +159,7 @@ public:
std::unique_ptr<u32[]> m_valid;// each u32 bits map to the 32 blocks of that page
GSTexture* m_palette;
GSVector4i m_valid_rect;
GSVector2i m_lod;
u8 m_valid_hashes = 0;
u8 m_complete_layers = 0;
bool m_target;