From c33faac32bcf333c990469d455f967599494347a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 18 Sep 2018 13:38:14 +0200 Subject: More fixups for GL_CONTEXT_LOST Fixes the rest of the places we use the pattern of emptying the OpenGL error stack to be able to handle GL_CONTEXT_LOST, and adds a note about it in the documentation. Change-Id: I7eb97dbca45f39295b832d44937023b538b19947 Reviewed-by: David Edmundson Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglprogrambinarycache.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/gui/opengl/qopenglprogrambinarycache.cpp') diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index f2d093ebed8..0f031013298 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -54,6 +54,10 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(DBG_SHADER_CACHE) +#ifndef GL_CONTEXT_LOST +#define GL_CONTEXT_LOST 0x0507 +#endif + #ifndef GL_PROGRAM_BINARY_LENGTH #define GL_PROGRAM_BINARY_LENGTH 0x8741 #endif @@ -161,7 +165,11 @@ bool QOpenGLProgramBinaryCache::verifyHeader(const QByteArray &buf) const bool QOpenGLProgramBinaryCache::setProgramBinary(uint programId, uint blobFormat, const void *p, uint blobSize) { QOpenGLExtraFunctions *funcs = QOpenGLContext::currentContext()->extraFunctions(); - while (funcs->glGetError() != GL_NO_ERROR) { } + while (true) { + GLenum error = funcs->glGetError(); + if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) + break; + } funcs->glProgramBinary(programId, blobFormat, p, blobSize); GLenum err = funcs->glGetError(); @@ -337,7 +345,11 @@ void QOpenGLProgramBinaryCache::save(const QByteArray &cacheKey, uint programId) QOpenGLExtraFunctions *funcs = QOpenGLContext::currentContext()->extraFunctions(); GLint blobSize = 0; - while (funcs->glGetError() != GL_NO_ERROR) { } + while (true) { + GLenum error = funcs->glGetError(); + if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) + break; + } funcs->glGetProgramiv(programId, GL_PROGRAM_BINARY_LENGTH, &blobSize); const int headerSize = FULL_HEADER_SIZE(info.glvendor.size() + info.glrenderer.size() + info.glversion.size()); -- cgit v1.2.3