gsdx mipmap:tc: add code to update a single layer of a mipmap

This commit is contained in:
Gregory Hainaut 2016-09-30 21:37:24 +02:00
parent dbb4bdf59f
commit 15b1d8d3f0
2 changed files with 30 additions and 5 deletions

View File

@ -1562,6 +1562,8 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
m_repeating = false; m_repeating = false;
} else { } else {
memset(m_layer_TEX0, 0, sizeof(m_layer_TEX0));
memset(m_valid, 0, sizeof(m_valid)); memset(m_valid, 0, sizeof(m_valid));
m_clut = (uint32*)_aligned_malloc(256 * sizeof(uint32), 32); m_clut = (uint32*)_aligned_malloc(256 * sizeof(uint32), 32);
@ -1593,7 +1595,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int layer)
{ {
Surface::UpdateAge(); Surface::UpdateAge();
if(m_complete || m_target) if(layer == 0 && (m_complete || m_target))
{ {
return; return;
} }
@ -1605,7 +1607,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int layer)
GSVector4i r = rect.ralign<Align_Outside>(bs); GSVector4i r = rect.ralign<Align_Outside>(bs);
if(r.eq(GSVector4i(0, 0, tw, th))) if(layer == 0 && r.eq(GSVector4i(0, 0, tw, th)))
{ {
m_complete = true; // lame, but better than nothing m_complete = true; // lame, but better than nothing
} }
@ -1679,6 +1681,27 @@ void GSTextureCache::Source::Update(const GSVector4i& rect, int layer)
} }
} }
void GSTextureCache::Source::UpdateLayer(const GIFRegTEX0& TEX0, const GSVector4i& rect, int layer)
{
if (layer > 6)
return;
if (m_target) // Yeah keep dreaming
return;
if (TEX0 == m_layer_TEX0[layer])
return;
GIFRegTEX0 old_TEX0 = m_TEX0;
m_layer_TEX0[layer] = TEX0;
m_TEX0 = TEX0;
Update(rect, layer);
m_TEX0 = old_TEX0;
}
void GSTextureCache::Source::Write(const GSVector4i& r, int layer) void GSTextureCache::Source::Write(const GSVector4i& r, int layer)
{ {
m_write.rect[m_write.count++] = r; m_write.rect[m_write.count++] = r;
@ -1750,13 +1773,13 @@ void GSTextureCache::Source::Flush(uint32 count, int layer)
{ {
(mem.*rtx)(off, r, buff, pitch, m_TEXA); (mem.*rtx)(off, r, buff, pitch, m_TEXA);
m_texture->Update(r.rintersect(tr), buff, pitch); m_texture->Update(r.rintersect(tr), buff, pitch, layer);
} }
else else
{ {
GSTexture::GSMap m; GSTexture::GSMap m;
if(m_texture->Map(m, &r)) if(m_texture->Map(m, &r, layer))
{ {
(mem.*rtx)(off, r, m.bits, m.pitch, m_TEXA); (mem.*rtx)(off, r, m.bits, m.pitch, m_TEXA);
@ -1766,7 +1789,7 @@ void GSTextureCache::Source::Flush(uint32 count, int layer)
{ {
(mem.*rtx)(off, r, buff, pitch, m_TEXA); (mem.*rtx)(off, r, buff, pitch, m_TEXA);
m_texture->Update(r, buff, pitch); m_texture->Update(r, buff, pitch, layer);
} }
} }
} }

View File

@ -71,12 +71,14 @@ public:
// still be valid on future. However it ought to be good when the source is created // still be valid on future. However it ought to be good when the source is created
// so it can be used to access un-converted data for the current draw call. // so it can be used to access un-converted data for the current draw call.
GSTexture* m_from_target; GSTexture* m_from_target;
GIFRegTEX0 m_layer_TEX0[7]; // Detect already loaded value
public: public:
Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp, bool dummy_container = false); Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp, bool dummy_container = false);
virtual ~Source(); virtual ~Source();
void Update(const GSVector4i& rect, int layer = 0); void Update(const GSVector4i& rect, int layer = 0);
void UpdateLayer(const GIFRegTEX0& TEX0, const GSVector4i& rect, int layer = 0);
}; };
class Target : public Surface class Target : public Surface