diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-03-10 14:39:41 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-15 12:14:42 +0000 |
commit | 3467fd99fd27cf36ff35a79c746f313e238882a7 (patch) | |
tree | e2fe240c2f174764c2583204abf4af6be1039a47 /src/gui | |
parent | 49c58510549370d22a1c0f9c9243bdff5c023d80 (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.mm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 8f6ca5c869..ac6931fee4 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -1742,8 +1742,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. |