From 5fcd9a3ebf83bc0700f32819d620c320b3844fd9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 Sep 2020 16:47:19 +0200 Subject: rhi: Do not just pick the first free res.upd. batch all the time Rather, utilize all the available ones in the pool, picking the next available batch after the one we picked previously (with wrapping over as necessary). Change-Id: I5f26e127a406c2dd07d155712429c72ad4f0f0f1 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhi.cpp | 13 ++++++++++++- src/gui/rhi/qrhi_p_p.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 6cc2b48922..f61fa6df59 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -4938,13 +4938,24 @@ void QRhiResourceUpdateBatch::generateMips(QRhiTexture *tex, int layer) QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch() { auto nextFreeBatch = [this]() -> QRhiResourceUpdateBatch * { - for (int i = 0, ie = d->resUpdPoolMap.count(); i != ie; ++i) { + auto isFree = [this](int i) -> QRhiResourceUpdateBatch * { if (!d->resUpdPoolMap.testBit(i)) { d->resUpdPoolMap.setBit(i); QRhiResourceUpdateBatch *u = d->resUpdPool[i]; QRhiResourceUpdateBatchPrivate::get(u)->poolIndex = i; + d->lastResUpdIdx = i; return u; } + return nullptr; + }; + const int poolSize = d->resUpdPoolMap.count(); + for (int i = d->lastResUpdIdx + 1; i < poolSize; ++i) { + if (QRhiResourceUpdateBatch *u = isFree(i)) + return u; + } + for (int i = 0; i <= d->lastResUpdIdx; ++i) { + if (QRhiResourceUpdateBatch *u = isFree(i)) + return u; } return nullptr; }; diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 1dbb2b9ab9..ef27be6d7d 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -227,6 +227,7 @@ private: QRhiProfiler profiler; QVarLengthArray resUpdPool; QBitArray resUpdPoolMap; + int lastResUpdIdx = -1; QSet resources; QSet pendingDeleteResources; QVarLengthArray cleanupCallbacks; -- cgit v1.2.3