summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglprogrambinarycache.cpp
Commit message (Collapse)AuthorAgeFilesLines
* gl: Try the local CacheLocation when the shared one failsLaszlo Agocs2021-10-081-19/+42
| | | | | | | | | | | | | | | | | | | | | | | We prefer the shared cache path, because there is no reason to give up benefitting from sharing the content between applications. If that path is not QFileInfo().isWritable(), we fall back to the local cache path. However, there are reportedly systems with security solutions such as AppArmor where the writable check passes and yet attempting to create a file still fails. Then there is no cache in effect, because nothing ever gets written out. Handle this better: if writing the file fails and we still use our first choice, the global cache location, fall back to the secondary choice (the app-local path) and try again. Fixes: QTBUG-96789 Change-Id: Ifea32e9af0cf85aa70f3069256ed3d6a7e2fbe90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Dalton Durst <dalton@ubports.com> Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 46e6a9a759ae89f905107ccad191ca5ddf442e53) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Get rid of QT_OPENGL_ES*Eskil Abrahamsen Blomfeldt2020-04-171-3/+3
| | | | | | | | | | | The QT_OPENGL_ES* macros are leftovers from an earlier, ad hoc configuration system, which has since been replaced by QT_CONFIG. To clean things up in Qt 6, we use the new way instead. Task-number: QTBUG-83467 Change-Id: I578dc7695bff9d5ee303b22e44f60fee22fe0c28 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move QOpenGLShaderProgram from QtGui to QtOpenGLJohan Klokkhammer Helsing2020-02-201-1/+0
| | | | | | Task-number: QTBUG-74409 Change-Id: I20dfafc0c9bf8e2b68b03e171d70c2cb4ad2bfaf Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Share and enable shader disk cache in QRhi OpenGL backendLaszlo Agocs2019-09-301-17/+63
| | | | | | | | | | | | | | | The expectation for it is to function identically to what we get with QOpenGLShaderProgram. (same environment variables, same logging categories, etc.). QOpenGLProgramBinaryCache is now shared between the QOpenGL convenience classes (like QOpenGLShaderProgram) and QRhi. To achieve more modularity and to prepare for QOpenGLShaderProgram and friends moving out of QtGui, this class cannot depend on QOpenGLShader* anymore. This involves adding some minor conversions between QRhi and QOpenGL enums for example. Change-Id: I2f4664e074823ea536281aea8006a6db159a7381 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Move cache key calculation to QOpenGLProgramBinaryCacheLaszlo Agocs2019-09-261-0/+10
| | | | | | | | This class will likely be used by the OpenGL backend of QRhi as well. Therefore, we need to make it more self-contained and independent. Change-Id: If046ed41e25c70cc9abb45219b451f9179feaa1c Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-041-3/+3
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/codecs/qicucodec.cpp src/dbus/qdbusserver.cpp src/gui/painting/qbezier.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/printsupport/cups/qppdprintdevice.cpp Change-Id: I2703128bb64baf5580fbc2c2061b55b0f0611d2a
| * Avoid double QCache lookup in QOpenGLProgramBinaryCacheLaszlo Agocs2019-08-221-3/+1
| | | | | | | | | | Change-Id: I4384a15f0b89e1f6d7f59bff1816fc2e6fc6adfe Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * Guard with a mutex in QOpenGLProgramBinaryCache where neededLaszlo Agocs2019-08-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | While there is likely no example of it in Qt itself, applications can use QOpenGLShaderProgram instances on different threads. These instances have nothing to do with each other but they do share a global cache object. This becomes problematic without proper synchronization. Change-Id: I80faf73f34af7e67349eee916bb3f216e22c07fd Fixes: QTBUG-77469 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-08-161-1/+2
|\| | | | | | | Change-Id: Ia3645f92b9debf3e1fe2d972300c7d0dbd649268
| * Include buildAbi() in the shader cache directory nameLaszlo Agocs2019-08-141-1/+2
| | | | | | | | | | | | Task-number: QTBUG-64697 Change-Id: I8b81bce94c50464105a9a43086b06b841e4b8551 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-271-2/+29
|\| | | | | | | Change-Id: Ic6cfe08dbda1dc92b969e67063f805df63ba0fcf
| * Enable shader cache for ES2 when GL_OES_get_program_binary is presentMichael Brasser2019-07-251-2/+29
| | | | | | | | | | Change-Id: I4fb71471a7dd22441def1eb837857d245c3e3c5a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | Fix build without feature.temporaryfileTasuku Suzuki2019-07-111-0/+6
|/ | | | | Change-Id: I096b6a7d9cc8e17165e07657f6647a14baafefa5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Drop cached shaders when arch is differentLaszlo Agocs2018-10-161-2/+7
| | | | | | | | | | | According to reports Intel on Windows gets confused when feeding program binaries retrieved from x86 and x64 builds into each other. Task-number: QTBUG-64697 Change-Id: Ia7748f532ad06942a92c6fbfc4c9d1ad16bc785a Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* More fixups for GL_CONTEXT_LOSTAllan Sandfeld Jensen2018-09-251-2/+14
| | | | | | | | | | 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 <davidedmundson@kde.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Make local symbols of some leaked namesThiago Macieira2018-08-031-0/+2
| | | | | | | | | Unnamed namespaces and static are great tools. Use them. Change-Id: Ie01831ddac5446fdbdeefffd15468b3acb3ced79 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* opengl: Bail if cached shader fails to loadAntonio Larrosa2018-02-211-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Align blob start in program binary disk cacheLaszlo Agocs2017-01-241-48/+88
| | | | | | | | | | | | Make INTEGRITY happy. While we are at it, clean up the way the data is composed and accessed and avoid unaligned uint32* accesses on our side as well. Task-number: QTBUG-58183 Change-Id: I357be4b6844e5e8b8d27261a3676e135faea6250 Reviewed-by: Kimmo Ollila <kimmo.ollila@theqtcompany.com> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use QSaveFile for more robust shader disk cacheLaszlo Agocs2016-11-251-4/+8
| | | | | | Task-number: QTBUG-55496 Change-Id: Ie9bd4390e7bb7bf22dbe597a6a01fecec7a6b404 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add an OpenGL program binary disk cacheLaszlo Agocs2016-11-241-0/+332
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 <edward.welbourne@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>