Paste P189

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Apr 4 2018, 9:00 PM.
commit 44e9c613065898122078de14d8c8883f5f8ab602
Author: David Edmundson <davidedmundson@kde.org>
Date: Wed Apr 4 21:59:28 2018 +0100
Don't block on lost context
When glGetError returns GL_CONTEXT_LOST (on XCB + Nvidia at least) the
error does not get cleared until the next glGetGraphicsResetStatus.
We can't handle this properly until the start of the next frame where we
will set the context to invalid, but in the meantime we should avoid
locking up completely.
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 469f019a1c..3d339e4240 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -55,12 +55,16 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG
#define QT_RESET_GLERROR() \
{ \
- while (QOpenGLContext::currentContext()->functions()->glGetError() != GL_NO_ERROR) {} \
+ while (true) {\
+ GLenum error = QOpenGLContext::currentContext()->functions()->glGetError(); \
+ if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) \
+ break; \
+ } \
}
#define QT_CHECK_GLERROR() \
{ \
GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); \
- if (err != GL_NO_ERROR) { \
+ if (err != GL_NO_ERROR && err != GL_CONTEXT_LOST) { \
qDebug("[%s line %d] OpenGL Error: %d", \
__FILE__, __LINE__, (int)err); \
} \
@@ -1303,8 +1307,11 @@ static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format,
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
QOpenGLFunctions *funcs = ctx->functions();
- while (funcs->glGetError());
-
+ while (true) {
+ GLenum error = funcs->glGetError();
+ if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST)
+ break;
+ }
switch (internal_format) {
case GL_RGB:
case GL_RGB8:
davidedmundson edited the content of this paste. (Show Details)Apr 4 2018, 9:00 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.
davidedmundson updated the paste's language from autodetect to autodetect.