diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index 8a9feeac643e..7708fc0e112c 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -116,6 +116,7 @@ static const char *sExtensionNames[] = { "GL_EXT_transform_feedback", "GL_NV_transform_feedback", "GL_ANGLE_depth_texture", + "GL_KHR_debug", nullptr }; @@ -974,6 +975,39 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) } } + if (IsExtensionSupported(KHR_debug)) { + SymLoadStruct extSymbols[] = { + { (PRFuncPtr*) &mSymbols.fDebugMessageControl, { "DebugMessageControl", "DebugMessageControlKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fDebugMessageInsert, { "DebugMessageInsert", "DebugMessageInsertKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fDebugMessageCallback, { "DebugMessageCallback", "DebugMessageCallbackKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetDebugMessageLog, { "GetDebugMessageLog", "GetDebugMessageLogKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetPointerv, { "GetPointerv", "GetPointervKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fPushDebugGroup, { "PushDebugGroup", "PushDebugGroupKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fPopDebugGroup, { "PopDebugGroup", "PopDebugGroupKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fObjectLabel, { "ObjectLabel", "ObjectLabelKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetObjectLabel, { "GetObjectLabel", "GetObjectLabelKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fObjectPtrLabel, { "ObjectPtrLabel", "ObjectPtrLabelKHR", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetObjectPtrLabel, { "GetObjectPtrLabel", "GetObjectPtrLabelKHR", nullptr } }, + { nullptr, { nullptr } }, + }; + + if (!LoadSymbols(&extSymbols[0], trygl, prefix)) { + NS_ERROR("GL supports KHR_debug without supplying its functions."); + + MarkExtensionUnsupported(KHR_debug); + mSymbols.fDebugMessageControl = nullptr; + mSymbols.fDebugMessageInsert = nullptr; + mSymbols.fDebugMessageCallback = nullptr; + mSymbols.fGetDebugMessageLog = nullptr; + mSymbols.fGetPointerv = nullptr; + mSymbols.fPushDebugGroup = nullptr; + mSymbols.fPopDebugGroup = nullptr; + mSymbols.fObjectLabel = nullptr; + mSymbols.fGetObjectLabel = nullptr; + mSymbols.fObjectPtrLabel = nullptr; + mSymbols.fGetObjectPtrLabel = nullptr; + } + } // Load developer symbols, don't fail if we can't find them. SymLoadStruct auxSymbols[] = { diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 36430f25bc85..e343f825c0b3 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -395,6 +395,7 @@ public: EXT_transform_feedback, NV_transform_feedback, ANGLE_depth_texture, + KHR_debug, Extensions_Max, Extensions_End }; @@ -896,6 +897,27 @@ public: AFTER_GL_CALL; } + void fDebugMessageCallback(GLDEBUGPROC callback, const GLvoid* userParam) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fDebugMessageCallback); + mSymbols.fDebugMessageCallback(callback, userParam); + AFTER_GL_CALL; + } + + void fDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, realGLboolean enabled) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fDebugMessageControl); + mSymbols.fDebugMessageControl(source, type, severity, count, ids, enabled); + AFTER_GL_CALL; + } + + void fDebugMessageInsert(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fDebugMessageInsert); + mSymbols.fDebugMessageInsert(source, type, id, severity, length, buf); + AFTER_GL_CALL; + } + void fDetachShader(GLuint program, GLuint shader) { BEFORE_GL_CALL; mSymbols.fDetachShader(program, shader); @@ -1094,6 +1116,35 @@ public: AFTER_GL_CALL; } + GLuint fGetDebugMessageLog(GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetDebugMessageLog); + GLuint ret = mSymbols.fGetDebugMessageLog(count, bufsize, sources, types, ids, severities, lengths, messageLog); + AFTER_GL_CALL; + return ret; + } + + void fGetPointerv(GLenum pname, GLvoid** params) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetPointerv); + mSymbols.fGetPointerv(pname, params); + AFTER_GL_CALL; + } + + void fGetObjectLabel(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetObjectLabel); + mSymbols.fGetObjectLabel(identifier, name, bufSize, length, label); + AFTER_GL_CALL; + } + + void fGetObjectPtrLabel(GLvoid* ptr, GLsizei bufSize, GLsizei* length, GLchar* label) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetObjectPtrLabel); + mSymbols.fGetObjectPtrLabel(ptr, bufSize, length, label); + AFTER_GL_CALL; + } + void fGenerateMipmap(GLenum target) { BEFORE_GL_CALL; mSymbols.fGenerateMipmap(target); @@ -1254,6 +1305,20 @@ public: AFTER_GL_CALL; } + void fObjectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar* label) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fObjectLabel); + mSymbols.fObjectLabel(identifier, name, length, label); + AFTER_GL_CALL; + } + + void fObjectPtrLabel(GLvoid* ptr, GLsizei length, const GLchar* label) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fObjectPtrLabel); + mSymbols.fObjectPtrLabel(ptr, length, label); + AFTER_GL_CALL; + } + void fPixelStorei(GLenum pname, GLint param) { BEFORE_GL_CALL; mSymbols.fPixelStorei(pname, param); @@ -1272,6 +1337,20 @@ public: AFTER_GL_CALL; } + void fPopDebugGroup() { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fPopDebugGroup); + mSymbols.fPopDebugGroup(); + AFTER_GL_CALL; + } + + void fPushDebugGroup(GLenum source, GLuint id, GLsizei length, const GLchar* message) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fPushDebugGroup); + mSymbols.fPushDebugGroup(source, id, length, message); + AFTER_GL_CALL; + } + void fReadBuffer(GLenum mode) { BEFORE_GL_CALL; mSymbols.fReadBuffer(mode); diff --git a/gfx/gl/GLContextSymbols.h b/gfx/gl/GLContextSymbols.h index 881a36a6fc5d..a30ebc5f3f5a 100644 --- a/gfx/gl/GLContextSymbols.h +++ b/gfx/gl/GLContextSymbols.h @@ -442,6 +442,30 @@ struct GLContextSymbols // EXT_transform_feedback only typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSET) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); PFNGLBINDBUFFEROFFSET fBindBufferOffset; + + // KHR_debug + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROL) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, realGLboolean enabled); + PFNGLDEBUGMESSAGECONTROL fDebugMessageControl; + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERT) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); + PFNGLDEBUGMESSAGEINSERT fDebugMessageInsert; + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACK) (GLDEBUGPROC callback, const GLvoid* userParam); + PFNGLDEBUGMESSAGECALLBACK fDebugMessageCallback; + typedef GLuint (GLAPIENTRY * PFNGLDEBUGMESSAGELOG) (GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); + PFNGLDEBUGMESSAGELOG fGetDebugMessageLog; + typedef void (GLAPIENTRY * PFNGLGETPOINTERV) (GLenum pname, GLvoid** params); + PFNGLGETPOINTERV fGetPointerv; + typedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUP) (GLenum source, GLuint id, GLsizei length, const GLchar* message); + PFNGLPUSHDEBUGGROUP fPushDebugGroup; + typedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUP) (void); + PFNGLPOPDEBUGGROUP fPopDebugGroup; + typedef void (GLAPIENTRY * PFNGLOBJECTLABEL) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label); + PFNGLOBJECTLABEL fObjectLabel; + typedef void (GLAPIENTRY * PFNGLGETOBJECTLABEL) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar* label); + PFNGLGETOBJECTLABEL fGetObjectLabel; + typedef void (GLAPIENTRY * PFNGLOBJECTPTRLABEL) (GLvoid* ptr, GLsizei length, const GLchar* label); + PFNGLOBJECTPTRLABEL fObjectPtrLabel; + typedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABEL) (GLvoid* ptr, GLsizei bufSize, GLsizei* length, GLchar* label); + PFNGLGETOBJECTPTRLABEL fGetObjectPtrLabel; }; } diff --git a/gfx/gl/GLTypes.h b/gfx/gl/GLTypes.h index d4f0dc5ce983..b155d2e12acf 100644 --- a/gfx/gl/GLTypes.h +++ b/gfx/gl/GLTypes.h @@ -8,6 +8,17 @@ #include #include +#ifndef GLAPIENTRY +# ifdef WIN32 +# include +# define GLAPIENTRY APIENTRY +# define GLAPI +# else +# define GLAPIENTRY +# define GLAPI +# endif +#endif + typedef int8_t realGLboolean; #if !defined(__gltypes_h_) && !defined(__gl_h_) @@ -49,6 +60,15 @@ typedef uint64_t GLuint64; // OES_EGL_image (GLES) typedef void* GLeglImage; +// KHR_debug +typedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar* message, + const GLvoid* userParam); + // EGL types typedef void* EGLImage; typedef int EGLint; @@ -71,14 +91,4 @@ typedef uint64_t EGLTime; #define EGL_NO_SYNC ((EGLSync)0) #define EGL_NO_IMAGE ((EGLImage)0) -#ifndef GLAPIENTRY -# ifdef WIN32 -# define GLAPIENTRY APIENTRY -# define GLAPI -# else -# define GLAPIENTRY -# define GLAPI -# endif -#endif - #endif