From e81a2d03d80d71c886b9214455e94f47ffb5ede1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 Nov 2024 14:00:28 +0100 Subject: [PATCH] rhi: gl: Maintain Qt 5 compat wrt disk cache behavior Task-number: QTBUG-126608 Change-Id: Id78d6fbdfec6d69bfec2fe9deab82e84f2588b29 Reviewed-by: Andy Nichols (cherry picked from commit 38279dea558b06cef6c1d345962df3063fd12c5b) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhigles2.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 53523ba9143..91075be50c9 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -6371,11 +6371,18 @@ bool QGles2GraphicsPipeline::create() // force replacing existing cache entry (if there is one, then // something is wrong with it, as there was no hit) rhiD->trySaveToPipelineCache(program, cacheKey, true); - } else { - // legacy QOpenGLShaderProgram style behavior: the "pipeline cache" - // was not enabled, so instead store to the Qt 5 disk cache - rhiD->trySaveToDiskCache(program, cacheKey); } + // legacy QOpenGLShaderProgram style behavior: do this always, even + // though it is superfluous with the "pipeline cache" enabled. Continue + // storing to the Qt 5 style individual-file disk cache, because there + // is no guarantee one retrieves the "pipeline cache" blob and writes it + // out. Classic example: if Qt Quick only retrieves and stores the + // combined cache contents when exiting, applications that never exit + // cleanly (because they are killed, Ctrl+C'd, etc.) never store any + // program binaries! Therefore, to maintain Qt 5 behavioral + // compatibility, continue writing out the individual files no matter + // what. + rhiD->trySaveToDiskCache(program, cacheKey); } else { Q_ASSERT(cacheResult == QRhiGles2::ProgramCacheHit); if (rhiD->rhiFlags.testFlag(QRhi::EnablePipelineCacheDataSave)) { @@ -6491,11 +6498,9 @@ bool QGles2ComputePipeline::create() // force replacing existing cache entry (if there is one, then // something is wrong with it, as there was no hit) rhiD->trySaveToPipelineCache(program, cacheKey, true); - } else { - // legacy QOpenGLShaderProgram style behavior: the "pipeline cache" - // was not enabled, so instead store to the Qt 5 disk cache - rhiD->trySaveToDiskCache(program, cacheKey); } + // legacy QOpenGLShaderProgram style behavior + rhiD->trySaveToDiskCache(program, cacheKey); } else { Q_ASSERT(cacheResult == QRhiGles2::ProgramCacheHit); if (rhiD->rhiFlags.testFlag(QRhi::EnablePipelineCacheDataSave)) {