summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-10-23 14:16:24 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-10-24 12:18:30 +0200
commit7c9ffe3e46bca3cfdec6fd1db3da4c96a6d5acd6 (patch)
tree82b2232df52797de9cc2571910a1e1a03a496ee6
parent444e947aadc82e2aeb72fa5b3e6a352ff02441f2 (diff)
rhi: Use Q_GLOBAL_STATIC for QRhiGles2 GL program cache
Defers initialization until actually needed. Change-Id: Idb09dbad0dfa602949d381ee61565d9050e77e7c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/gui/rhi/qrhigles2.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index dec28cac9b..abee843a74 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -2961,7 +2961,7 @@ bool QRhiGles2::isProgramBinaryDiskCacheEnabled() const
return checker.get(ctx)->isSupported();
}
-static QOpenGLProgramBinaryCache qrhi_programBinaryCache;
+Q_GLOBAL_STATIC(QOpenGLProgramBinaryCache, qrhi_programBinaryCache);
static inline QShader::Stage toShaderStage(QRhiShaderStage::Type type)
{
@@ -2995,7 +2995,7 @@ QRhiGles2::DiskCacheResult QRhiGles2::tryLoadFromDiskCache(const QRhiShaderStage
}
diskCacheKey = binaryProgram.cacheKey();
- if (qrhi_programBinaryCache.load(diskCacheKey, program)) {
+ if (qrhi_programBinaryCache()->load(diskCacheKey, program)) {
qCDebug(lcOpenGLProgramDiskCache, "Program binary received from cache, program %u, key %s",
program, diskCacheKey.constData());
result = QRhiGles2::DiskCacheHit;
@@ -3013,7 +3013,7 @@ void QRhiGles2::trySaveToDiskCache(GLuint program, const QByteArray &cacheKey)
if (isProgramBinaryDiskCacheEnabled()) {
qCDebug(lcOpenGLProgramDiskCache, "Saving program binary, program %u, key %s",
program, cacheKey.constData());
- qrhi_programBinaryCache.save(cacheKey, program);
+ qrhi_programBinaryCache()->save(cacheKey, program);
}
}