diff options
author | Aurélien Brooke <aurelien@bahiasoft.fr> | 2024-01-13 15:13:25 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-01-13 17:17:28 +0000 |
commit | 46cebd024cd73fe22948a1ac5f98e28d7459f2aa (patch) | |
tree | 06504c6641309b5362318dce63e847a862d76dd1 | |
parent | 9cc5257312ca181f719b3331928a26733c8e9b4a (diff) |
RHI renderer: fix crash when executing a draw RV after a compute RV
RHI resource update batches are released when we pass them to
beginPass() or endPass(). We must then either clear the m_currentUpdates
pointer, or assign it to a new batch.
The later was done after all endPass(). But we forgot to clear the
m_currentUpdates pointer after beginPass(), which resulted in a crash,
since we then sent the same -released- batch pointer to the following
endPass().
This crash did not manifest before
6b6465032f103a084e416cbddf03f8e83191aea2 because then all batches were
leaked (never released).
Fixes: QTBUG-119657
Change-Id: Ic63a96fc58714099b0a4e65e495ae0a720a3823f
Reviewed-by: Mike Krus <mike.krus@kdab.com>
(cherry picked from commit 708b851eb5afcb5ae4019777b56787cce4910c8b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/renderers/rhi/renderer/renderer.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp index c3fb610f5..824e741a5 100644 --- a/src/plugins/renderers/rhi/renderer/renderer.cpp +++ b/src/plugins/renderers/rhi/renderer/renderer.cpp @@ -2759,6 +2759,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo) if (supportsCompute) { if (!inCompute) { cb->beginComputePass(m_submissionContext->m_currentUpdates); + m_submissionContext->m_currentUpdates = nullptr; inCompute = true; } executeComputeRenderView(rv); @@ -2780,6 +2781,7 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo) continue; } cb->beginPass(rhiRenderTarget, clearColor, clearDepthStencil, m_submissionContext->m_currentUpdates); + m_submissionContext->m_currentUpdates = nullptr; inDraw = true; } @@ -2845,7 +2847,13 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo) else if (inCompute) cb->endComputePass(); - m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch(); + if (!renderViews.empty()) { + Q_ASSERT(m_submissionContext->m_currentUpdates == nullptr); // ensures that we are not leaking a batch + m_submissionContext->m_currentUpdates = m_submissionContext->rhi()->nextResourceUpdateBatch(); + } + else { + // Keep the m_submissionContext->m_currentUpdates + } return allCommandsIssued; } |