diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-09-22 16:47:19 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-09-23 16:59:06 +0200 |
commit | 5fcd9a3ebf83bc0700f32819d620c320b3844fd9 (patch) | |
tree | 43c9cb30cff2ff7f3c04f85ddb5c3cdc482d3350 /src/gui/rhi/qrhi.cpp | |
parent | fe3a1617afd71e5ea2fced740a69b3d27958e2d7 (diff) |
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>
Diffstat (limited to 'src/gui/rhi/qrhi.cpp')
-rw-r--r-- | src/gui/rhi/qrhi.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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; }; |