summaryrefslogtreecommitdiffstats
path: root/src/render/geometry
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-06-04 14:20:44 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-06-08 14:07:43 +0200
commitf60af06970181fe9d026c654653d0f8f91fb4973 (patch)
treec65262513bba29dd87d6f9bb776d23a9194ff70b /src/render/geometry
parentc1b6293728b062a37a65d9f2bde16e750f0952a1 (diff)
Fix QBuffer::updateData being called several times in a row
QBuffer::updateData would send a single update at the time and would overwrite the latest update if it was called again before synching with the backend took place. This patches fixes by storing a list of pending updates instead. Change-Id: I1fc501ad921c953ec88117fcc49c0cfcde6ca8aa Task-number: QTBUG-81921 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/geometry')
-rw-r--r--src/render/geometry/buffer.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/render/geometry/buffer.cpp b/src/render/geometry/buffer.cpp
index f7a1f376c..d9c1ac788 100644
--- a/src/render/geometry/buffer.cpp
+++ b/src/render/geometry/buffer.cpp
@@ -112,7 +112,7 @@ void Buffer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
m_bufferDirty = true;
}
{
- const QVariant v = node->property("QT3D_updateData");
+ const QVariant v = node->property(Qt3DCore::QBufferPrivate::UpdateDataPropertyName);
// Make sure we record data if it's the first time we are called
// or if we have no partial updates
@@ -126,17 +126,21 @@ void Buffer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
// if we enter this code block, there's no problem in actually
// ignoring the partial updates
if (v.isValid())
- const_cast<Qt3DCore::QBuffer *>(node)->setProperty("QT3D_updateData", {});
+ const_cast<Qt3DCore::QBuffer *>(node)->setProperty(Qt3DCore::QBufferPrivate::UpdateDataPropertyName, {});
if (dirty && !m_data.isEmpty())
forceDataUpload();
} else if (v.isValid()) {
// Apply partial updates and record them to allow partial upload to the GPU
- Qt3DCore::QBufferUpdate updateData = v.value<Qt3DCore::QBufferUpdate>();
- m_data.replace(updateData.offset, updateData.data.size(), updateData.data);
- m_bufferUpdates.push_back(updateData);
- m_bufferDirty = true;
- const_cast<Qt3DCore::QBuffer *>(node)->setProperty("QT3D_updateData", {});
+ const QVariantList updateList = v.toList();
+ for (const QVariant &update : updateList) {
+ Qt3DCore::QBufferUpdate updateData = update.value<Qt3DCore::QBufferUpdate>();
+ m_data.replace(updateData.offset, updateData.data.size(), updateData.data);
+ m_bufferUpdates.push_back(updateData);
+ m_bufferDirty = true;
+ }
+
+ const_cast<Qt3DCore::QBuffer *>(node)->setProperty(Qt3DCore::QBufferPrivate::UpdateDataPropertyName, {});
}
}
markDirty(AbstractRenderer::BuffersDirty);