diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index cbb073a0a..56c67e28f 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -1849,6 +1849,8 @@ void WrappedOpenGL::DebugSnoop(GLenum source, GLenum type, GLuint id, GLenum sev { if(type != eGL_DEBUG_TYPE_PERFORMANCE && type != eGL_DEBUG_TYPE_OTHER) { + if(m_DebugMsgContext != "") + RDCLOG("Debug Message context: \"%s\"", m_DebugMsgContext.c_str()); RDCLOG("Got a Debug message from %s, type %s, ID %d, severity %s:\n'%s'", ToStr::Get(source).c_str(), ToStr::Get(type).c_str(), id, ToStr::Get(severity).c_str(), message); } diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 3bead2260..519d3ecd3 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -101,6 +101,7 @@ class WrappedOpenGL GLDEBUGPROC m_RealDebugFunc; const void *m_RealDebugFuncParam; + string m_DebugMsgContext; void DebugSnoop(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message); static void APIENTRY DebugSnoopStatic(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) @@ -347,6 +348,8 @@ class WrappedOpenGL GLReplay *GetReplay() { return &m_Replay; } void *GetCtx(); void *SwitchToContext(void *ctx); + + void SetDebugMsgContext(const char *context) { m_DebugMsgContext = context; } // replay interface void Initialise(GLInitParams ¶ms); @@ -1185,3 +1188,23 @@ class WrappedOpenGL IMPLEMENT_FUNCTION_SERIALISED(void, glVertexArrayVertexAttribLOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset)); IMPLEMENT_FUNCTION_SERIALISED(void, glVertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor)); }; + +class ScopedDebugContext +{ + public: + ScopedDebugContext(WrappedOpenGL *gl, const char *fmt, ...) + { + va_list args; + va_start(args, fmt); + char buf[1024]; buf[1023] = 0; + StringFormat::vsnprintf(buf, 1023, fmt, args); + va_end(args); + + m_GL = gl; + m_GL->SetDebugMsgContext(buf); + } + + ~ScopedDebugContext() { m_GL->SetDebugMsgContext(""); } + private: + WrappedOpenGL *m_GL; +};