Skip to content

Commit

Permalink
opengl: Bail if cached shader fails to load
Browse files Browse the repository at this point in the history
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.

Done-with: Max Staudt <mstaudt@suse.com>
Done-with: Michal Srb <msrb@suse.com>
Done-with: Fabian Vogt <fvogt@suse.de>
Task-number: QTBUG-66420
Change-Id: Iabb51d0eb2c0c16bde696efff623e57d15f28d82
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit fa091640134b3ff99a9eb92df8286d15203122bf)
  • Loading branch information
antlarr-suse authored and alpqr committed Feb 22, 2018
1 parent 9c3d5ff commit ef20989
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 18 additions & 2 deletions src/gui/opengl/qopenglprogrambinarycache.cpp
Expand Up @@ -161,10 +161,26 @@ 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();

GLenum err = funcs->glGetError();
if (err != GL_NO_ERROR) {
qCDebug(DBG_SHADER_CACHE, "Program binary failed to load for program %u, size %d, "
"format 0x%x, err = 0x%x",
programId, blobSize, blobFormat, err);
return false;
}
GLint linkStatus = 0;
funcs->glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
if (linkStatus != GL_TRUE) {
qCDebug(DBG_SHADER_CACHE, "Program binary failed to load for program %u, size %d, "
"format 0x%x, linkStatus = 0x%x, err = 0x%x",
programId, blobSize, blobFormat, linkStatus, 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
Expand Down
8 changes: 1 addition & 7 deletions src/gui/opengl/qopenglshaderprogram.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit ef20989

Please sign in to comment.