aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickshadereffectnode_p.h
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2015-10-19 14:50:06 +0200
committerGunnar Sletta <gunnar@sletta.org>2015-10-20 05:41:07 +0000
commitd12391470f5a9b2f0ae22e11960177c5b7496a75 (patch)
tree2c613ccbe944f17252f3a4c93b5015f453a63458 /src/quick/items/qquickshadereffectnode_p.h
parent3e9f61f305dc4c988e6f2718df56df80f639734e (diff)
Make it possible to change sources of ShaderEffect again.
92433623b31388e2e8c4d532033dad6189eaab24 introduced a bug where an unused material would clear its typeid pointer. This resulted in that a changed shadereffect would in all likelyhood get the same pointer for its changed shader which would result in using the same GL shader inside the renderer. This change rewrites the logic so that the cache is per render thread and the cache is cleaned up along with other GL/SG resources as part of scene graph invalidation. Task-number: QTBUG-48856 Change-Id: Id2feb14f584b5f5c176e8176cc9f1b54abd0d079 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'src/quick/items/qquickshadereffectnode_p.h')
-rw-r--r--src/quick/items/qquickshadereffectnode_p.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/quick/items/qquickshadereffectnode_p.h b/src/quick/items/qquickshadereffectnode_p.h
index 28382c483c..a6a6d1b2fc 100644
--- a/src/quick/items/qquickshadereffectnode_p.h
+++ b/src/quick/items/qquickshadereffectnode_p.h
@@ -62,7 +62,6 @@ struct QQuickShaderEffectMaterialKey {
uint qHash(const QQuickShaderEffectMaterialKey &key);
-
class QQuickCustomMaterialShader;
class QQuickShaderEffectNode;
class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffectMaterial : public QSGMaterial
@@ -106,13 +105,12 @@ public:
protected:
friend class QQuickCustomMaterialShader;
- // The type pointer needs to be unique. It is not safe to let the type object be part of the
- // QQuickShaderEffectMaterial, since it can be deleted and a new one constructed on top of the old
- // one. The new QQuickShaderEffectMaterial would then get the same type pointer as the old one, and
- // CustomMaterialShaders based on the old one would incorrectly be used together with the new
- // one. To guarantee that the type pointer is unique, the type object must live as long as
- // there are any CustomMaterialShaders of that type.
- QSharedPointer<QSGMaterialType> m_type;
+ // Each material needs a unique type to ensure that the renderer has a one
+ // and exactly one GL program for every unique set of shader sources.
+ // setProgramSource() stores the sources in a cache along with the right
+ // type. The type is cleaned up in cleanupMaterialCache() which is called
+ // when the GL context is shut down.
+ QSGMaterialType *m_type;
QQuickShaderEffectMaterialKey m_source;
QQuickShaderEffectNode *m_node;