From a7509dadb6f2e438eae6d5278eab11ee285f8138 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 29 Jun 2018 13:55:29 +0100 Subject: [PATCH] Remove Pre/Post Init/Shutdown of counters. Inline into normal flow --- renderdoc/driver/gl/gl_counters.cpp | 37 ------------------------- renderdoc/driver/gl/gl_replay.cpp | 27 +++++++++++++++--- renderdoc/driver/gl/gl_replay.h | 10 ------- renderdoc/driver/gl/gl_replay_egl.cpp | 6 ---- renderdoc/driver/gl/gl_replay_linux.cpp | 8 ------ renderdoc/driver/gl/gl_replay_win32.cpp | 9 ------ 6 files changed, 23 insertions(+), 74 deletions(-) diff --git a/renderdoc/driver/gl/gl_counters.cpp b/renderdoc/driver/gl/gl_counters.cpp index 2ffa437b0..981bf13f9 100644 --- a/renderdoc/driver/gl/gl_counters.cpp +++ b/renderdoc/driver/gl/gl_counters.cpp @@ -29,43 +29,6 @@ #include "gl_replay.h" #include "gl_resources.h" -void GLReplay::PreContextInitCounters() -{ -} - -void GLReplay::PostContextInitCounters() -{ - AMDCounters *counters = NULL; - - if(m_Vendor == GPUVendor::AMD) - { - RDCLOG("AMD GPU detected - trying to initialise AMD counters"); - counters = new AMDCounters(); - } - else - { - RDCLOG("%s GPU detected - no counters available", ToStr(m_Vendor).c_str()); - } - - if(counters && counters->Init(AMDCounters::ApiType::Ogl, m_ReplayCtx.ctx)) - { - m_pAMDCounters = counters; - } - else - { - delete counters; - m_pAMDCounters = NULL; - } -} -void GLReplay::PreContextShutdownCounters() -{ - SAFE_DELETE(m_pAMDCounters); -} - -void GLReplay::PostContextShutdownCounters() -{ -} - vector GLReplay::EnumerateCounters() { vector ret; diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 382c6c92d..9e32d9048 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -24,6 +24,7 @@ ******************************************************************************/ #include "gl_replay.h" +#include "driver/ihv/amd/amd_counters.h" #include "maths/matrix.h" #include "serialise/rdcfile.h" #include "strings/string_utils.h" @@ -57,7 +58,7 @@ GLReplay::GLReplay() void GLReplay::Shutdown() { - PreContextShutdownCounters(); + SAFE_DELETE(m_pAMDCounters); DeleteDebugData(); @@ -73,8 +74,6 @@ void GLReplay::Shutdown() } delete m_pDriver; - - GLReplay::PostContextShutdownCounters(); } ReplayStatus GLReplay::ReadLogInitialisation(RDCFile *rdc, bool storeStructuredBuffers) @@ -223,7 +222,27 @@ void GLReplay::SetReplayData(GLWindowingData data) InitDebugData(); - PostContextInitCounters(); + AMDCounters *counters = NULL; + + if(m_Vendor == GPUVendor::AMD) + { + RDCLOG("AMD GPU detected - trying to initialise AMD counters"); + counters = new AMDCounters(); + } + else + { + RDCLOG("%s GPU detected - no counters available", ToStr(m_Vendor).c_str()); + } + + if(counters && counters->Init(AMDCounters::ApiType::Ogl, m_ReplayCtx.ctx)) + { + m_pAMDCounters = counters; + } + else + { + delete counters; + m_pAMDCounters = NULL; + } } void GLReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, bytebuf &ret) diff --git a/renderdoc/driver/gl/gl_replay.h b/renderdoc/driver/gl/gl_replay.h index 6a373e053..d3329a513 100644 --- a/renderdoc/driver/gl/gl_replay.h +++ b/renderdoc/driver/gl/gl_replay.h @@ -231,11 +231,6 @@ public: bool IsRenderOutput(ResourceId id); void FileChanged() {} - // called before any context is created, to init any counters - static void PreContextInitCounters(); - // called after any context is destroyed, to do corresponding shutdown of counters - static void PostContextShutdownCounters(); - void SetReplayData(GLWindowingData data); bool IsReplayContext(void *ctx) { return m_ReplayCtx.ctx == NULL || ctx == m_ReplayCtx.ctx; } @@ -386,11 +381,6 @@ private: void CheckGLSLVersion(const char *sl, int &glslVersion); - // called after the context is created, to init any counters - void PostContextInitCounters(); - // called before the context is destroyed, to shutdown any counters - void PreContextShutdownCounters(); - void FillTimers(GLCounterContext &ctx, const DrawcallDescription &drawnode, const vector &counters); diff --git a/renderdoc/driver/gl/gl_replay_egl.cpp b/renderdoc/driver/gl/gl_replay_egl.cpp index e72950efc..720675b2f 100644 --- a/renderdoc/driver/gl/gl_replay_egl.cpp +++ b/renderdoc/driver/gl/gl_replay_egl.cpp @@ -113,13 +113,10 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) int major, minor; egl.Initialize(eglDisplay, &major, &minor); - GLReplay::PreContextInitCounters(); - GLWindowingData data = CreateWindowingData(egl, eglDisplay, EGL_NO_CONTEXT, 0); if(data.egl_ctx == NULL) { - GLReplay::PostContextShutdownCounters(); RDCERR("Couldn't create GL ES 3.x context - RenderDoc requires OpenGL ES 3.x availability"); return ReplayStatus::APIHardwareUnsupported; } @@ -128,7 +125,6 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) { RDCERR("Couldn't create a suitable PBuffer"); egl.DestroyContext(eglDisplay, data.egl_ctx); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -138,7 +134,6 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) RDCERR("Couldn't active the created GL ES context"); egl.DestroySurface(eglDisplay, data.egl_wnd); egl.DestroyContext(eglDisplay, data.egl_ctx); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -150,7 +145,6 @@ ReplayStatus GLES_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) { egl.DestroySurface(eglDisplay, data.egl_wnd); egl.DestroyContext(eglDisplay, data.egl_ctx); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIHardwareUnsupported; } diff --git a/renderdoc/driver/gl/gl_replay_linux.cpp b/renderdoc/driver/gl/gl_replay_linux.cpp index 56a441506..71bca266b 100644 --- a/renderdoc/driver/gl/gl_replay_linux.cpp +++ b/renderdoc/driver/gl/gl_replay_linux.cpp @@ -135,8 +135,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) int attribs[64] = {0}; int i = 0; - GLReplay::PreContextInitCounters(); - attribs[i++] = GLX_CONTEXT_MAJOR_VERSION_ARB; int &major = attribs[i]; attribs[i++] = 0; @@ -168,7 +166,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) if(fbcfg == NULL) { - GLReplay::PostContextShutdownCounters(); RDCERR("Couldn't choose default framebuffer config"); return ReplayStatus::APIInitFailed; } @@ -206,7 +203,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) if(ctx == NULL || X11ErrorSeen) { XFree(fbcfg); - GLReplay::PostContextShutdownCounters(); RDCERR("Couldn't create 3.2 context - RenderDoc requires OpenGL 3.2 availability"); return ReplayStatus::APIHardwareUnsupported; } @@ -227,7 +223,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) glXDestroyPbufferProc(dpy, pbuffer); glXDestroyCtxProc(dpy, ctx); XFree(fbcfg); - GLReplay::PostContextShutdownCounters(); RDCERR("Couldn't make pbuffer & context current"); return ReplayStatus::APIInitFailed; } @@ -245,7 +240,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) glXDestroyPbufferProc(dpy, pbuffer); glXDestroyCtxProc(dpy, ctx); XFree(fbcfg); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -259,7 +253,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) glXDestroyPbufferProc(dpy, pbuffer); glXDestroyCtxProc(dpy, ctx); XFree(fbcfg); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIHardwareUnsupported; } @@ -270,7 +263,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) glXDestroyPbufferProc(dpy, pbuffer); glXDestroyCtxProc(dpy, ctx); XFree(fbcfg); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIHardwareUnsupported; } diff --git a/renderdoc/driver/gl/gl_replay_win32.cpp b/renderdoc/driver/gl/gl_replay_win32.cpp index e6540ea22..c97bfcf1a 100644 --- a/renderdoc/driver/gl/gl_replay_win32.cpp +++ b/renderdoc/driver/gl/gl_replay_win32.cpp @@ -185,8 +185,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) ReleaseDC(w, dc); DestroyWindow(w); - GLReplay::PreContextInitCounters(); - // we don't use the default framebuffer (backbuffer) for anything, so we make it // tiny and with no depth/stencil bits pfd.iPixelType = PFD_TYPE_RGBA; @@ -205,7 +203,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) { RDCERR("Couldn't choose pixel format"); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -214,7 +211,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) { RDCERR("Couldn't set pixel format"); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -261,7 +257,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) { RDCERR("Couldn't create 3.2 RC - RenderDoc requires OpenGL 3.2 availability"); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIHardwareUnsupported; } @@ -274,7 +269,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) wglMakeCurrentProc(NULL, NULL); wglDeleteRC(rc); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -289,7 +283,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) wglMakeCurrentProc(NULL, NULL); wglDeleteRC(rc); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -300,7 +293,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) wglMakeCurrentProc(NULL, NULL); wglDeleteRC(rc); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; } @@ -313,7 +305,6 @@ ReplayStatus GL_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver) wglMakeCurrentProc(NULL, NULL); wglDeleteRC(rc); ReleaseDC(w, dc); - GLReplay::PostContextShutdownCounters(); return ReplayStatus::APIInitFailed; }