From bd96a73580033786b08545296ae48107c8e28d54 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 13 May 2015 08:49:32 +0200 Subject: [PATCH] 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 --- plugins/GSdx/GSTextureCache.cpp | 23 ++++++++++++++++++++++- plugins/GSdx/stdafx.h | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index dbec297e0a..70ba3c3bfd 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -128,12 +128,29 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con 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); if(src == 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) @@ -718,7 +735,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con GSVector4 sr(0, 0, w, h); 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 // 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. @@ -1250,6 +1267,10 @@ void GSTextureCache::SourceMap::RemoveAt(Source* 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. for(size_t start = s->m_TEX0.TBP0 >> 5, end = s->m_target ? start : countof(m_map) - 1; start <= end; start++) { diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 8c5aa7bdd8..1834f4c558 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -494,6 +494,12 @@ extern void vmfree(void* ptr, size_t size); #endif // 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) #define GL_PUSH(s) gl_PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, s); #define GL_POP(s) gl_PopDebugGroup();