gsdx tc: allow to create a dummy Source without tons of memory allocation

It makes shared texture virtually free from the CPU PoV.
This commit is contained in:
Gregory Hainaut 2016-04-24 22:30:56 +02:00
parent ad08701cb1
commit 49d175b677
2 changed files with 24 additions and 12 deletions

View File

@ -125,7 +125,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
TEX0.TBP0, TEX0.PSM);
// Create a shared texture source
src = new Source(m_renderer, TEX0, TEXA, m_temp);
src = new Source(m_renderer, TEX0, TEXA, m_temp, true);
src->m_texture = dst->m_texture;
src->m_shared_texture = true;
src->m_target = true; // So renderer can check if a conversion is required
@ -1480,7 +1480,7 @@ void GSTextureCache::Surface::Update()
// GSTextureCache::Source
GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp)
GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp, bool dummy_container)
: Surface(r, temp)
, m_palette(NULL)
, m_initpalette(true)
@ -1492,6 +1492,17 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
m_TEX0 = TEX0;
m_TEXA = TEXA;
if (dummy_container) {
// Dummy container only contain a m_texture that is a pointer to another source.
m_write.rect = NULL;
m_write.count = 0;
m_clut = NULL;
m_repeating = false;
} else {
memset(m_valid, 0, sizeof(m_valid));
m_clut = (uint32*)_aligned_malloc(256 * sizeof(uint32), 32);
@ -1507,6 +1518,7 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
{
m_p2t = r->m_mem.GetPage2TileMap(m_TEX0);
}
}
}
GSTextureCache::Source::~Source()

View File

@ -69,7 +69,7 @@ public:
vector<GSVector2i>* m_p2t;
public:
Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp);
Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp, bool dummy_container = false);
virtual ~Source();
virtual void Update(const GSVector4i& rect);