diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-03-10 14:54:17 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-15 08:57:25 +0000 |
commit | c8991d2986c37c04d1359c3c19d1600c1d408fa3 (patch) | |
tree | 0e2980f4a9ece8432cfef28c63afe2f254d7e6c5 /src | |
parent | 90e71575fbe62162dec4efe659bd81e45e6c1628 (diff) |
rhi: metal: Stop using BufferOp for no good reason
Do what the Vulkan backend does, and just take the offset
and the QRhiBufferData. There is no reason to store a full
QRhiResourceUpdateBatchPrivate::BufferOp struct within the
backend.
Change-Id: I67528029de40320b3e4f031346d40dfc0bb9ab52
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit adf6ba7eaeba97fb2561394e52ee265d94e1c6e0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 65f46f7f68..71f6eabb4c 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -224,7 +224,11 @@ struct QMetalBufferData bool managed; bool slotted; id<MTLBuffer> buf[QMTL_FRAMES_IN_FLIGHT]; - QVarLengthArray<QRhiResourceUpdateBatchPrivate::BufferOp, 16> pendingUpdates[QMTL_FRAMES_IN_FLIGHT]; + struct BufferUpdate { + int offset; + QRhiBufferData data; + }; + QVarLengthArray<BufferUpdate, 16> pendingUpdates[QMTL_FRAMES_IN_FLIGHT]; }; struct QMetalRenderBufferData @@ -1702,7 +1706,7 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate 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.offset, u.data }); } } else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::StaticUpload) { // Due to the Metal API the handling of static and dynamic buffers is @@ -1711,8 +1715,7 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic); Q_ASSERT(u.offset + u.data.size() <= bufD->m_size); for (int i = 0, ie = bufD->d->slotted ? QMTL_FRAMES_IN_FLIGHT : 1; i != ie; ++i) - bufD->d->pendingUpdates[i].append( - QRhiResourceUpdateBatchPrivate::BufferOp::dynamicUpdate(u.buf, u.offset, u.data.size(), u.data.constData())); + bufD->d->pendingUpdates[i].append({ u.offset, u.data }); } else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::Read) { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf); executeBufferHostWritesForCurrentFrame(bufD); @@ -1872,8 +1875,7 @@ void QRhiMetal::executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot) void *p = [bufD->d->buf[slot] contents]; int changeBegin = -1; int changeEnd = -1; - for (const QRhiResourceUpdateBatchPrivate::BufferOp &u : qAsConst(bufD->d->pendingUpdates[slot])) { - Q_ASSERT(bufD == QRHI_RES(QMetalBuffer, u.buf)); + for (const QMetalBufferData::BufferUpdate &u : qAsConst(bufD->d->pendingUpdates[slot])) { memcpy(static_cast<char *>(p) + u.offset, u.data.constData(), size_t(u.data.size())); if (changeBegin == -1 || u.offset < changeBegin) changeBegin = u.offset; |