From 0628932fef349d217c0a50a192e7ee6a955994b7 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 26 Sep 2019 11:26:51 +0200 Subject: Move cache key calculation to QOpenGLProgramBinaryCache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gui/opengl/qopenglprogrambinarycache.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gui/opengl/qopenglprogrambinarycache.cpp') diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp index 54160e1240..1495471457 100644 --- a/src/gui/opengl/qopenglprogrambinarycache.cpp +++ b/src/gui/opengl/qopenglprogrambinarycache.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef Q_OS_UNIX #include @@ -94,6 +95,15 @@ GLEnvInfo::GLEnvInfo() glversion = QByteArray(version); } +QByteArray QOpenGLProgramBinaryCache::ProgramDesc::cacheKey() const +{ + QCryptographicHash keyBuilder(QCryptographicHash::Sha1); + for (const QOpenGLProgramBinaryCache::ShaderDesc &shader : shaders) + keyBuilder.addData(shader.source); + + return keyBuilder.result().toHex(); +} + static inline bool qt_ensureWritableDir(const QString &name) { QDir::root().mkpath(name); -- cgit v1.2.3