From e70e2f7d98f7763463413bfd6d2f9300e48087b4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 16 Sep 2021 14:43:00 +0200 Subject: Reinitialize shader data structure when effect changes Shaders might not all have the same number of uniforms and locations, so reinitialize the array when the effect changes. Change-Id: I16b4f6b865ebe7b74c2960a1e88b8f12b83ee2b3 Done-with: Matt Galloway Fixes: QTBUG-55204 Reviewed-by: Laszlo Agocs --- src/quick/items/qquickopenglshadereffectnode.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquickopenglshadereffectnode.cpp') diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp index 7bbed42a6f..9222cabf49 100644 --- a/src/quick/items/qquickopenglshadereffectnode.cpp +++ b/src/quick/items/qquickopenglshadereffectnode.cpp @@ -120,10 +120,13 @@ void QQuickCustomMaterialShader::updateState(const RenderState &state, QSGMateri : QQuickShaderEffect::Error); } + if (newEffect != oldEffect) + m_initialized = false; + int textureProviderIndex = 0; if (!m_initialized) { for (int shaderType = 0; shaderType < QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount; ++shaderType) { - Q_ASSERT(m_uniformLocs[shaderType].isEmpty()); + m_uniformLocs[shaderType].clear(); m_uniformLocs[shaderType].reserve(material->uniforms[shaderType].size()); for (int i = 0; i < material->uniforms[shaderType].size(); ++i) { const UniformData &d = material->uniforms[shaderType].at(i); -- cgit v1.2.3