summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2023-02-24 09:07:57 +0100
committerPaul Lemire <paul.lemire@kdab.com>2023-02-24 10:12:20 +0100
commit77823b3b678a586f90d1211fa27dddfbf1fe4e71 (patch)
treeaa790c075c295564e1979fec386d6ac2951ea392
parentd1e1ccc8f92b12779a1adab853202bc48f8a1cad (diff)
downloadqt3d-77823b3b678a586f90d1211fa27dddfbf1fe4e71.tar.gz
OpenGL SubmissionContext: reset m_renderTargetFormat for default FBO
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. Pick-to: 6.5 6.4 Change-Id: I5c722f20857b23b5696617065c8f50406e10aea9 Reviewed-by: Mike Krus <mike.krus@kdab.com>
-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 ca6e0ce49..814667c10 100644
--- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
+++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
@@ -466,6 +466,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)) {
@@ -476,9 +478,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);
@@ -608,6 +611,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;