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>
This commit is contained in:
parent
49c5851054
commit
3467fd99fd
@ -1742,8 +1742,11 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
|
|||||||
if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) {
|
if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) {
|
||||||
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf);
|
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf);
|
||||||
Q_ASSERT(bufD->m_type == QRhiBuffer::Dynamic);
|
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);
|
bufD->d->pendingUpdates[i].append(u);
|
||||||
|
}
|
||||||
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) {
|
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) {
|
||||||
// Due to the Metal API the handling of static and dynamic buffers is
|
// Due to the Metal API the handling of static and dynamic buffers is
|
||||||
// basically the same. So go through the same pendingUpdates machinery.
|
// basically the same. So go through the same pendingUpdates machinery.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user