summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-05-13 11:35:12 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-05-25 13:04:28 +0200
commit9e19e547272df3c332332954481a6c34471884cd (patch)
treefba69b4dc82833b26e5b36ac0dadc6144f3bb859
parent59345bc1a733ee035b342feecadc923e062a850c (diff)
downloadqt3d-9e19e547272df3c332332954481a6c34471884cd.tar.gz
Release rendertargets on destruction
We were only releasing them at runtime if they changed, but we should also clean them up before we are destroyed. Change-Id: Ibc3f37fba92e8be8381fd869af7f5747da87038a Task-number: QTBUG-84204 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit cfd8c4d06bc81028b055e6c3343d0d4b50793219) (cherry picked from commit b297d6bfdfd2116ccbed1e552fc0cbe68ea274f3)
-rw-r--r--src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp7
-rw-r--r--src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h1
-rw-r--r--src/plugins/renderers/opengl/renderer/renderer.cpp2
3 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
index bbbeaa307..a8d6a9749 100644
--- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
@@ -568,6 +568,13 @@ GLuint SubmissionContext::updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeI
return fboId;
}
+void SubmissionContext::releaseRenderTargets()
+{
+ const auto keys = m_renderTargets.keys();
+ for (Qt3DCore::QNodeId renderTargetId : keys)
+ releaseRenderTarget(renderTargetId);
+}
+
QSize SubmissionContext::renderTargetSize(const QSize &surfaceSize) const
{
QSize renderTargetSize;
diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h
index 4c895013c..2643cd92d 100644
--- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h
+++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext_p.h
@@ -114,6 +114,7 @@ public:
GLuint activeFBO() const { return m_activeFBO; }
void activateRenderTarget(const Qt3DCore::QNodeId id, const AttachmentPack &attachments, GLuint defaultFboId);
void releaseRenderTarget(const Qt3DCore::QNodeId id);
+ void releaseRenderTargets();
QSize renderTargetSize(const QSize &surfaceSize) const;
QImage readFramebuffer(const QRect &rect);
void blitFramebuffer(Qt3DCore::QNodeId outputRenderTargetId, Qt3DCore::QNodeId inputRenderTargetId,
diff --git a/src/plugins/renderers/opengl/renderer/renderer.cpp b/src/plugins/renderers/opengl/renderer/renderer.cpp
index fabc241f3..f80fdeae1 100644
--- a/src/plugins/renderers/opengl/renderer/renderer.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderer.cpp
@@ -622,6 +622,8 @@ void Renderer::releaseGraphicsResources()
vao->destroy();
}
+ m_submissionContext->releaseRenderTargets();
+
m_frameProfiler.reset();
context->doneCurrent();
} else {