rhi: vk: Reduce memcopies with full dynamic buffer updates

Change-Id: Ifc754a639fcdb45a1b1b8721393de9356504342f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2020-10-03 21:57:24 +02:00
parent f84ba3108c
commit 20eb40bce9

View File

@ -2945,8 +2945,11 @@ void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdat
if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) { if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::DynamicUpdate) {
QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf); QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf);
Q_ASSERT(bufD->m_type == QRhiBuffer::Dynamic); 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 }); bufD->pendingDynamicUpdates[i].append({ u.offset, u.data });
}
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) { } else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) {
QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf); QVkBuffer *bufD = QRHI_RES(QVkBuffer, u.buf);
Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic); Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic);