Skip to content

Instantly share code, notes, and snippets.

@shadeslayer
Created October 7, 2015 01:59
Show Gist options
  • Save shadeslayer/32bf0ee8de0432ce6bc9 to your computer and use it in GitHub Desktop.
Save shadeslayer/32bf0ee8de0432ce6bc9 to your computer and use it in GitHub Desktop.
diff --git a/scene_opengl.cpp b/scene_opengl.cpp
index 8b3be71..f22e2ad 100644
--- a/scene_opengl.cpp
+++ b/scene_opengl.cpp
@@ -464,6 +464,39 @@ static void scheduleVboReInit()
timer->start(250);
}
+static void APIENTRY someCallback(GLenum source, GLenum type, GLuint id,
+ GLenum severity, GLsizei length,
+ const GLchar *message,
+ const GLvoid *userParam) {
+ Q_UNUSED(source)
+ Q_UNUSED(severity)
+ Q_UNUSED(userParam)
+ while (message[length] == '\n' || message[length] == '\r')
+ --length;
+
+ switch (type) {
+ case GL_DEBUG_TYPE_ERROR:
+ case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
+ qCWarning(KWIN_CORE, "%#x: %.*s", id, length, message);
+ break;
+
+ case GL_DEBUG_TYPE_OTHER:
+ // at least the nvidia driver seems prone to end up with invalid VBOs after
+ // transferring them between system heap and VRAM
+ // so we re-init them whenever this happens (typically when switching VT, resuming
+ // from STR and XRandR events - #344326
+ if (strstr(message, "Buffer detailed info:") && strstr(message, "has been updated"))
+ scheduleVboReInit();
+ // fall through! for general message printing
+ case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
+static void APIENTRY someCallback(GLenum source, GLenum type, GLuint id,
+ GLenum severity, GLsizei length,
+ const GLchar *message,
+ const GLvoid *userParam) {
+ Q_UNUSED(source)
+ Q_UNUSED(severity)
+ Q_UNUSED(userParam)
+ while (message[length] == '\n' || message[length] == '\r')
+ --length;
+
+ switch (type) {
+ case GL_DEBUG_TYPE_ERROR:
+ case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
+ qCWarning(KWIN_CORE, "%#x: %.*s", id, length, message);
+ break;
+
+ case GL_DEBUG_TYPE_OTHER:
+ // at least the nvidia driver seems prone to end up with invalid VBOs after
+ // transferring them between system heap and VRAM
+ // so we re-init them whenever this happens (typically when switching VT, resuming
+ // from STR and XRandR events - #344326
+ if (strstr(message, "Buffer detailed info:") && strstr(message, "has been updated"))
+ scheduleVboReInit();
+ // fall through! for general message printing
+ case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
+ case GL_DEBUG_TYPE_PORTABILITY:
+ case GL_DEBUG_TYPE_PERFORMANCE:
+ default:
+ qCDebug(KWIN_CORE, "%#x: %.*s", id, length, message);
+ break;
+ }
+}
+
void SceneOpenGL::initDebugOutput()
{
const bool have_KHR_debug = hasGLExtension(QByteArrayLiteral("GL_KHR_debug"));
@@ -511,7 +544,7 @@ void SceneOpenGL::initDebugOutput()
return;
}
- glDebugMessageCallback(callback, nullptr);
+ glDebugMessageCallback(someCallback, nullptr);
// This state exists only in GL_KHR_debug
if (have_KHR_debug)
Breakpoint 1, KWin::SceneOpenGL::initDebugOutput (this=0x132480) at /home/live/kwin/scene_opengl.cpp:547
547 glDebugMessageCallback(someCallback, nullptr);
(gdb) s
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) where
#0 0x00000000 in ?? ()
#1 0xb6eb7810 in KWin::SceneOpenGL::initDebugOutput (this=0x132480) at /home/live/kwin/scene_opengl.cpp:547
#2 0xb6eb70dc in KWin::SceneOpenGL::SceneOpenGL (this=0x132480, backend=0x152820, parent=0xb3c70) at /home/live/kwin/scene_opengl.cpp:412
#3 0xb6eba02c in KWin::SceneOpenGL2::SceneOpenGL2 (this=0x132480, backend=0x152820, parent=0xb3c70) at /home/live/kwin/scene_opengl.cpp:1024
#4 0xb6eb7982 in KWin::SceneOpenGL::createScene (parent=0xb3c70) at /home/live/kwin/scene_opengl.cpp:597
#5 0xb6e9f720 in KWin::Compositor::slotCompositingOptionsInitialized (this=0xb3c70) at /home/live/kwin/composite.cpp:219
#6 0xb6e9f43a in KWin::Compositor::setup (this=0xb3c70) at /home/live/kwin/composite.cpp:177
#7 0xb6f54068 in KWin::Compositor::qt_static_metacall (_o=0xb3c70, _c=QMetaObject::InvokeMetaMethod, _id=14, _a=0xb1b68) at /home/live/kwin/build/moc_composite.cpp:261
#8 0xb53b94f8 in QObject::event(QEvent*) () from /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5
#9 0xb593a9e4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#10 0xb593e8bc in QApplication::notify(QObject*, QEvent*) () from /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#11 0x0002cfb8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment