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 <andy.nichols@qt.io>
bb10
Laszlo Agocs 2020-09-22 16:47:19 +02:00
parent fe3a1617af
commit 5fcd9a3ebf
2 changed files with 13 additions and 1 deletions

View File

@ -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;
};

View File

@ -227,6 +227,7 @@ private:
QRhiProfiler profiler;
QVarLengthArray<QRhiResourceUpdateBatch *, 4> resUpdPool;
QBitArray resUpdPoolMap;
int lastResUpdIdx = -1;
QSet<QRhiResource *> resources;
QSet<QRhiResource *> pendingDeleteResources;
QVarLengthArray<QRhi::CleanupCallback, 4> cleanupCallbacks;