From b1ea081fc31b01271437137e90f3c69438959d50 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 16 May 2015 19:28:22 +0200 Subject: [PATCH] gsdx-debug: improve tracing interface Basically move the format and c_str() in the macro --- plugins/GSdx/GSDeviceOGL.cpp | 16 ++++++------- plugins/GSdx/GSDeviceOGL.h | 2 +- plugins/GSdx/GSRendererHW.cpp | 4 ++-- plugins/GSdx/GSRendererOGL.cpp | 5 ++-- plugins/GSdx/GSTextureCache.cpp | 38 ++++++++++++++---------------- plugins/GSdx/GSTextureCacheOGL.cpp | 5 ++-- plugins/GSdx/GSTextureOGL.cpp | 2 +- plugins/GSdx/stdafx.h | 16 ++++++------- 8 files changed, 42 insertions(+), 46 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index cc5787336f..8625ea22a4 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -147,13 +147,13 @@ GSDeviceOGL::~GSDeviceOGL() GL_POP(); } -GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int format) +GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt) { GL_PUSH("Create surface"); // A wrapper to call GSTextureOGL, with the different kind of parameter GSTextureOGL* t = NULL; - t = new GSTextureOGL(type, w, h, format, m_fbo_read); + t = new GSTextureOGL(type, w, h, fmt, m_fbo_read); // NOTE: I'm not sure RenderTarget always need to be cleared. It could be costly for big upscale. switch(type) @@ -430,7 +430,7 @@ void GSDeviceOGL::ClearRenderTarget(GSTexture* t, const GSVector4& c) if (T->HasBeenCleaned() && !T->IsBackbuffer()) return; - GL_PUSH(format("Clear RT %d", T->GetID()).c_str()); + GL_PUSH("Clear RT %d", T->GetID()); // TODO: check size of scissor before toggling it glDisable(GL_SCISSOR_TEST); @@ -471,7 +471,7 @@ void GSDeviceOGL::ClearRenderTarget_i(GSTexture* t, int32 c) { GSTextureOGL* T = static_cast(t); - GL_PUSH(format("Clear RTi %d", T->GetID()).c_str()); + GL_PUSH("Clear RTi %d", T->GetID()); uint32 old_color_mask = GLState::wrgba; OMSetColorMaskState(); @@ -494,7 +494,7 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c) { GSTextureOGL* T = static_cast(t); - GL_PUSH(format("Clear Depth %d", T->GetID()).c_str()); + GL_PUSH("Clear Depth %d", T->GetID()); OMSetFBO(m_fbo); OMAttachDs(T); @@ -517,7 +517,7 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c) { GSTextureOGL* T = static_cast(t); - GL_PUSH(format("Clear Stencil %d", T->GetID()).c_str()); + GL_PUSH("Clear Stencil %d", T->GetID()); // Keep SCISSOR_TEST enabled on purpose to reduce the size // of clean in DATE (impact big upscaling) @@ -694,7 +694,7 @@ void GSDeviceOGL::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r const GLuint& sid = sTex->GetID(); const GLuint& did = dTex->GetID(); - GL_PUSH(format("CopyRect from %d to %d", sid, did).c_str()); + GL_PUSH("CopyRect from %d to %d", sid, did); if (GLLoader::found_GL_ARB_copy_image) { gl_CopyImageSubData( sid, GL_TEXTURE_2D, @@ -734,7 +734,7 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture return; } - GL_PUSH(format("StretchRect from %d to %d", sTex->GetID(), dTex->GetID()).c_str()); + GL_PUSH("StretchRect from %d to %d", sTex->GetID(), dTex->GetID()); // ************************************ // Init diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 03f71355c8..c43674fd4c 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -92,7 +92,7 @@ public: #ifdef ENABLE_OGL_DEBUG if (m_bogus > 2) { - GL_INS(format("!!! Bogus blending effect used (%d) !!!", m_bogus).c_str()); + GL_INS("!!! Bogus blending effect used (%d) !!!", m_bogus); } #endif if (m_enable) { diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index f1d7af817e..0d4af0ec02 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -313,7 +313,7 @@ void GSRendererHW::Draw() s_n += 3; // Keep it sync with SW renderer return; } - GL_PUSH(format("HW Draw %d", s_n).c_str()); + GL_PUSH("HW Draw %d", s_n); GSDrawingEnvironment& env = m_env; GSDrawingContext* context = m_context; @@ -447,7 +447,7 @@ void GSRendererHW::Draw() context->FRAME.FBMSK = fm; context->ZBUF.ZMSK = zm != 0; - // A couple of hack to avoid upscaling issue. So far it seems to impacts only sprite without linear filtering + // A couple of hack to avoid upscaling issue. So far it seems to impacts mostly sprite if ((m_upscale_multiplier > 1) && (m_vt.m_primclass == GS_SPRITE_CLASS)) { size_t count = m_vertex.next; GSVertex* v = &m_vertex.buff[0]; diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 344f1cea8f..726591c597 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -211,10 +211,9 @@ void GSRendererOGL::SendDraw(bool require_barrier) void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { - GL_PUSH(format("GL Draw from %d in %d (Depth %d)", + GL_PUSH("GL Draw from %d in %d (Depth %d)", tex && tex->m_texture ? tex->m_texture->GetID() : 0, - rt->GetID(), - ds->GetID()).c_str()); + rt->GetID(), ds->GetID()); GSDrawingEnvironment& env = m_env; GSDrawingContext* context = m_context; diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 6dbedb7ec8..205f54f889 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -130,12 +130,11 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con { #ifdef ENABLE_OGL_DEBUG if (dst) { - GL_CACHE(format("TC: dst hit: %d (0x%x)", + GL_CACHE("TC: dst hit: %d (0x%x)", dst->m_texture ? dst->m_texture->GetID() : 0, - TEX0.TBP0 - ).c_str()); + TEX0.TBP0); } else { - GL_CACHE(format("TC: src miss (0x%x)", TEX0.TBP0).c_str()); + GL_CACHE("TC: src miss (0x%x)", TEX0.TBP0); } #endif src = CreateSource(TEX0, TEXA, dst); @@ -146,10 +145,9 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con } #ifdef ENABLE_OGL_DEBUG } else { - GL_CACHE(format("TC: src hit: %d (0x%x)", + GL_CACHE("TC: src hit: %d (0x%x)", src->m_texture ? src->m_texture->GetID() : 0, - TEX0.TBP0 - ).c_str()); + TEX0.TBP0); #endif } @@ -195,7 +193,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int if(dst == NULL) { - GL_CACHE(format("TC: Lookup Target(T%d) %dx%d, miss (0x%x)", type, w, h, bp).c_str()); + GL_CACHE("TC: Lookup Target(T%d) %dx%d, miss (0x%x)", type, w, h, bp); dst = CreateTarget(TEX0, w, h, type); @@ -206,7 +204,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int } else { - GL_CACHE(format("TC: Lookup Target(T%d) %dx%d, hit: %d (0x%x)", type, w, h, dst->m_texture->GetID(), bp).c_str()); + GL_CACHE("TC: Lookup Target(T%d) %dx%d, hit: %d (0x%x)", type, w, h, dst->m_texture->GetID(), bp); dst->Update(); } @@ -275,7 +273,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int { dst = t; - GL_CACHE(format("TC: Lookup Frame %dx%d, perfect hit: %d (0x%x)", w, h, dst->m_texture->GetID(), bp).c_str()); + GL_CACHE("TC: Lookup Frame %dx%d, perfect hit: %d (0x%x)", w, h, dst->m_texture->GetID(), bp); break; } @@ -285,7 +283,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int if(t->m_TEX0.TBP0 <= bp && bp < t->m_TEX0.TBP0 + 0xe00UL && (!dst || t->m_TEX0.TBP0 >= dst->m_TEX0.TBP0)) { - GL_CACHE(format("TC: Lookup Frame %dx%d, close hit: %d (0x%x, took 0x%x)", w, h, dst->m_texture->GetID(), bp, dst->m_TEX0.TBP0).c_str()); + GL_CACHE("TC: Lookup Frame %dx%d, close hit: %d (0x%x, took 0x%x)", w, h, dst->m_texture->GetID(), bp, dst->m_TEX0.TBP0); dst = t; } } @@ -293,7 +291,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int if(dst == NULL) { - GL_CACHE(format("TC: Lookup Frame %dx%d, miss (0x%x)", w, h, bp).c_str()); + GL_CACHE("TC: Lookup Frame %dx%d, miss (0x%x)", w, h, bp); dst = CreateTarget(TEX0, w, h, RenderTarget); @@ -425,9 +423,9 @@ void GSTextureCache::InvalidateVideoMem(GSOffset* off, const GSVector4i& rect, b else { m_dst[type].erase(j); - GL_CACHE(format("TC: Remove Target(%d) %d (0x%x)", type, + GL_CACHE("TC: Remove Target(%d) %d (0x%x)", type, t->m_texture ? t->m_texture->GetID() : 0, - t->m_TEX0.TBP0).c_str()); + t->m_TEX0.TBP0); delete t; continue; } @@ -605,9 +603,9 @@ void GSTextureCache::IncAge() if(++t->m_age > maxage) { m_dst[type].erase(j); - GL_CACHE(format("TC: Remove Target(T%d): %d (0x%x) due to age", type, + GL_CACHE("TC: Remove Target(T%d): %d (0x%x) due to age", type, t->m_texture ? t->m_texture->GetID() : 0, - t->m_TEX0.TBP0).c_str()); + t->m_TEX0.TBP0); delete t; } @@ -645,9 +643,9 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con if(dst->m_type != RenderTarget) { - GL_CACHE(format("TC: Remove dst because not a RT %d (0x%x)", + GL_CACHE("TC: Remove dst because not a RT %d (0x%x)", dst->m_texture ? dst->m_texture->GetID() : 0, - dst->m_TEX0.TBP0).c_str()); + dst->m_TEX0.TBP0); // TODO delete src; @@ -1285,9 +1283,9 @@ void GSTextureCache::SourceMap::RemoveAt(Source* s) { m_surfaces.erase(s); - GL_CACHE(format("TC: Remove Src Texture: %d (0x%x)", + GL_CACHE("TC: Remove Src Texture: %d (0x%x)", s->m_texture ? s->m_texture->GetID() : 0, - s->m_TEX0.TBP0).c_str()); + s->m_TEX0.TBP0); // 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/GSTextureCacheOGL.cpp b/plugins/GSdx/GSTextureCacheOGL.cpp index 010938a8ef..b784c81d01 100644 --- a/plugins/GSdx/GSTextureCacheOGL.cpp +++ b/plugins/GSdx/GSTextureCacheOGL.cpp @@ -54,9 +54,8 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r) return; } - GL_CACHE(format("TC: Read Back Target: %d (0x%x formatted as 0x%x)", - t->m_texture->GetID(), TEX0.TBP0, TEX0.PSM - ).c_str()); + GL_CACHE("TC: Read Back Target: %d (0x%x formatted as 0x%x)", + t->m_texture->GetID(), TEX0.TBP0, TEX0.PSM); GL_PUSH("Texture Cache Read"); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 9fd7d58f01..cd3fe75c1c 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -293,7 +293,7 @@ void GSTextureOGL::Invalidate() bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) { ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen); - GL_PUSH(format("Upload Texture %d", m_texture_id).c_str()); + GL_PUSH("Upload Texture %d", m_texture_id); m_dirty = true; m_clean = false; diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index e49084bfdd..5815a4a205 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -495,20 +495,20 @@ extern void vmfree(void* ptr, size_t size); // 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_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, -1, s); +#define GL_CACHE(...) gl_DebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, -1, format(__VA_ARGS__).c_str()); #else -#define GL_CACHE(s) (0); +#define GL_CACHE(...) (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(); -#define GL_INS(s) gl_DebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0xDEAD, GL_DEBUG_SEVERITY_MEDIUM, -1, s); +#define GL_PUSH(...) gl_PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); +#define GL_POP() gl_PopDebugGroup(); +#define GL_INS(...) gl_DebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0xDEAD, GL_DEBUG_SEVERITY_MEDIUM, -1, format(__VA_ARGS__).c_str()); #else -#define GL_PUSH(s) (0); -#define GL_POP() (0); -#define GL_INS(s) (0); +#define GL_PUSH(...) (0); +#define GL_POP() (0); +#define GL_INS(...) (0); #endif // Helper path to dump texture