summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2023-02-24 09:07:57 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-24 11:16:13 +0000
commitf4e8dd2e191f062fa527dd5e6bdd7611f1e68d02 (patch)
tree13a6773874ab8b725abd424e203a3095bf6f8f0c
parent0c13d600cc45f58fe395b0cb7f1ae127d553872b (diff)
downloadqt3d-6.4.tar.gz
OpenGL SubmissionContext: reset m_renderTargetFormat for default FBO6.4
We rely on m_renderTargetFormat when doing render capture to know in whick internal format the currently bound FBO is. m_renderTargetFormat is reset once per surface change based on the QSurfaceFormat. However, when using custom RenderTargets, it gets overwritten in the call to SubmissionContext::activateRenderTarget which happens for each RenderView. If we switch back to the default FBO in a RenderView that follows one using a custom RenderTarget, both using the same surface, we failed to reset the m_renderTargetFormat and it would mistakenly remain to the value set for the custom RenderTarget. If a RenderCapture were to happen at that stage, this would lead to crashes as we would compute the capture buffer assuming a format that doesn't match that of the current FBO. Change-Id: I5c722f20857b23b5696617065c8f50406e10aea9 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit 77823b3b678a586f90d1211fa27dddfbf1fe4e71) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
index 2b4da1ec7..06557debc 100644
--- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
@@ -471,6 +471,8 @@ void SubmissionContext::endDrawing(bool swapBuffers)
void SubmissionContext::activateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId, const AttachmentPack &attachments, GLuint defaultFboId)
{
GLuint fboId = defaultFboId; // Default FBO
+ resolveRenderTargetFormat(); // Reset m_renderTargetFormat based on the default FBO
+
if (renderTargetNodeId) {
// New RenderTarget
if (!m_renderTargets.contains(renderTargetNodeId)) {
@@ -481,9 +483,10 @@ void SubmissionContext::activateRenderTarget(Qt3DCore::QNodeId renderTargetNodeI
fboId = createRenderTarget(renderTargetNodeId, attachments);
}
} else {
- fboId = updateRenderTarget(renderTargetNodeId, attachments, true);
+ fboId = updateRenderTarget(renderTargetNodeId, attachments, true); // Overwrites m_renderTargetFormat based on custom FBO
}
}
+
m_activeFBO = fboId;
m_activeFBONodeId = renderTargetNodeId;
m_glHelper->bindFrameBufferObject(m_activeFBO, GraphicsHelperInterface::FBODraw);
@@ -613,6 +616,7 @@ QImage SubmissionContext::readFramebuffer(const QRect &rect)
QImage::Format imageFormat;
uint stride;
+ // m_renderTargetFormat is set when the current RV FBO is set in activateRenderTarget
/* format value should match GL internalFormat */
GLenum internalFormat = m_renderTargetFormat;