From 2b2df724e14f5696bf751a53f5898e5be9bbac0c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 May 2018 15:45:06 +0200 Subject: Fix BlitFramebuffer on GLES Task-number: QTBUG-68395 Change-Id: I216f32bd22d12c6fa6f2efd09765ad95754326b4 Reviewed-by: Andy Nichols --- .../renderers/opengl/graphicshelpers/graphicscontext.cpp | 5 +++++ .../renderers/opengl/graphicshelpers/graphicscontext_p.h | 1 + .../renderers/opengl/graphicshelpers/submissioncontext.cpp | 12 ++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/render/renderers/opengl/graphicshelpers') diff --git a/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp b/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp index c2ec3db59..af1fb5675 100644 --- a/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp +++ b/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp @@ -705,6 +705,11 @@ void GraphicsContext::drawBuffer(GLenum mode) m_glHelper->drawBuffer(mode); } +void GraphicsContext::drawBuffers(GLsizei n, const int *bufs) +{ + m_glHelper->drawBuffers(n, bufs); +} + void GraphicsContext::applyUniform(const ShaderUniform &description, const UniformValue &v) { const UniformType type = m_glHelper->uniformTypeFromGLType(description.m_type); diff --git a/src/render/renderers/opengl/graphicshelpers/graphicscontext_p.h b/src/render/renderers/opengl/graphicshelpers/graphicscontext_p.h index 82db57433..7bc79996c 100644 --- a/src/render/renderers/opengl/graphicshelpers/graphicscontext_p.h +++ b/src/render/renderers/opengl/graphicshelpers/graphicscontext_p.h @@ -158,6 +158,7 @@ public: void pointSize(bool programmable, GLfloat value); void readBuffer(GLenum mode); void drawBuffer(GLenum mode); + void drawBuffers(GLsizei n, const int *bufs); void setMSAAEnabled(bool enabled); void setAlphaCoverageEnabled(bool enabled); void setClipPlane(int clipPlane, const QVector3D &normal, float distance); diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp index ecaa12d8b..20aca81bc 100644 --- a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -1618,8 +1618,12 @@ void SubmissionContext::blitFramebuffer(Qt3DCore::QNodeId inputRenderTargetId, if (!inputBufferIsDefault) readBuffer(GL_COLOR_ATTACHMENT0 + inputAttachmentPoint); - if (!outputBufferIsDefault) - drawBuffer(GL_COLOR_ATTACHMENT0 + outputAttachmentPoint); + if (!outputBufferIsDefault) { + // Note that we use glDrawBuffers, not glDrawBuffer. The + // latter is not available with GLES. + const int buf = outputAttachmentPoint; + drawBuffers(1, &buf); + } // Blit framebuffer const GLenum mode = interpolationMethod ? GL_NEAREST : GL_LINEAR; @@ -1629,6 +1633,10 @@ void SubmissionContext::blitFramebuffer(Qt3DCore::QNodeId inputRenderTargetId, // Reset draw buffer bindFramebuffer(lastDrawFboId, GraphicsHelperInterface::FBOReadAndDraw); + if (outputAttachmentPoint != QRenderTargetOutput::Color0) { + const int buf = QRenderTargetOutput::Color0; + drawBuffers(1, &buf); + } } } // namespace Render -- cgit v1.2.3