summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-10-30 15:13:18 +0100
committerPaul Lemire <paul.lemire@kdab.com>2019-10-30 15:25:38 +0100
commitdb9f0721c4406843766aab66d1cae170e76a237d (patch)
treeed737b1fb0f95e58244ef22f41210dac9e17cf1d /src/render
parente5b5505569b409798e382d60b71fbf436952bab9 (diff)
Buffer: make sure we force allocate before doing partial updates
Change-Id: I229f9bcd21a10c0a4cff5c4f559cd285a3e50276 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render')
-rw-r--r--src/render/geometry/buffer.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/render/geometry/buffer.cpp b/src/render/geometry/buffer.cpp
index 0d634c911..6db3bab44 100644
--- a/src/render/geometry/buffer.cpp
+++ b/src/render/geometry/buffer.cpp
@@ -137,20 +137,31 @@ void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
m_manager->addDirtyBuffer(peerId());
}
{
- QVariant v = node->property("QT3D_updateData");
- if (v.isValid()) {
+ const QVariant v = node->property("QT3D_updateData");
+
+ // Make sure we record data if it's the first time we are called
+ // or if we have no partial updates
+ if (firstTime || !v.isValid()){
+ const QByteArray newData = node->data();
+ const bool dirty = m_data != newData;
+ m_bufferDirty |= dirty;
+ m_data = newData;
+
+ // Since frontend applies partial updates to its m_data
+ // if we enter this code block, there's no problem in actually
+ // ignoring the partial updates
+ if (v.isValid())
+ const_cast<QBuffer *>(node)->setProperty("QT3D_updateData", {});
+
+ if (dirty && !m_data.isEmpty())
+ forceDataUpload();
+ } else if (v.isValid()) {
+ // Apply partial updates and record them to allow partial upload to the GPU
Qt3DRender::QBufferUpdate updateData = v.value<Qt3DRender::QBufferUpdate>();
m_data.replace(updateData.offset, updateData.data.size(), updateData.data);
m_bufferUpdates.push_back(updateData);
m_bufferDirty = true;
const_cast<QBuffer *>(node)->setProperty("QT3D_updateData", {});
- } else {
- QByteArray newData = node->data();
- bool dirty = m_data != newData;
- m_bufferDirty |= dirty;
- m_data = newData;
- if (dirty && !m_data.isEmpty())
- forceDataUpload();
}
}
markDirty(AbstractRenderer::BuffersDirty);