mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-13 10:11:02 +00:00
Add an optional context when debug messages are logged
* Many debug messages are completely useless without context, so to track down bugs in crashdumps with logs, etc, it would be very useful to add a little snippet to show what function call the message was fired from and what the parameters were. * I'll just add these as/when necessary for tracking bugs.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user