aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2020-05-20 15:40:33 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2020-05-22 14:28:03 +0200
commit84e87fd38e7cff31b88abc52d774299890545b92 (patch)
tree2f0af40e6d8fefc90ff2c605b30b9bff2f22d1fa /src
parent2ad9d682bd64328fc341e0c28123976fbde8b792 (diff)
Don't detach from atlas when using qt_SubRect_foo
Fixes: QTBUG-84299 Change-Id: Ib1c73ae5e7f5df8d4390d33ce0e61c06b052cd59 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp8
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode_p.h3
2 files changed, 9 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index 5d3b158de8..0508ae9c7a 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -62,6 +62,7 @@ void QSGRhiShaderLinker::reset(const QShader &vs, const QShader &fs)
m_constants.clear();
m_samplers.clear();
m_samplerNameMap.clear();
+ m_subRectBindings.clear();
}
void QSGRhiShaderLinker::feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices)
@@ -140,7 +141,9 @@ void QSGRhiShaderLinker::linkTextureSubRects()
const QByteArray name = c.value.toByteArray();
if (!m_samplerNameMap.contains(name))
qWarning("ShaderEffect: qt_SubRect_%s refers to unknown source texture", name.constData());
- c.value = m_samplerNameMap[name];
+ const int binding = m_samplerNameMap[name];
+ c.value = binding;
+ m_subRectBindings.insert(binding);
}
}
}
@@ -394,7 +397,8 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, in
if (tp) {
if (QSGTexture *t = tp->texture()) {
t->commitTextureOperations(state.rhi(), state.resourceUpdateBatch());
- if (t->isAtlasTexture() && !mat->m_geometryUsesTextureSubRect) {
+
+ if (t->isAtlasTexture() && !mat->m_geometryUsesTextureSubRect && !mat->usesSubRectUniform(binding)) {
// Why the hassle with the batch: while removedFromAtlas() is
// able to operate with its own resource update batch (which is
// then committed immediately), that approach is wrong when the
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode_p.h b/src/quick/scenegraph/qsgrhishadereffectnode_p.h
index fb98bbf10e..08f1af9f6e 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode_p.h
+++ b/src/quick/scenegraph/qsgrhishadereffectnode_p.h
@@ -89,6 +89,7 @@ public:
QHash<uint, Constant> m_constants; // offset -> Constant
QHash<int, QVariant> m_samplers; // binding -> value (source ref)
QHash<QByteArray, int> m_samplerNameMap; // name -> binding
+ QSet<int> m_subRectBindings;
};
QDebug operator<<(QDebug debug, const QSGRhiShaderLinker::Constant &c);
@@ -105,6 +106,8 @@ public:
void updateTextureProviders(bool layoutChange);
+ bool usesSubRectUniform(int binding) const { return m_linker.m_subRectBindings.contains(binding); }
+
static const int MAX_BINDINGS = 32;
QSGRhiShaderEffectNode *m_node;