From bc31922c3354ae63bac8ca756e555c641f6ad6bb Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sat, 29 Nov 2014 17:33:39 +0100 Subject: [PATCH] Allow inserting GL string markers (GREMEDY_string_marker) --- src/debuglogger.h | 14 ++++++++++++++ src/gl-fun.cpp | 7 +++++++ src/gl-fun.h | 7 ++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/debuglogger.h b/src/debuglogger.h index cb7021c..c9e8fb9 100644 --- a/src/debuglogger.h +++ b/src/debuglogger.h @@ -22,6 +22,11 @@ #ifndef DEBUGLOGGER_H #define DEBUGLOGGER_H +#include "gl-fun.h" + +#include +#include + struct DebugLoggerPrivate; class DebugLogger @@ -34,4 +39,13 @@ private: DebugLoggerPrivate *p; }; +#define GL_MARKER(format, ...) \ + if (gl.StringMarker) \ + { \ + char buf[128]; \ + int len = snprintf(buf, sizeof(buf), format, ##__VA_ARGS__); \ + gl.StringMarker(std::min(len, sizeof(buf)), buf); \ + } + + #endif // DEBUGLOGGER_H diff --git a/src/gl-fun.cpp b/src/gl-fun.cpp index f47c0a2..09174db 100644 --- a/src/gl-fun.cpp +++ b/src/gl-fun.cpp @@ -172,6 +172,13 @@ void initGLFunctions() GL_DEBUG_KHR_FUN; } + if (HAVE_EXT(GREMEDY_string_marker)) + { +#undef EXT_SUFFIX +#define EXT_SUFFIX "GREMEDY" + GL_GREMEMDY_FUN; + } + /* Misc caps */ if (!gles || glMajor >= 3 || HAVE_EXT(EXT_unpack_subimage)) gl.unpack_subimage = true; diff --git a/src/gl-fun.h b/src/gl-fun.h index 8fb29eb..a9862da 100644 --- a/src/gl-fun.h +++ b/src/gl-fun.h @@ -55,9 +55,10 @@ typedef void (APIENTRYP _PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GL typedef void (APIENTRYP _PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP _PFNGLACTIVETEXTUREPROC) (GLenum texture); -/* Debug callback */ +/* Debugging */ typedef void (APIENTRY * _GLDEBUGPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void *userParam); typedef void (APIENTRYP _PFNGLDEBUGMESSAGECALLBACKPROC) (_GLDEBUGPROC callback, const void *userParam); +typedef void (APIENTRYP _PFNGLSTRINGMARKERPROC) (GLsizei len, const GLvoid *string); /* Buffer object */ typedef void (APIENTRYP _PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); @@ -193,6 +194,9 @@ typedef void (APIENTRYP _PFNGLBINDVERTEXARRAYPROC) (GLuint array); #define GL_DEBUG_KHR_FUN \ GL_FUN(DebugMessageCallback, _PFNGLDEBUGMESSAGECALLBACKPROC) +#define GL_GREMEMDY_FUN \ + GL_FUN(StringMarker, _PFNGLSTRINGMARKERPROC) + struct GLFunctions { @@ -203,6 +207,7 @@ struct GLFunctions GL_FBO_BLIT_FUN GL_VAO_FUN GL_DEBUG_KHR_FUN + GL_GREMEMDY_FUN bool glsles; bool unpack_subimage;