Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65080

BlitFramebuffer node unusable when the input/output RT is not actively used elsewhere in the framegraph

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.10.1
    • 5.10, 5.11
    • Qt3D
    • None
    • 0331dbd1ed89e3aac6c7a1371db5c9b1615f8307

    Description

      One common usage of glBlitFramebuffer is to copy regions between textures. In plain GL code this is often done by creating more or less temporary framebuffer objects that have the textures in question as their color attachment.

      Trying to reproduce the same with the BlitFramebuffer framegraph node fails since the implementation is not prepared for the case when the input and/or output QRenderTarget has no FBO associated with it:

      void GraphicsContext::blitFramebuffer(Qt3DCore::QNodeId inputRenderTarget,
                                            Qt3DCore::QNodeId outputRenderTarget,
                                            QRect inputRect, QRect outputRect,
                                            uint defaultFboId,
                                            QRenderTargetOutput::AttachmentPoint inputAttachmentPoint,
                                            QRenderTargetOutput::AttachmentPoint outputAttachmentPoint,
                                            QBlitFramebuffer::InterpolationMethod interpolationMethod)
      {
          //Find the context side name for the render targets
          const GLuint inputFboId = m_renderTargets[inputRenderTarget];
          GLuint outputFboId = defaultFboId;
          bool outputBufferIsDefault = true;
          if (!outputRenderTarget.isNull() && m_renderTargets.contains(outputRenderTarget)) {
              outputFboId = m_renderTargets[outputRenderTarget];
              outputBufferIsDefault = false;
          }
      

      The simple m_renderTargets access and check are wrong. Consider application code like this:

                      Qt3DRender::QBlitFramebuffer *bgBlit = new Qt3DRender::QBlitFramebuffer(...);
                      Qt3DRender::QRenderTarget *tempTexRt = new Qt3DRender::QRenderTarget(...);
                      Qt3DRender::QRenderTargetOutput *tempTexOutput = new Qt3DRender::QRenderTargetOutput;
      tempTexOutput->setAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0);
                      tempTexOutput->setTexture(data->advBlend.tempTexture);
                      tempTexRt->addOutput(tempTexOutput);
      
                      bgBlit->setSource(screenTexRt);
                      bgBlit->setDestination(tempTexRt);
                      bgBlit->setSourceRect(...);
                      bgBlit->setDestinationRect(...);
                      new Qt3DRender::QNoDraw(bgBlit);
      

      Here the destination QRenderTarget (tempTexRt) is not something that is ever "activated" from the GraphicsContext's point of view. Yet the blitframebuffer is expected to work. Right now it will silently fall back to FBO 0 as the destination...

      Same applies to the source. If screenTexRt is something another section of the framegraph renders to, then it works fine. If not then bad things happen.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              lagocs Laszlo Agocs
              lagocs Laszlo Agocs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes