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

How to render a part of area by QQuickRenderControl::render

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Reported
    • Priority: P4: Low
    • Resolution: Unresolved
    • Affects Version/s: 6.0.1
    • Fix Version/s: None
    • Component/s: Quick: SceneGraph
    • Labels:
      None
    • Platform/s:
      All

      Description

      Hi.

      I want render a QQuickWindow to multi custom render target, how do i should it? For a pseudo code example:

      class FutureRenderControl : public QQuickRenderControl
      {
      public:
          void render(const QRect &geometry) {
              Q_D(QQuickRenderControl);
              if (!d->window)
                  return;
          
              QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window);
              if (d->rhi) {
                  if (!d->rhi->isRecordingFrame()) {
                      qWarning("QQuickRenderControl can only render when beginFrame() has been called");
                      return;
                  }
                  if (!d->cb) {
                      qWarning("QQuickRenderControl cannot be used with QRhi when no QRhiCommandBuffer is provided");
                      return;
                  }
                  cd->setCustomCommandBuffer(d->cb);
              }
          
              // should add renderSceneGraph(const QRect &geometry) for QQuickWindow
              cd->renderSceneGraph(geometry);
          }
      };
      
      void renderWindow(FutureRenderControl *rc, const QRect &geo) {
          QOpenGLContext *glOfThread = ...;
          glOfThread->makeCurrent(...);
          // This texture can is a Linux GBM buffer of a drm output device, so we can map the QQuickWindow to multi screen at the same time by multi thread.
          QOpenGLTexture *texture = ...;
          aBlockOfTexture->bind();
          rc->render(geo);
      }
      
      void demo() {
          auto rc = new FutureRenderControl();
          auto window = new QQuickWindow(rc);
          window->resize(20, 20);
          // render for part top-left
          QtConcurrent::run(renderWindow, rc, QRect(0, 0, 10, 10));
          // render for part top-right
          QtConcurrent::run(renderWindow, rc, QRect(10, 0, 10, 10));
          // render for part bottom-left
          QtConcurrent::run(renderWindow, rc, QRect(0, 10, 10, 10));
          // render for part bottom-right
          QtConcurrent::run(renderWindow, rc, QRect(10, 10, 10, 10));
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            janichol Andy Nichols
            Reporter:
            zccrs chen zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes