Increase cache size for QOpenGLTextureCache

Currently images that does not fit in the cache will be destroyed, which
is unfortunate. 256 MB cache is too small for todays standards, so
increasing it to 1 GB. Also adding an environment variable so that it is
changeable if required.

Fixes: QTBUG-111498
Pick-to: 6.5
Change-Id: I70c65cad6219a59102b16abc50f098aa0b017314
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Kristoffer Skau 2023-02-27 13:33:32 +01:00
parent b6bc4199ec
commit 55568b8c62

View File

@ -61,9 +61,19 @@ void QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData(QPlatformPixmap *p
cleanupTexturesForCacheKey(pmd->cacheKey()); cleanupTexturesForCacheKey(pmd->cacheKey());
} }
static quint64 cacheSize()
{
bool ok = false;
const int envCacheSize = qEnvironmentVariableIntValue("QT_OPENGL_TEXTURE_CACHE_SIZE", &ok);
if (ok)
return envCacheSize;
return 1024 * 1024; // 1024 MB cache default
}
QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx) QOpenGLTextureCache::QOpenGLTextureCache(QOpenGLContext *ctx)
: QOpenGLSharedResource(ctx->shareGroup()) : QOpenGLSharedResource(ctx->shareGroup())
, m_cache(256 * 1024) // 256 MB cache , m_cache(cacheSize())
{ {
} }