mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-15 11:06:54 +00:00
Remove Pre/Post Init/Shutdown of counters. Inline into normal flow
This commit is contained in:
@@ -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<GPUCounter> GLReplay::EnumerateCounters()
|
||||
{
|
||||
vector<GPUCounter> ret;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<GPUCounter> &counters);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user