aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-11-23 12:17:40 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-11-23 14:29:02 +0100
commitf95b99902fae6e53a9da5fbccb6e1616299fb3bf (patch)
treedc96eeee32fb4d64665632bc725abea3a105d7e9 /src/quick/items
parent56f428c360191230b571969a2651e85380030afa (diff)
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. Pick-to: 6.0 Fixes: QTBUG-88673 Change-Id: I201750716d3ba6dbe73a4799ac56f26f9b8ec820 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickshadereffect.cpp16
1 files changed, 8 insertions, 8 deletions
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();