summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2016-08-31 11:56:30 +0300
committerAntti Määttä <antti.maatta@qt.io>2016-09-01 05:40:15 +0000
commitce1db34bf273c397bb7b4be182f274547c35ea3e (patch)
treea11adfc1cc24cd6ccbe0a2b6c62ff5c3a4a09f20
parent320bdb45cf3a76e4a7c2b2ac79481e65280bb27a (diff)
Reset bound fbo at the end of the rendering
The last bound fbo must be reset at the end of the rendering if the bound fbo was changed due to render-to-texture. Otherwise offscreen rendering(in scene3d case) might have wrong bound fbo. Also in threaded mode, if the last renderview was rtt, the current fbo remains bound, and the next frame doesn't render to the surface as expected. Change-Id: I842040766aa6010740b008a36f7f9f2c935b0561 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/render/backend/renderer.cpp6
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp5
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index c91eff86e..49f2f4434 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -908,6 +908,12 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
frameElapsed = timer.elapsed();
}
+ // Bind lastBoundFBOId back. Needed also in threaded mode.
+ // lastBoundFBOId != m_graphicsContext->activeFBO() when the last FrameGraph leaf node/renderView
+ // contains RenderTargetSelector/RenderTarget
+ if (lastBoundFBOId != m_graphicsContext->activeFBO())
+ m_graphicsContext->bindFramebuffer(lastBoundFBOId);
+
// Reset state and call doneCurrent if the surface
// is valid and was actually activated
if (surface && m_graphicsContext->hasValidGLHelper()) {
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 2fc36c306..3a67db729 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -843,6 +843,11 @@ void GraphicsContext::alphaTest(GLenum mode1, GLenum mode2)
m_glHelper->alphaTest(mode1, mode2);
}
+void GraphicsContext::bindFramebuffer(GLuint fbo)
+{
+ m_glHelper->bindFrameBufferObject(fbo);
+}
+
void GraphicsContext::depthTest(GLenum mode)
{
m_glHelper->depthTest(mode);
diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h
index 1aa4c3e5a..cc63a03b6 100644
--- a/src/render/graphicshelpers/graphicscontext_p.h
+++ b/src/render/graphicshelpers/graphicscontext_p.h
@@ -180,6 +180,7 @@ public:
// Wrapper methods
void alphaTest(GLenum mode1, GLenum mode2);
+ void bindFramebuffer(GLuint fbo);
void bindBufferBase(GLenum target, GLuint bindingIndex, GLuint buffer);
void bindFragOutputs(GLuint shader, const QHash<QString, int> &outputs);
void bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding);