Skip to content

Commit

Permalink
rhi: Use Q_GLOBAL_STATIC for QRhiGles2 GL program cache
Browse files Browse the repository at this point in the history
Defers initialization until actually needed.

Change-Id: Idb09dbad0dfa602949d381ee61565d9050e77e7c
Reviewed-by: Laszlo Agocs <[email protected]>
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
torarnv committed Oct 24, 2019
1 parent 444e947 commit 7c9ffe3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gui/rhi/qrhigles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 7c9ffe3

Please sign in to comment.