summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurélien Brooke <aurelien@bahiasoft.fr>2022-12-18 15:58:08 +0100
committerAurélien Brooke <aurelien@bahiasoft.fr>2022-12-19 08:50:22 +0100
commit6b6465032f103a084e416cbddf03f8e83191aea2 (patch)
tree7229b42c75d72e757d4aef55f9bcc90691d6c22b /src
parentb15f62e3234a85d7220fc1533b6a224522dd4735 (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). Pick-to: 6.4 6.5 Change-Id: Ic3fb145b11a8e615c83745f560f019e6c4ee37f7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-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 c0afedfdb..0d3ef1e1b 100644
--- a/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/rhi/graphicshelpers/submissioncontext.cpp
@@ -804,6 +804,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 66b40c21c..45485a6c7 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;
}