From 31fe414dbcb750ad9fb53b1607cb555875b480e5 Mon Sep 17 00:00:00 2001 From: Rex Dieter Date: Wed, 21 Feb 2018 09:16:10 -0600 Subject: [PATCH] QOpenGLShaderProgram: glProgramBinary() resulting in LINK_STATUS=FALSE not handled properly (QTBUG-66420) pull in opensuse patch for now --- ...-Bail-if-cached-shader-fails-to-load.patch | 79 +++++++++++++++++++ qt5-qtbase.spec | 9 ++- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 opengl-Bail-if-cached-shader-fails-to-load.patch diff --git a/opengl-Bail-if-cached-shader-fails-to-load.patch b/opengl-Bail-if-cached-shader-fails-to-load.patch new file mode 100644 index 0000000..fbd26da --- /dev/null +++ b/opengl-Bail-if-cached-shader-fails-to-load.patch @@ -0,0 +1,79 @@ +From 3bb3ee936f27e9749bf1a2c4bd5ded2f5167663f Mon Sep 17 00:00:00 2001 +From: Max Staudt +Date: Mon, 12 Feb 2018 15:07:29 +0100 +Subject: [PATCH] opengl: Bail if cached shader fails to load +References: boo#1080578, boo#1079465 +Signed-off-by: Max Staudt + +QOpenGLProgramBinaryCache::setProgramBinary() should check +GL_LINK_STATUS after glProgramBinary(), but doesn't. + +In practice, this means that SDDM is a white screen, and KDE is just +a gray task bar. + +So far, Qt tries to check this using its internal ::link() function. +But in case the cached binary fails to load, Qt currently attempts to +link the inexistent program, resulting in a zero-length, fixed +pipeline shader. + +Checking this already in ::setProgramBinary() makes the call to +::link() superfluous, so we remove that as well. + +Many thanks to Michal Srb and Fabian Vogt for hunting this down. +This was truly a joint effort. + +Cc: Michal Srb +Cc: Fabian Vogt +Signed-off-by: Max Staudt +--- + src/gui/opengl/qopenglprogrambinarycache.cpp | 11 ++++++++++- + src/gui/opengl/qopenglshaderprogram.cpp | 8 +------- + 2 files changed, 11 insertions(+), 8 deletions(-) + +diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp +index 06373e1113..f50878ab5c 100644 +--- a/src/gui/opengl/qopenglprogrambinarycache.cpp ++++ b/src/gui/opengl/qopenglprogrambinarycache.cpp +@@ -161,10 +161,19 @@ bool QOpenGLProgramBinaryCache::setProgramBinary(uint programId, uint blobFormat + QOpenGLExtraFunctions *funcs = QOpenGLContext::currentContext()->extraFunctions(); + while (funcs->glGetError() != GL_NO_ERROR) { } + funcs->glProgramBinary(programId, blobFormat, p, blobSize); ++ + int err = funcs->glGetError(); ++ GLint link_status = 0; ++ funcs->glGetProgramiv(programId, GL_LINK_STATUS, &link_status); ++ if (link_status != GL_TRUE || err != GL_NO_ERROR) { ++ qCDebug(DBG_SHADER_CACHE, "Program binary failed to load for program %u, size %d, format 0x%x, link_status = 0x%x, err = 0x%x", ++ programId, blobSize, blobFormat, link_status, err); ++ return false; ++ } ++ + qCDebug(DBG_SHADER_CACHE, "Program binary set for program %u, size %d, format 0x%x, err = 0x%x", + programId, blobSize, blobFormat, err); +- return err == 0; ++ return true; + } + + #ifdef Q_OS_UNIX +diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp +index cc8af16bfe..3b82baccb3 100644 +--- a/src/gui/opengl/qopenglshaderprogram.cpp ++++ b/src/gui/opengl/qopenglshaderprogram.cpp +@@ -3824,13 +3824,7 @@ bool QOpenGLShaderProgramPrivate::linkBinary() + bool needsCompile = true; + if (binCache.load(cacheKey, q->programId())) { + qCDebug(DBG_SHADER_CACHE, "Program binary received from cache"); +- linkBinaryRecursion = true; +- bool ok = q->link(); +- linkBinaryRecursion = false; +- if (ok) +- needsCompile = false; +- else +- qCDebug(DBG_SHADER_CACHE, "Link failed after glProgramBinary"); ++ needsCompile = false; + } + + bool needsSave = false; +-- +2.13.6 + diff --git a/qt5-qtbase.spec b/qt5-qtbase.spec index 8e38eba..97852fd 100644 --- a/qt5-qtbase.spec +++ b/qt5-qtbase.spec @@ -51,7 +51,7 @@ BuildRequires: pkgconfig(libsystemd) Name: qt5-qtbase Summary: Qt5 - QtBase components Version: 5.10.1 -Release: 4%{?dist} +Release: 5%{?dist} # See LGPL_EXCEPTIONS.txt, for exception details License: LGPLv2 with exceptions or GPLv3 with exceptions @@ -109,6 +109,9 @@ Patch53: qtbase-fdo101667.patch # respect QMAKE_LFLAGS_RELEASE when building qmake Patch54: qtbase-qmake_LFLAGS.patch +# https://bugreports.qt.io/browse/QTBUG-66420 +Patch55: https://bugreports.qt.io/secure/attachment/69873/opengl-Bail-if-cached-shader-fails-to-load.patch + # drop -O3 and make -O2 by default Patch61: qt5-qtbase-cxxflag.patch @@ -361,6 +364,7 @@ Qt5 libraries used for drawing widgets and OpenGL items. %patch52 -p1 -b .moc_macros %patch53 -p1 -b .fdo101667 %patch54 -p1 -b .qmake_LFLAGS +%patch55 -p1 -b .QTBUG-66420 %patch61 -p1 -b .qt5-qtbase-cxxflag %patch64 -p1 -b .firebird %if 0%{?fedora} > 27 @@ -989,6 +993,9 @@ fi %changelog +* Wed Feb 21 2018 Rex Dieter - 5.10.1-5 +- QOpenGLShaderProgram: glProgramBinary() resulting in LINK_STATUS=FALSE not handled properly (QTBUG-66420) + * Fri Feb 16 2018 Rex Dieter - 5.10.1-4 - use %%make_build, %%ldconfig - drop %%_licensedir hack