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

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

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Won't Do
    • P4: Low
    • None
    • 6.0.1
    • Quick: SceneGraph
    • None
    • 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

            janichol Andy Nichols
            zccrs JiDe Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes