mirror of https://github.com/PCSX2/pcsx2.git
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:
parent
babb5480ce
commit
6f9a89dcf2
|
@ -146,6 +146,20 @@ GSTexture* GSDevice::FetchSurface(int type, int w, int h, bool msaa, int format)
|
||||||
return CreateSurface(type, w, h, msaa, 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()
|
void GSDevice::EndScene()
|
||||||
{
|
{
|
||||||
m_vertex.start += m_vertex.count;
|
m_vertex.start += m_vertex.count;
|
||||||
|
|
|
@ -173,6 +173,8 @@ public:
|
||||||
bool IsRBSwapped() {return m_rbswapped;}
|
bool IsRBSwapped() {return m_rbswapped;}
|
||||||
|
|
||||||
void AgePool();
|
void AgePool();
|
||||||
|
|
||||||
|
virtual void PrintMemoryUsage();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GSAdapter
|
struct GSAdapter
|
||||||
|
|
|
@ -137,6 +137,9 @@ void GSRendererHW::VSync(int field)
|
||||||
|
|
||||||
m_tc->IncAge();
|
m_tc->IncAge();
|
||||||
|
|
||||||
|
m_tc->PrintMemoryUsage();
|
||||||
|
m_dev->PrintMemoryUsage();
|
||||||
|
|
||||||
m_skip = 0;
|
m_skip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,4 +69,7 @@ public:
|
||||||
bool LikelyOffset;
|
bool LikelyOffset;
|
||||||
float OffsetHack_modx;
|
float OffsetHack_modx;
|
||||||
float OffsetHack_mody;
|
float OffsetHack_mody;
|
||||||
|
|
||||||
|
// Typical size of a RGBA texture
|
||||||
|
virtual uint32 GetMemUsage() { return m_size.x * m_size.y * 4; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -1143,6 +1143,38 @@ GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int
|
||||||
return t;
|
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
|
||||||
|
|
||||||
GSTextureCache::Surface::Surface(GSRenderer* r, uint8* temp)
|
GSTextureCache::Surface::Surface(GSRenderer* r, uint8* temp)
|
||||||
|
|
|
@ -154,4 +154,6 @@ public:
|
||||||
const char* to_string(int type) {
|
const char* to_string(int type) {
|
||||||
return (type == DepthStencil) ? "Depth" : "Color";
|
return (type == DepthStencil) ? "Depth" : "Color";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintMemoryUsage();
|
||||||
};
|
};
|
||||||
|
|
|
@ -251,7 +251,8 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read)
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case GSTexture::Offscreen:
|
case GSTexture::Offscreen:
|
||||||
// 8B is the worst case for depth/stencil
|
// 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::Texture:
|
||||||
case GSTexture::RenderTarget:
|
case GSTexture::RenderTarget:
|
||||||
case GSTexture::DepthStencil:
|
case GSTexture::DepthStencil:
|
||||||
|
@ -567,3 +568,18 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
|
||||||
return status;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -76,4 +76,6 @@ class GSTextureOGL : public GSTexture
|
||||||
bool HasBeenCleaned() { return m_clean; }
|
bool HasBeenCleaned() { return m_clean; }
|
||||||
void WasAttached() { m_clean = false; m_dirty = true; }
|
void WasAttached() { m_clean = false; m_dirty = true; }
|
||||||
void WasCleaned() { m_clean = true; }
|
void WasCleaned() { m_clean = true; }
|
||||||
|
|
||||||
|
uint32 GetMemUsage();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue