From 20eb40bce92c3e5460cd2540547f3c404fe6dccc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 3 Oct 2020 21:57:24 +0200 Subject: [PATCH] rhi: vk: Reduce memcopies with full dynamic buffer updates Change-Id: Ifc754a639fcdb45a1b1b8721393de9356504342f Reviewed-by: Andy Nichols --- src/gui/rhi/qrhivulkan.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index bb4b94c6b3..4e23f1622c 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2945,8 +2945,11 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) { QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf); Q_ASSERT(bufD->m_type == QRhiBuffer::Dynamic); - for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) + for (int i = 0; i < QVK_FRAMES_IN_FLIGHT; ++i) { + if (u.offset == 0 && u.data.size() == bufD->m_size) + bufD->pendingDynamicUpdates[i].clear(); bufD->pendingDynamicUpdates[i].append({ u.offset, u.data }); + } } else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) { QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf); Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic);