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 managed;
|
||||||
bool slotted;
|
bool slotted;
|
||||||
id<MTLBuffer> buf[QMTL_FRAMES_IN_FLIGHT];
|
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
|
struct QMetalRenderBufferData
|
||||||
@ -1746,8 +1750,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) {
|
||||||
bufD->d->pendingUpdates[i].append(u);
|
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) {
|
} 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.
|
||||||
@ -1755,8 +1762,7 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
|
|||||||
Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic);
|
Q_ASSERT(bufD->m_type != QRhiBuffer::Dynamic);
|
||||||
Q_ASSERT(u.offset + u.data.size() <= bufD->m_size);
|
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)
|
for (int i = 0, ie = bufD->d->slotted ? QMTL_FRAMES_IN_FLIGHT : 1; i != ie; ++i)
|
||||||
bufD->d->pendingUpdates[i].append(
|
bufD->d->pendingUpdates[i].append({ u.offset, u.data });
|
||||||
QRhiResourceUpdateBatchPrivate::BufferOp::dynamicUpdate(u.buf, u.offset, u.data.size(), u.data.constData()));
|
|
||||||
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::Read) {
|
} else if (u.type == QRhiResourceUpdateBatchPrivate::BufferOp::Read) {
|
||||||
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf);
|
QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, u.buf);
|
||||||
executeBufferHostWritesForCurrentFrame(bufD);
|
executeBufferHostWritesForCurrentFrame(bufD);
|
||||||
@ -1916,8 +1922,7 @@ void QRhiMetal::executeBufferHostWritesForSlot(QMetalBuffer *bufD, int slot)
|
|||||||
void *p = [bufD->d->buf[slot] contents];
|
void *p = [bufD->d->buf[slot] contents];
|
||||||
int changeBegin = -1;
|
int changeBegin = -1;
|
||||||
int changeEnd = -1;
|
int changeEnd = -1;
|
||||||
for (const QRhiResourceUpdateBatchPrivate::BufferOp &u : qAsConst(bufD->d->pendingUpdates[slot])) {
|
for (const QMetalBufferData::BufferUpdate &u : qAsConst(bufD->d->pendingUpdates[slot])) {
|
||||||
Q_ASSERT(bufD == QRHI_RES(QMetalBuffer, u.buf));
|
|
||||||
memcpy(static_cast<char *>(p) + u.offset, u.data.constData(), size_t(u.data.size()));
|
memcpy(static_cast<char *>(p) + u.offset, u.data.constData(), size_t(u.data.size()));
|
||||||
if (changeBegin == -1 || u.offset < changeBegin)
|
if (changeBegin == -1 || u.offset < changeBegin)
|
||||||
changeBegin = u.offset;
|
changeBegin = u.offset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user