summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurélien Brooke <aurelien@bahiasoft.fr>2022-12-18 15:58:08 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-12-19 09:29:36 +0000
commitb1fea9fb29b42ab30bc7a474d439827a4a97f7d6 (patch)
treedfc8f3fa62a6c779f8d693df6e95eac2fdb6577f
parent11d3abeea5cf710db17f45514dfc59e41aad00b9 (diff)
RHI: fix the leak of QRhiResourceUpdateBatch
There are 2 ways to dispose of a QRhiResourceUpdateBatch obtained with QRhi::nextResourceUpdateBatch(): 1) Either give it to beginPass/endPass/beginComputePass/endComputePass so it is sent to the RHI backend and then automatically released; 2) or call QRhiResourceUpdateBatch::release() if the resource update is not used for any pass. The Qt3D RHI renderer was never disposing of the QRhiResourceUpdateBatch, and could end up exhausting all the 64 batches available in the RHI: "Resource update batch pool exhausted (max is 64)", in addition to consuming a lot of RAM if the buffers or textures are large. To fix this, ensure the QRhiResourceUpdateBatch'es we allocate are always released: when requesting a new one, send the previous one to endPass/endComputePass (1), and when destroying the SubmissionContext, release the one we will not use (2). Change-Id: Ic3fb145b11a8e615c83745f560f019e6c4ee37f7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> (cherry picked from commit 6b6465032f103a084e416cbddf03f8e83191aea2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp5
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
index 1ae2d081e..9b03adf90 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
@@ -802,6 +802,11 @@ void SubmissionContext::releaseResources()
m_renderBufferHash.clear();
RHI_UNIMPLEMENTED;
+ if (m_currentUpdates) {
+ m_currentUpdates->release();
+ m_currentUpdates = nullptr;
+ }
+
// Free RHI resources
{
qCDebug(Backend) << Q_FUNC_INFO;
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index 5e46c42bc..c190bf474 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -2715,7 +2715,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
if (rv->isCompute()) {
// If we were running draw calls we stop the draw pass
if (inDraw) {
- cb->endPass();
+ cb->endPass(m_submissionContext->m_currentUpdates);
m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inDraw = false;
}
@@ -2734,7 +2734,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
} else {
// Same logic than above but reversed
if (inCompute) {
- cb->endComputePass();
+ cb->endComputePass(m_submissionContext->m_currentUpdates);
m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch();
inCompute = false;
}