Skip to content

Instantly share code, notes, and snippets.

@UniversalSuperBox
Created April 30, 2021 00:39
Show Gist options
  • Save UniversalSuperBox/0657831f311e2e39c6beed02b01d1797 to your computer and use it in GitHub Desktop.
Save UniversalSuperBox/0657831f311e2e39c6beed02b01d1797 to your computer and use it in GitHub Desktop.
Patch to print EGL/GL errors around eglSwapBuffers calls in QtUbuntu
diff --git a/src/ubuntumirclient/qmirclientglcontext.cpp b/src/ubuntumirclient/qmirclientglcontext.cpp
index 3c67461..5f78e59 100644
--- a/src/ubuntumirclient/qmirclientglcontext.cpp
+++ b/src/ubuntumirclient/qmirclientglcontext.cpp
@@ -47,6 +47,8 @@
#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <QtGui/private/qopenglcontext_p.h>
+#include <QElapsedTimer>
+
Q_LOGGING_CATEGORY(mirclientGraphics, "qt.qpa.mirclient.graphics", QtWarningMsg)
namespace {
@@ -122,11 +124,41 @@ EGLSurface QMirClientOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurfac
void QMirClientOpenGLContext::swapBuffers(QPlatformSurface *surface)
{
+ QElapsedTimer timer;
+ EGLint error = EGL_SUCCESS;
+ do {
+ error = eglGetError();
+ qDebug() << "BEFORE!";
+ if (error != EGL_SUCCESS) {
+ qDebug() << "EGL ERROR BEFORE!" << error;
+ }
+ } while (error != EGL_SUCCESS);
+ GLenum glerror = GL_NO_ERROR;
+ do {
+ glerror = glGetError();
+ if (glerror != GL_NO_ERROR)
+ qDebug() << "GL ERROR BEFORE!" << glerror;
+ } while (glerror != GL_NO_ERROR);
+
+ timer.start();
QEGLPlatformContext::swapBuffers(surface);
+ qDebug() << "AFTER!" << timer.elapsed();
if (surface->surface()->surfaceClass() == QSurface::Window) {
// notify window on swap completion
auto platformWindow = static_cast<QMirClientWindow *>(surface);
platformWindow->onSwapBuffersDone();
}
+
+ do {
+ glerror = glGetError();
+ if (glerror != GL_NO_ERROR)
+ qDebug() << "GL ERROR BEFORE!" << glerror;
+ } while (glerror != GL_NO_ERROR);
+ do {
+ error = eglGetError();
+ if (error != EGL_SUCCESS) {
+ qDebug() << "EGL ERROR AFTER!" << error;
+ }
+ } while (error != EGL_SUCCESS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment