path: root/src/gui/opengl/qopenglengineshadermanager_p.h
diff options
authorLaszlo Agocs <>2016-09-29 12:59:06 +0200
committerLaszlo Agocs <>2016-11-24 10:27:16 +0000
commit85f868e73e4cf9dffe27b737f8dc3f5bb626ed04 (patch)
tree60f19e5319e14957e98edeeafaa8da8279972b75 /src/gui/opengl/qopenglengineshadermanager_p.h
parentffd316ebe3963b7ff8d94a3484ac85de793b8299 (diff)
Add an OpenGL program binary disk cache
Introduce a glProgramBinary-based disk cache in QOpenGLShaderProgram. By switching the typical program->addShaderFromSourceCode(QOpenGLShader::Vertex, ...) program->addShaderFromSourceCode(QOpenGLShader::Fragment, ...) invocations to program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, ...) program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, ...) the compilation may be skipped via gl(Get)ProgramBinary and a disk cache, when supported. Such QOpenGLShaderProgram instances will have no QOpenGLShader instances attached. Instead, the entire program binary (which is driver-specific) is loaded as-is. Support means OpenGL ES 3.0 or the presence of GL_ARB_get_program_binary, in combination with >= 1 supported binary formats. Note that some drivers claim program binary support but expose no formats. This amounts to no support in practice. When support is not present, calling the new functions is equivalent to the non-cacheable variants. If the OpenGL driver changes (vendor, renderer, version strings), recompilation and storage of the new, potentially incompatible binary program will happen transparently. The cache can always be disabled by setting QT_DISABLE_SHADER_DISK_CACHE=1 or the new application attribute Qt::AA_DisableShaderDiskCache. Location-wise the primary choice is the shared cache (GenericCacheLocation). If this is not available or is not writable, the per-process one (CacheLocation) is used instead. In addition to the new public APIs in QOpenGLShaderProgram, the main shader users in QtGui are migrated as well. (OpenGL paint engine, glyph cache, blitter, eglfs mouse cursor). This means that any application using QPainter on OpenGL or widgets with eglfs will benefit from the improved startup times. Qt Quick will follow suit as well. [ChangeLog][QtGui][OpenGL] QOpenGLShaderProgram offers a built-in program binary disk cache for systems with OpenGL ES 3.x or GL_ARB_get_program_binary. This can lead to significant increases in performance when it comes to application startup times for example. Usage is opt-in for direct C++ users of the class, however Qt's own main users of shaders, including Qt Quick and QPainter's OpenGL engine, are migrated to use the new, cache-enabled APIs. Opting out on application level is always possible via Qt::AA_DisableShaderDiskCache. Task-number: QTBUG-55496 Change-Id: I556f053d258bfa6887b1d5238c9f6396914c5421 Reviewed-by: Edward Welbourne <> Reviewed-by: Andy Nichols <>
Diffstat (limited to 'src/gui/opengl/qopenglengineshadermanager_p.h')
1 files changed, 0 insertions, 1 deletions
diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h
index 23b2ccf486..377501457d 100644
--- a/src/gui/opengl/qopenglengineshadermanager_p.h
+++ b/src/gui/opengl/qopenglengineshadermanager_p.h
@@ -366,7 +366,6 @@ private:
QOpenGLShaderProgram *blitShaderProg;
QOpenGLShaderProgram *simpleShaderProg;
QList<QOpenGLEngineShaderProg*> cachedPrograms;
- QList<QOpenGLShader *> shaders;
static const char* qShaderSnippets[TotalSnippetCount];