summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-09-28 13:19:52 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-09-29 21:24:38 +0200
commit848ed9644c5ddd4b761f7b5184658b6131027e7a (patch)
tree51d415a47f27ef618524b5def8da161ef42d7a44 /src/gui/rhi
parent868866cecd57e671d1b2826b59d3fa1c872b214c (diff)
rhi: Drop QBitArray usage
Change-Id: I4ae92e6c8c91111a4593c51ee05443b3bc806c35 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhi.cpp19
-rw-r--r--src/gui/rhi/qrhi_p_p.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 21542930ac..151e1268f6 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -4998,13 +4998,17 @@ void QRhiResourceUpdateBatch::generateMips(QRhiTexture *tex)
\note Can be called outside beginFrame() - endFrame() as well since a batch
instance just collects data on its own, it does not perform any operations.
+
+ \warning The maximum number of batches is 64. When this limit is reached,
+ the function will return null until a batch is returned to the pool.
*/
QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch()
{
auto nextFreeBatch = [this]() -> QRhiResourceUpdateBatch * {
auto isFree = [this](int i) -> QRhiResourceUpdateBatch * {
- if (!d->resUpdPoolMap.testBit(i)) {
- d->resUpdPoolMap.setBit(i);
+ const quint64 mask = 1ULL << quint64(i);
+ if (!(d->resUpdPoolMap & mask)) {
+ d->resUpdPoolMap |= mask;
QRhiResourceUpdateBatch *u = d->resUpdPool[i];
QRhiResourceUpdateBatchPrivate::get(u)->poolIndex = i;
d->lastResUpdIdx = i;
@@ -5012,7 +5016,7 @@ QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch()
}
return nullptr;
};
- const int poolSize = d->resUpdPoolMap.count();
+ const int poolSize = d->resUpdPool.size();
for (int i = d->lastResUpdIdx + 1; i < poolSize; ++i) {
if (QRhiResourceUpdateBatch *u = isFree(i))
return u;
@@ -5027,13 +5031,13 @@ QRhiResourceUpdateBatch *QRhi::nextResourceUpdateBatch()
QRhiResourceUpdateBatch *u = nextFreeBatch();
if (!u) {
const int oldSize = d->resUpdPool.count();
- const int newSize = oldSize + 4;
+ const int newSize = oldSize + qMin(4, qMax(0, 64 - oldSize));
d->resUpdPool.resize(newSize);
- d->resUpdPoolMap.resize(newSize);
for (int i = oldSize; i < newSize; ++i)
d->resUpdPool[i] = new QRhiResourceUpdateBatch(d);
u = nextFreeBatch();
- Q_ASSERT(u);
+ if (!u)
+ qWarning("Resource update batch pool exhausted (max is 64)");
}
return u;
@@ -5046,7 +5050,8 @@ void QRhiResourceUpdateBatchPrivate::free()
activeBufferOpCount = 0;
activeTextureOpCount = 0;
- rhi->resUpdPoolMap.clearBit(poolIndex);
+ const quint64 mask = 1ULL << quint64(poolIndex);
+ rhi->resUpdPoolMap &= ~mask;
poolIndex = -1;
}
diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h
index 51b3645b9d..3b68b5d078 100644
--- a/src/gui/rhi/qrhi_p_p.h
+++ b/src/gui/rhi/qrhi_p_p.h
@@ -227,7 +227,7 @@ private:
QThread *implThread;
QRhiProfiler profiler;
QVarLengthArray<QRhiResourceUpdateBatch *, 4> resUpdPool;
- QBitArray resUpdPoolMap;
+ quint64 resUpdPoolMap = 0;
int lastResUpdIdx = -1;
QSet<QRhiResource *> resources;
QSet<QRhiResource *> pendingDeleteResources;