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

QRenderTargetOutput cannot change its target texture when the new texture has the same size



    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.9, 5.10, 5.11
    • Fix Version/s: None
    • Component/s: Qt3D
    • Labels:


      Have a QRenderTargetOutput, set a texture. Then later on, e.g. in a frame action, change it to another texture. The second texture should have the same size as the first (which is a pretty common case in techniques where one plays ping pong with two textures)

      This has no effect: in practice the output gets unchanged.

      Looking at GraphicsContext::activateRenderTarget the code looks suspicious (at first glance): there is nothing saying we hit the needsResize branch at the end when the texture (i.e. attachment.m_textureUuid) but not the size changes.

             } else {
                  fboId = m_renderTargets.value(renderTargetNodeId);
                  // We need to check if  one of the attachment was resized
                  bool needsResize = !m_renderTargetsSize.contains(fboId);    // not even initialized yet?
                  if (!needsResize) {
                      // render target exists, has attachment been resized?
                      GLTextureManager *glTextureManager = m_renderer->nodeManagers()->glTextureManager();
                      const QSize s = m_renderTargetsSize[fboId];
                      const auto attachments_ = attachments.attachments();
                      for (const Attachment &attachment : attachments_) {
                          GLTexture *rTex = glTextureManager->lookupResource(attachment.m_textureUuid);
                          needsResize |= (rTex != nullptr && rTex->size() != s);
                          if (attachment.m_point == QRenderTargetOutput::Color0)
                              m_renderTargetFormat = rTex->properties().format;
                  if (needsResize) {
                      m_glHelper->bindFrameBufferObject(fboId, GraphicsHelperInterface::FBODraw);
                      bindFrameBufferAttachmentHelper(fboId, attachments);

      Could probably be worked on application side around by changing the entire QRenderTarget in the QRenderTargetSelector. (and that would likely be more efficient since we then just switch FBOs then instead of altering the framebuffer attachments all the time) Still, would be good to handle this somehow on QRenderTargetOutput level too.

      Update: Actually, there are very valid use cases when a texture changes and it is more appropriate to update that one attachment only, not create a whole new FBO (i.e. QRenderTarget). Think a technique that (infrequently) needs to steal the texture belonging to a QRenderTargetOutput, replacing it with a new one.


          Issue Links

          For Gerrit Dashboard: QTBUG-64757
          # Subject Branch Project Status CR V



              seanharmer Sean Harmer
              lagocs Laszlo Agocs
              0 Vote for this issue
              1 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes