gsdx-debug: trace texture cache hit/miss/removal

Actually only a small part but I think it is enough to help debugging
tc issue.
Only enable it on debug because it is quite verbose
This commit is contained in:
Gregory Hainaut 2015-05-13 08:49:32 +02:00
parent 5e9a3a424e
commit bd96a73580
2 changed files with 28 additions and 1 deletions

View File

@ -128,12 +128,29 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
if(src == NULL) if(src == NULL)
{ {
#ifdef ENABLE_OGL_DEBUG
if (dst) {
GL_CACHE(format("TC: dst hit: %d (%x)",
dst->m_texture ? dst->m_texture->GetID() : 0,
TEX0.TBP0
).c_str());
} else {
GL_CACHE(format("TC: src miss (%x)", TEX0.TBP0).c_str());
}
#endif
src = CreateSource(TEX0, TEXA, dst); src = CreateSource(TEX0, TEXA, dst);
if(src == NULL) if(src == NULL)
{ {
return NULL; return NULL;
} }
#ifdef ENABLE_OGL_DEBUG
} else {
GL_CACHE(format("TC: src hit: %d (%x)",
src->m_texture ? src->m_texture->GetID() : 0,
TEX0.TBP0
).c_str());
#endif
} }
if (src->m_palette) if (src->m_palette)
@ -718,7 +735,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
GSVector4 sr(0, 0, w, h); GSVector4 sr(0, 0, w, h);
GSTexture* st = src->m_texture ? src->m_texture : dst->m_texture; GSTexture* st = src->m_texture ? src->m_texture : dst->m_texture;
GSTexture *dt = m_renderer->m_dev->CreateRenderTarget(w, h, false); GSTexture* dt = m_renderer->m_dev->CreateRenderTarget(w, h, false);
// GH: by default (m_paltex == 0) GSdx converts texture to the 32 bit format // GH: by default (m_paltex == 0) GSdx converts texture to the 32 bit format
// However it is different here. We want to reuse a Render Target as a texture. // However it is different here. We want to reuse a Render Target as a texture.
// Because the texture is already on the GPU, CPU can't convert it. // Because the texture is already on the GPU, CPU can't convert it.
@ -1250,6 +1267,10 @@ void GSTextureCache::SourceMap::RemoveAt(Source* s)
{ {
m_surfaces.erase(s); m_surfaces.erase(s);
GL_CACHE(format("TC: remove texture %d (%x)",
s->m_texture ? s->m_texture->GetID() : 0,
s->m_TEX0.TBP0).c_str());
// Source (except render target) is duplicated for each page they use. // Source (except render target) is duplicated for each page they use.
for(size_t start = s->m_TEX0.TBP0 >> 5, end = s->m_target ? start : countof(m_map) - 1; start <= end; start++) for(size_t start = s->m_TEX0.TBP0 >> 5, end = s->m_target ? start : countof(m_map) - 1; start <= end; start++)
{ {

View File

@ -494,6 +494,12 @@ extern void vmfree(void* ptr, size_t size);
#endif #endif
// Except apple any sane driver support this extension // Except apple any sane driver support this extension
#if defined(__linux__) && defined(_DEBUG)
#define GL_CACHE(s) gl_DebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0xFEAD, GL_DEBUG_SEVERITY_MEDIUM, -1, s);
#else
#define GL_CACHE(s) (0);
#endif
#if defined(__linux__) && defined(ENABLE_OGL_DEBUG) #if defined(__linux__) && defined(ENABLE_OGL_DEBUG)
#define GL_PUSH(s) gl_PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, s); #define GL_PUSH(s) gl_PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, s);
#define GL_POP(s) gl_PopDebugGroup(); #define GL_POP(s) gl_PopDebugGroup();