From 230be3c4d1e53d7024064b926010131c6a83762f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 Sep 2020 19:03:19 +0200 Subject: rhi: Report an "optimal capacity" from res.update batches Change-Id: If47eddf3fe7d365c80b0a15712ef155a6898d904 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhi.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/gui/rhi/qrhi.cpp') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index f61fa6df59..a74765758c 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4732,6 +4732,24 @@ void QRhiResourceUpdateBatch::merge(QRhiResourceUpdateBatch *other) d->merge(other->d); } +/*! + \return true until the number of buffer and texture operations enqueued + onto this batch is below a reasonable limit. + + The return value is false when the number of buffer and/or texture + operations added to this batch have reached, or are about to reach, a + certain limit. The batch is fully functional afterwards as well, but may + need to allocate additional memory. Therefore, a renderer that collects + lots of buffer and texture updates in a single batch when preparing a frame + may want to consider \l{QRhiCommandBuffer::resourceUpdate()}{submitting the + batch} and \l{QRhi::nextResourceUpdateBatch()}{starting a new one} when + this function returns false. + */ +bool QRhiResourceUpdateBatch::hasOptimalCapacity() const +{ + return d->hasOptimalCapacity(); +} + /*! Enqueues updating a region of a QRhiBuffer \a buf created with the type QRhiBuffer::Dynamic. @@ -4997,6 +5015,12 @@ void QRhiResourceUpdateBatchPrivate::merge(QRhiResourceUpdateBatchPrivate *other textureOps.append(op); } +bool QRhiResourceUpdateBatchPrivate::hasOptimalCapacity() const +{ + return bufferOps.count() < BUFFER_OPS_STATIC_ALLOC - 16 + && textureOps.count() < TEXTURE_OPS_STATIC_ALLOC - 16; +} + /*! Sometimes committing resource updates is necessary without starting a render pass. Not often needed, updates should typically be passed to -- cgit v1.2.3