diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2020-06-16 09:48:02 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-06-16 22:35:21 +0000 |
commit | a3453480c4247028c38f75c0775d9ff4f21ce1bb (patch) | |
tree | e0983a012c15382c7e398c18c3330d936c52a0b4 /src/plugins | |
parent | 5600231953e7e68965d66617509c0513bef7a2ca (diff) |
Blit: Fix attachment binding point
We assumed we would only have 15 color attachments at most. In cases you
have more or less, if request Depth or Stencil binding points, we would
have used an invalid value.
Change-Id: I2ecfefbff043fc80efff4b5ad777f3d365f424c2
Reviewed-by: Mike Krus <mike.krus@kdab.com>
(cherry picked from commit 8a9c37b3e7d57e1275706be035f588ddd27f8c53)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp index abfb7922a..cdd1cfeef 100644 --- a/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -356,6 +356,23 @@ void applyStateHelper<LineWidth>(const LineWidth *state, SubmissionContext *gc) gc->openGLContext()->functions()->glLineWidth(std::get<0>(values)); } +GLint glAttachmentPoint(const QRenderTargetOutput::AttachmentPoint &attachmentPoint) +{ + if (attachmentPoint <= QRenderTargetOutput::Color15) + return GL_COLOR_ATTACHMENT0 + attachmentPoint; + + switch (attachmentPoint) { + case QRenderTargetOutput::Depth: + case QRenderTargetOutput::DepthStencil: + return GL_DEPTH_ATTACHMENT; + case QRenderTargetOutput::Stencil: + return GL_STENCIL_ATTACHMENT; + default: + Q_UNREACHABLE(); + return GL_NONE; + } +} + } // anonymous @@ -1572,12 +1589,12 @@ void SubmissionContext::blitFramebuffer(Qt3DCore::QNodeId inputRenderTargetId, //Bind texture if (!inputBufferIsDefault) - readBuffer(GL_COLOR_ATTACHMENT0 + inputAttachmentPoint); + readBuffer(glAttachmentPoint(inputAttachmentPoint)); if (!outputBufferIsDefault) { // Note that we use glDrawBuffers, not glDrawBuffer. The // latter is not available with GLES. - const int buf = outputAttachmentPoint; + const int buf = glAttachmentPoint(outputAttachmentPoint); drawBuffers(1, &buf); } |