diff options
Diffstat (limited to 'src/render/geometry/buffer.cpp')
-rw-r--r-- | src/render/geometry/buffer.cpp | 29 |
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); |