diff --git a/src/OpenGl/OpenGl_ArbDbg.hxx b/src/OpenGl/OpenGl_ArbDbg.hxx index 934551b4e7..e68e4bf2ef 100755 --- a/src/OpenGl/OpenGl_ArbDbg.hxx +++ b/src/OpenGl/OpenGl_ArbDbg.hxx @@ -21,12 +21,10 @@ //! Debug context routines struct OpenGl_ArbDbg : protected OpenGl_GlFunctions { -#if !defined(GL_ES_VERSION_2_0) - using OpenGl_GlFunctions::glDebugMessageControlARB; - using OpenGl_GlFunctions::glDebugMessageInsertARB; - using OpenGl_GlFunctions::glDebugMessageCallbackARB; - using OpenGl_GlFunctions::glGetDebugMessageLogARB; -#endif + using OpenGl_GlFunctions::glDebugMessageControl; + using OpenGl_GlFunctions::glDebugMessageInsert; + using OpenGl_GlFunctions::glDebugMessageCallback; + using OpenGl_GlFunctions::glGetDebugMessageLog; }; #endif // _OpenGl_ArbDbg_H__ diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 0a21ead0f8..ccadcf60b7 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -247,21 +247,21 @@ OpenGl_Context::~OpenGl_Context() myTexSampler->Release (this); } -#if !defined(GL_ES_VERSION_2_0) if (arbDbg != NULL && myIsGlDebugCtx && IsValid()) { // reset callback + #if !defined(GL_ES_VERSION_2_0) void* aPtr = NULL; glGetPointerv (GL_DEBUG_CALLBACK_USER_PARAM, &aPtr); if (aPtr == this) + #endif { - arbDbg->glDebugMessageCallbackARB (NULL, NULL); + arbDbg->glDebugMessageCallback (NULL, NULL); } myIsGlDebugCtx = Standard_False; } -#endif } // ======================================================================= @@ -936,7 +936,6 @@ static Standard_CString THE_DBGMSG_SEV_HIGH = "High"; // GL_DEBUG_SEVERITY_H static Standard_CString THE_DBGMSG_SEV_MEDIUM = "Medium"; // GL_DEBUG_SEVERITY_MEDIUM static Standard_CString THE_DBGMSG_SEV_LOW = "Low"; // GL_DEBUG_SEVERITY_LOW -#if !defined(GL_ES_VERSION_2_0) //! Callback for GL_ARB_debug_output extension static void APIENTRY debugCallbackWrap(unsigned int theSource, unsigned int theType, @@ -949,7 +948,6 @@ static void APIENTRY debugCallbackWrap(unsigned int theSource, OpenGl_Context* aCtx = (OpenGl_Context* )theUserParam; aCtx->PushMessage (theSource, theType, theId, theSeverity, theMessage); } -#endif // ======================================================================= // function : PushMessage @@ -1195,6 +1193,37 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) { arbTBO = reinterpret_cast (myFuncs.get()); } + + // initialize debug context extension + if (CheckExtension ("GL_KHR_debug")) + { + // this functionality become a part of OpenGL ES 3.2 + arbDbg = NULL; + // According to GL_KHR_debug spec, all functions should have KHR suffix. + // However, some implementations can export these functions without suffix. + if (FindProc ("glDebugMessageControlKHR", myFuncs->glDebugMessageControl) + && FindProc ("glDebugMessageInsertKHR", myFuncs->glDebugMessageInsert) + && FindProc ("glDebugMessageCallbackKHR", myFuncs->glDebugMessageCallback) + && FindProc ("glGetDebugMessageLogKHR", myFuncs->glGetDebugMessageLog)) + { + arbDbg = (OpenGl_ArbDbg* )(&(*myFuncs)); + } + + if (arbDbg != NULL + && caps->contextDebug) + { + // setup default callback + myIsGlDebugCtx = Standard_True; + arbDbg->glDebugMessageCallback (debugCallbackWrap, this); + ::glEnable (GL_DEBUG_OUTPUT); + if (caps->contextSyncDebug) + { + // note that some broken implementations (e.g. simulators) might generate error message on this call + ::glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + } + } + #else myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP; @@ -1293,30 +1322,6 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) //extSwapTear = CheckExtension (aGlxExts, "GLX_EXT_swap_control_tear"); #endif - // initialize debug context extension - if (CheckExtension ("GL_ARB_debug_output")) - { - arbDbg = NULL; - if (FindProcShort (glDebugMessageControlARB) - && FindProcShort (glDebugMessageInsertARB) - && FindProcShort (glDebugMessageCallbackARB) - && FindProcShort (glGetDebugMessageLogARB)) - { - arbDbg = (OpenGl_ArbDbg* )(&(*myFuncs)); - } - if (arbDbg != NULL - && caps->contextDebug) - { - // setup default callback - myIsGlDebugCtx = Standard_True; - arbDbg->glDebugMessageCallbackARB (debugCallbackWrap, this); - if (caps->contextSyncDebug) - { - ::glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS); - } - } - } - // load OpenGL 1.2 new functions has12 = IsGlGreaterEqual (1, 2) && FindProcShort (glBlendColor) @@ -2052,6 +2057,39 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) && FindProcShort (glBindImageTextures) && FindProcShort (glBindVertexBuffers); + // initialize debug context extension + if (CheckExtension ("GL_ARB_debug_output")) + { + arbDbg = NULL; + if (has43) + { + arbDbg = (OpenGl_ArbDbg* )(&(*myFuncs)); + } + else if (FindProc ("glDebugMessageControlARB", myFuncs->glDebugMessageControl) + && FindProc ("glDebugMessageInsertARB", myFuncs->glDebugMessageInsert) + && FindProc ("glDebugMessageCallbackARB", myFuncs->glDebugMessageCallback) + && FindProc ("glGetDebugMessageLogARB", myFuncs->glGetDebugMessageLog)) + { + arbDbg = (OpenGl_ArbDbg* )(&(*myFuncs)); + } + + if (arbDbg != NULL + && caps->contextDebug) + { + // setup default callback + myIsGlDebugCtx = Standard_True; + arbDbg->glDebugMessageCallback (debugCallbackWrap, this); + if (has43) + { + ::glEnable (GL_DEBUG_OUTPUT); + } + if (caps->contextSyncDebug) + { + ::glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + } + } + // initialize TBO extension (ARB) if (!has31 && CheckExtension ("GL_ARB_texture_buffer_object") diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index e974a6fc27..6c364f05d7 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -153,6 +153,7 @@ #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF // debug ARB extension + #define GL_DEBUG_OUTPUT 0x92E0 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 @@ -751,6 +752,27 @@ public: //! @name OpenGL ES 3.2 typedef void (*glTexBuffer_t)(GLenum target, GLenum internalFormat, GLuint buffer); glTexBuffer_t glTexBuffer; +public: //! @name GL_KHR_debug (optional) + + typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); + + typedef void (APIENTRYP glDebugMessageControl_t ) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); + typedef void (APIENTRYP glDebugMessageInsert_t ) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); + typedef void (APIENTRYP glDebugMessageCallback_t) (GLDEBUGPROCARB callback, const void* userParam); + typedef GLuint (APIENTRYP glGetDebugMessageLog_t ) (GLuint count, + GLsizei bufSize, + GLenum* sources, + GLenum* types, + GLuint* ids, + GLenum* severities, + GLsizei* lengths, + GLchar* messageLog); + + glDebugMessageControl_t glDebugMessageControl; + glDebugMessageInsert_t glDebugMessageInsert; + glDebugMessageCallback_t glDebugMessageCallback; + glGetDebugMessageLog_t glGetDebugMessageLog; + #else // OpenGL ES vs. desktop public: //! @name OpenGL 1.2 @@ -1437,13 +1459,6 @@ public: //! @name OpenGL 4.4 PFNGLBINDIMAGETEXTURESPROC glBindImageTextures; PFNGLBINDVERTEXBUFFERSPROC glBindVertexBuffers; -public: //! @name GL_ARB_debug_output (optional) - - PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB; - PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; - PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; - PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; - public: //! @name GL_EXT_geometry_shader4 PFNGLPROGRAMPARAMETERIEXTPROC glProgramParameteriEXT; diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index 257843cc8e..735adc9f6c 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -1586,8 +1586,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh EOL"uniform mat4 uMultL;" EOL"uniform mat4 uMultR;" EOL - EOL"vec4 THE_POW_UP = vec4 (2.2, 2.2, 2.2, 1.0);" - EOL"vec4 THE_POW_DOWN = 1.0 / THE_POW_UP;" + EOL"const vec4 THE_POW_UP = vec4 (2.2, 2.2, 2.2, 1.0);" + EOL"const vec4 THE_POW_DOWN = 1.0 / vec4 (2.2, 2.2, 2.2, 1.0);" EOL EOL"THE_SHADER_IN vec2 TexCoord;" EOL