Introduce additional safety checks for init debug output in SceneOpenGL

There are slight differences between GL_ARB_debug_output and GL_KHR_debug
affecting how it works on GLES. With GL_KHR_debug the context should be
created with a debug flag. With the ARB extension there is no such
requirement. Empirical data (Mali) shows that it doesn't work if the
context is not created with the flag, although the spec seems to allows
it.

So:
* if we have GL_ARB_debug_output we assume it works
* if we only have GL_KHR_debug we check whether the context is created
  with debug support (which we don't do yet, but maybe should?)
* on GLES we can only query with version 3.2 (which we don't request yet)
* with anything older we just assume it's not enabled (which is correct
  given that we don't enable the debug flag)

REVIEW: 126053
This commit is contained in:
Martin Gräßlin 2015-11-13 13:11:47 +01:00
parent 1d75cd26fb
commit 5d416a0f69

View file

@ -476,9 +476,27 @@ static void scheduleVboReInit()
void SceneOpenGL::initDebugOutput()
{
const bool have_KHR_debug = hasGLExtension(QByteArrayLiteral("GL_KHR_debug"));
if (!have_KHR_debug && !hasGLExtension(QByteArrayLiteral("GL_ARB_debug_output")))
const bool have_ARB_debug = hasGLExtension(QByteArrayLiteral("GL_ARB_debug_output"));
if (!have_KHR_debug && !have_ARB_debug)
return;
if (!have_ARB_debug) {
// if we don't have ARB debug, but only KHR debug we need to verify whether the context is a debug context
// it should work without as well, but empirical tests show: no it doesn't
if (GLPlatform::instance()->isGLES()) {
if (!hasGLVersion(3, 2)) {
// empirical data shows extension doesn't work
return;
}
}
// can only be queried with either OpenGL or OpenGL ES of at least 3.1
GLint value = 0;
glGetIntegerv(GL_CONTEXT_FLAGS, &value);
if (!(value & GL_CONTEXT_FLAG_DEBUG_BIT)) {
return;
}
}
gs_debuggedScene = this;
// Set the callback function
@ -515,11 +533,6 @@ void SceneOpenGL::initDebugOutput()
}
};
// Expoxy fails to resolve glDebugMessageCallback on GLES
if (!glDebugMessageCallback) {
return;
}
glDebugMessageCallback(callback, nullptr);
// This state exists only in GL_KHR_debug