summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-03-10 14:39:41 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-15 08:57:23 +0000
commit90e71575fbe62162dec4efe659bd81e45e6c1628 (patch)
treec6de359f9a1df8a380aa29c229849f18c9a6be24 /src/gui
parente8151984021d33e732823a57de15ff64f79b7aee (diff)
rhi: metal: Skip unnecessary writes when updating the entire buffer
Follow the similar Vulkan change in 20eb40bce92c3e5460cd2540547f3c404fe6dccc and drop the queued up buffer data for a given slot when the current update covers the entire buffer. This is relevant in particular for Qt Quick 3D where such dynamic buffer changes are common. Change-Id: If1e70d78968586b552a5357bc97af10cc61d9611 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 0c6375a346551dbf2effb2ea54e1df7de56f0849) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/rhi/qrhimetal.mm5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index e6a12067d9..65f46f7f68 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -1699,8 +1699,11 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) {
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf);
Q_ASSERT(bufD->m_type == QRhiBuffer::Dynamic);
- for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i)
+ for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i) {
+ if (u.offset == 0 && u.data.size() == bufD->m_size)
+ bufD->d->pendingUpdates[i].clear();
bufD->d->pendingUpdates[i].append(u);
+ }
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) {
// Due to the Metal API the handling of static and dynamic buffers is
// basically the same. So go through the same pendingUpdates machinery.