Merge "rhi: metal: Stop using BufferOp for no good reason"
This commit is contained in:
commit
aa9b4bd01e
@ -227,7 +227,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
|
||||
@ -1746,8 +1750,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)
|
||||
bufD->d->pendingUpdates[i].append(u);
|
||||
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.offset, u.data });
|
||||
}
|
||||
} 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.
|
||||
@ -1755,8 +1762,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);
|
||||
@ -1916,8 +1922,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user