gsdx-debug: print memory usage of all textures pools

It is a bit crude but it allow to see the impact of code and options.
This commit is contained in:
Gregory Hainaut 2015-07-10 21:11:14 +02:00
parent babb5480ce
commit 6f9a89dcf2
8 changed files with 75 additions and 1 deletions

View File

@ -146,6 +146,20 @@ GSTexture* GSDevice::FetchSurface(int type, int w, int h, bool msaa, int format)
return CreateSurface(type, w, h, msaa, format);
}
void GSDevice::PrintMemoryUsage()
{
#ifdef ENABLE_OGL_DEBUG
uint32 pool = 0;
for(list<GSTexture*>::iterator i = m_pool.begin(); i != m_pool.end(); i++)
{
GSTexture* t = *i;
if (t)
pool += t->GetMemUsage();
}
GL_PERF("MEM: Surface Pool %dMB", pool >> 20u);
#endif
}
void GSDevice::EndScene()
{
m_vertex.start += m_vertex.count;

View File

@ -173,6 +173,8 @@ public:
bool IsRBSwapped() {return m_rbswapped;}
void AgePool();
virtual void PrintMemoryUsage();
};
struct GSAdapter

View File

@ -137,6 +137,9 @@ void GSRendererHW::VSync(int field)
m_tc->IncAge();
m_tc->PrintMemoryUsage();
m_dev->PrintMemoryUsage();
m_skip = 0;
}

View File

@ -69,4 +69,7 @@ public:
bool LikelyOffset;
float OffsetHack_modx;
float OffsetHack_mody;
// Typical size of a RGBA texture
virtual uint32 GetMemUsage() { return m_size.x * m_size.y * 4; }
};

View File

@ -1143,6 +1143,38 @@ GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int
return t;
}
void GSTextureCache::PrintMemoryUsage()
{
#ifdef ENABLE_OGL_DEBUG
uint32 tex = 0;
uint32 tex_rt = 0;
uint32 rt = 0;
uint32 dss = 0;
for(hash_set<Source*>::iterator i = m_src.m_surfaces.begin(); i != m_src.m_surfaces.end(); i++) {
Source* s = *i;
if (s) {
if (s->m_target)
tex_rt += s->m_texture->GetMemUsage();
else
tex += s->m_texture->GetMemUsage();
}
}
for(list<Target*>::iterator i = m_dst[RenderTarget].begin(); i != m_dst[RenderTarget].end(); i++) {
Target* t = *i;
if (t)
rt += t->m_texture->GetMemUsage();
}
for(list<Target*>::iterator i = m_dst[DepthStencil].begin(); i != m_dst[DepthStencil].end(); i++) {
Target* t = *i;
if (t)
dss += t->m_texture->GetMemUsage();
}
GL_PERF("MEM: RO Tex %dMB. RW Tex %dMB. Target %dMB. Depth %dMB", tex >> 20u, tex_rt >> 20u, rt >> 20u, dss >> 20u);
#endif
}
// GSTextureCache::Surface
GSTextureCache::Surface::Surface(GSRenderer* r, uint8* temp)

View File

@ -154,4 +154,6 @@ public:
const char* to_string(int type) {
return (type == DepthStencil) ? "Depth" : "Color";
}
void PrintMemoryUsage();
};

View File

@ -251,7 +251,8 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read)
switch (m_type) {
case GSTexture::Offscreen:
// 8B is the worst case for depth/stencil
m_local_buffer = (uint8*)_aligned_malloc(m_size.x * m_size.y * 8, 32);
// FIXME I think it is only used for color. So you can save half of the size
m_local_buffer = (uint8*)_aligned_malloc(m_size.x * m_size.y * 4, 32);
case GSTexture::Texture:
case GSTexture::RenderTarget:
case GSTexture::DepthStencil:
@ -567,3 +568,18 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
return status;
}
uint32 GSTextureOGL::GetMemUsage()
{
switch (m_type) {
case GSTexture::Offscreen:
return m_size.x * m_size.y * (4 + m_int_alignment);
case GSTexture::Texture:
case GSTexture::RenderTarget:
return m_size.x * m_size.y * m_int_alignment;
case GSTexture::DepthStencil:
return m_size.x * m_size.y * 8;
case GSTexture::Backbuffer:
default:
return 0;
}
}

View File

@ -76,4 +76,6 @@ class GSTextureOGL : public GSTexture
bool HasBeenCleaned() { return m_clean; }
void WasAttached() { m_clean = false; m_dirty = true; }
void WasCleaned() { m_clean = true; }
uint32 GetMemUsage();
};