From 9c733e3944e93c7eb7c9e1f4dcd22dce3d34206e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Nov 2020 12:17:40 +0100 Subject: Re-enable the caching of shader data loaded from files There was a mismatch for the cache key: sometimes using the original url as specified in the QML code, sometimes using the resolved url (which has, for example, a relative path expanded to absolute). Change this to be consistent. Fixes: QTBUG-88673 Change-Id: I201750716d3ba6dbe73a4799ac56f26f9b8ec820 Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit f95b99902fae6e53a9da5fbccb6e1616299fb3bf) Reviewed-by: Qt Cherry-pick Bot --- src/quick/items/qquickshadereffect.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/quick') diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index c2cf30a30e..0513f7bfa4 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -440,7 +440,7 @@ private slots: void markGeometryDirtyAndUpdate(); void markGeometryDirtyAndUpdateIfSupportsAtlas(); void shaderCodePrepared(bool ok, QSGGuiThreadShaderEffectManager::ShaderInfo::Type typeHint, - const QUrl &fileUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result); + const QUrl &loadUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result); private: QSGGuiThreadShaderEffectManager *shaderEffectManager() const; @@ -1193,8 +1193,10 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl m_shaders[shaderType].varData.clear(); if (!fileUrl.isEmpty()) { - if (shaderInfoCache()->contains(fileUrl)) { - m_shaders[shaderType].shaderInfo = shaderInfoCache()->value(fileUrl); + const QQmlContext *context = qmlContext(m_item); + const QUrl loadUrl = context ? context->resolvedUrl(fileUrl) : fileUrl; + if (shaderInfoCache()->contains(loadUrl)) { + m_shaders[shaderType].shaderInfo = shaderInfoCache()->value(loadUrl); m_shaders[shaderType].hasShaderCode = true; } else { // Each prepareShaderCode call needs its own work area, hence the @@ -1205,8 +1207,6 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl const QSGGuiThreadShaderEffectManager::ShaderInfo::Type typeHint = shaderType == Vertex ? QSGGuiThreadShaderEffectManager::ShaderInfo::TypeVertex : QSGGuiThreadShaderEffectManager::ShaderInfo::TypeFragment; - const QQmlContext *context = qmlContext(m_item); - const QUrl loadUrl = context ? context->resolvedUrl(fileUrl) : fileUrl; // Figure out what input parameters and variables are used in the // shader. This is where the data is pulled in from the file. // (however, if there is compilation involved, that happens at a @@ -1239,7 +1239,7 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl } void QQuickShaderEffectImpl::shaderCodePrepared(bool ok, QSGGuiThreadShaderEffectManager::ShaderInfo::Type typeHint, - const QUrl &fileUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result) + const QUrl &loadUrl, QSGGuiThreadShaderEffectManager::ShaderInfo *result) { const Shader shaderType = typeHint == QSGGuiThreadShaderEffectManager::ShaderInfo::TypeVertex ? Vertex : Fragment; @@ -1256,13 +1256,13 @@ void QQuickShaderEffectImpl::shaderCodePrepared(bool ok, QSGGuiThreadShaderEffec if (!ok) { qWarning("ShaderEffect: shader preparation failed for %s\n%s\n", - qPrintable(fileUrl.toString()), qPrintable(log())); + qPrintable(loadUrl.toString()), qPrintable(log())); m_shaders[shaderType].hasShaderCode = false; return; } m_shaders[shaderType].hasShaderCode = true; - shaderInfoCache()->insert(fileUrl, m_shaders[shaderType].shaderInfo); + shaderInfoCache()->insert(loadUrl, m_shaders[shaderType].shaderInfo); updateShaderVars(shaderType); m_dirty |= QSGShaderEffectNode::DirtyShaders; m_item->update(); -- cgit v1.2.3