mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
Make sure to destroy GL debug context and associated resources
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "maths/matrix.h"
|
||||
#include "maths/camera.h"
|
||||
|
||||
#include "data/glsl/debuguniforms.h"
|
||||
|
||||
#include "serialise/string_utils.h"
|
||||
|
||||
GLuint GLReplay::CreateCShaderProgram(const char *csSrc)
|
||||
@@ -67,6 +69,8 @@ GLuint GLReplay::CreateCShaderProgram(const char *csSrc)
|
||||
RDCERR("Link error: %s", buffer);
|
||||
}
|
||||
|
||||
gl.glDetachShader(ret, cs);
|
||||
|
||||
gl.glDeleteShader(cs);
|
||||
|
||||
return ret;
|
||||
@@ -115,14 +119,15 @@ GLuint GLReplay::CreateShaderProgram(const char *vsSrc, const char *psSrc)
|
||||
|
||||
gl.glLinkProgram(ret);
|
||||
|
||||
gl.glDetachShader(ret, vs);
|
||||
gl.glDetachShader(ret, fs);
|
||||
|
||||
gl.glDeleteShader(vs);
|
||||
gl.glDeleteShader(fs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include "data/glsl/debuguniforms.h"
|
||||
|
||||
void GLReplay::InitDebugData()
|
||||
{
|
||||
if(m_pDriver == NULL) return;
|
||||
@@ -130,6 +135,7 @@ void GLReplay::InitDebugData()
|
||||
{
|
||||
uint64_t id = MakeOutputWindow(NULL, true);
|
||||
|
||||
m_DebugID = id;
|
||||
m_DebugCtx = &m_OutputWindows[id];
|
||||
|
||||
MakeCurrentReplayContext(m_DebugCtx);
|
||||
@@ -317,6 +323,61 @@ void GLReplay::InitDebugData()
|
||||
DebugData.replayQuadProg = CreateShaderProgram(DebugData.blitvsSource.c_str(), DebugData.genericfsSource.c_str());
|
||||
}
|
||||
|
||||
void GLReplay::DeleteDebugData()
|
||||
{
|
||||
MakeCurrentReplayContext(m_DebugCtx);
|
||||
|
||||
WrappedOpenGL &gl = *m_pDriver;
|
||||
|
||||
gl.glDeleteProgram(DebugData.blitProg);
|
||||
|
||||
for(int i=0; i < 3; i++)
|
||||
gl.glDeleteProgram(DebugData.texDisplayProg[i]);
|
||||
|
||||
gl.glDeleteProgram(DebugData.checkerProg);
|
||||
gl.glDeleteProgram(DebugData.genericProg);
|
||||
gl.glDeleteProgram(DebugData.meshProg);
|
||||
|
||||
gl.glDeleteBuffers(1, &DebugData.outlineStripVB);
|
||||
gl.glDeleteVertexArrays(1, &DebugData.outlineStripVAO);
|
||||
|
||||
gl.glDeleteSamplers(1, &DebugData.linearSampler);
|
||||
gl.glDeleteSamplers(1, &DebugData.pointSampler);
|
||||
gl.glDeleteSamplers(1, &DebugData.pointNoMipSampler);
|
||||
gl.glDeleteBuffers(ARRAY_COUNT(DebugData.UBOs), DebugData.UBOs);
|
||||
gl.glDeleteFramebuffers(1, &DebugData.pickPixelFBO);
|
||||
gl.glDeleteTextures(1, &DebugData.pickPixelTex);
|
||||
|
||||
gl.glDeleteVertexArrays(1, &DebugData.emptyVAO);
|
||||
|
||||
for(int t=1; t <= RESTYPE_TEXTYPEMAX; t++)
|
||||
{
|
||||
// float, uint, sint
|
||||
for(int i=0; i < 3; i++)
|
||||
{
|
||||
int idx = t;
|
||||
if(i == 1) idx |= TEXDISPLAY_UINT_TEX;
|
||||
if(i == 2) idx |= TEXDISPLAY_SINT_TEX;
|
||||
|
||||
gl.glDeleteProgram(DebugData.minmaxTileProgram[idx]);
|
||||
gl.glDeleteProgram(DebugData.histogramProgram[idx]);
|
||||
|
||||
if(t == 1)
|
||||
gl.glDeleteProgram(DebugData.minmaxResultProgram[i]);
|
||||
}
|
||||
}
|
||||
|
||||
gl.glDeleteBuffers(1, &DebugData.minmaxTileResult);
|
||||
gl.glDeleteBuffers(1, &DebugData.minmaxResult);
|
||||
gl.glDeleteBuffers(1, &DebugData.histogramBuf);
|
||||
|
||||
MakeCurrentReplayContext(&m_ReplayCtx);
|
||||
|
||||
gl.glDeleteVertexArrays(1, &DebugData.meshVAO);
|
||||
|
||||
gl.glDeleteProgram(DebugData.replayQuadProg);
|
||||
}
|
||||
|
||||
bool GLReplay::GetMinMax(ResourceId texid, uint32_t sliceFace, uint32_t mip, uint32_t sample, float *minval, float *maxval)
|
||||
{
|
||||
if(m_pDriver->m_Textures.find(texid) == m_pDriver->m_Textures.end())
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "gl_driver.h"
|
||||
#include "gl_resources.h"
|
||||
|
||||
#include "data/glsl/debuguniforms.h"
|
||||
|
||||
#include "serialise/string_utils.h"
|
||||
|
||||
GLReplay::GLReplay()
|
||||
@@ -42,6 +44,10 @@ GLReplay::GLReplay()
|
||||
|
||||
void GLReplay::Shutdown()
|
||||
{
|
||||
DeleteDebugData();
|
||||
|
||||
DestroyOutputWindow(m_DebugID);
|
||||
|
||||
CloseReplayContext();
|
||||
|
||||
delete m_pDriver;
|
||||
|
||||
@@ -218,6 +218,7 @@ class GLReplay : public IReplayDriver
|
||||
} DebugData;
|
||||
|
||||
void InitDebugData();
|
||||
void DeleteDebugData();
|
||||
|
||||
GLuint CreateShaderProgram(const char *vs, const char *ps);
|
||||
GLuint CreateCShaderProgram(const char *cs);
|
||||
@@ -226,6 +227,7 @@ class GLReplay : public IReplayDriver
|
||||
void CreateOutputWindowBackbuffer(OutputWindow &outwin);
|
||||
|
||||
GLWindowingData m_ReplayCtx;
|
||||
int64_t m_DebugID;
|
||||
OutputWindow *m_DebugCtx;
|
||||
|
||||
void MakeCurrentReplayContext(GLWindowingData *ctx);
|
||||
|
||||
@@ -64,6 +64,7 @@ void GLReplay::CloseReplayContext()
|
||||
{
|
||||
if(glXDestroyCtxProc)
|
||||
{
|
||||
glXMakeContextCurrentProc(m_ReplayCtx.dpy, None, None, NULL);
|
||||
glXDestroyCtxProc(m_ReplayCtx.dpy, m_ReplayCtx.ctx);
|
||||
}
|
||||
}
|
||||
@@ -170,6 +171,7 @@ void GLReplay::DestroyOutputWindow(uint64_t id)
|
||||
|
||||
OutputWindow &outw = it->second;
|
||||
|
||||
glXMakeContextCurrentProc(outw.dpy, None, None, NULL);
|
||||
glXDestroyCtxProc(outw.dpy, outw.ctx);
|
||||
|
||||
m_OutputWindows.erase(it);
|
||||
|
||||
@@ -61,6 +61,7 @@ void GLReplay::CloseReplayContext()
|
||||
{
|
||||
if(wglDeleteRC)
|
||||
{
|
||||
wglMakeCurrentProc(NULL, NULL);
|
||||
wglDeleteRC(m_ReplayCtx.ctx);
|
||||
ReleaseDC(m_ReplayCtx.wnd, m_ReplayCtx.DC);
|
||||
::DestroyWindow(m_ReplayCtx.wnd);
|
||||
@@ -198,7 +199,8 @@ void GLReplay::DestroyOutputWindow(uint64_t id)
|
||||
return;
|
||||
|
||||
OutputWindow &outw = it->second;
|
||||
|
||||
|
||||
wglMakeCurrentProc(NULL, NULL);
|
||||
wglDeleteRC(outw.ctx);
|
||||
ReleaseDC(outw.wnd, outw.DC);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user