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

Scenegraph nodes batching broken beginning with Qt 6.5.3

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.3, 6.6
    • Quick: SceneGraph
    • None
    • Windows

    Description

      I have constructed a simple example with a custom QQuickItem wich renders 10x10 Rectangles by using QSGRectangleNodes (constructed with window()->createRectangleNode())
      When I analyse the running program with RenderDoc (https://renderdoc.org/) I see that with newer Versions of Qt (beginning with Qt 6.5.3) the batching wont work any longer.
      Each rectangle will be drawn in a single draw call for itself.
      When I try the same example with Qt 6.5.2 then the all the rectangles are combined into a single draw call (see attached screenshots)
      I tried various newer Qt versions (also Qt 6.6.0, 6.6.1 and 6.6.2) which all show the same bug.

      QSGNode* DemoQuickItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) {
        QSGNode* rootNode = oldNode ? oldNode : new QSGTransformNode;
        if (!oldNode) {
          const int gridSize = 10; 
          const qreal rectSize = width() / gridSize;
          for (int i = 0; i < gridSize; ++i) {
            for (int j = 0; j < gridSize; ++j) {
              QColor color = QColor::fromHsv((i * gridSize + j) % 360, 255, 255);
              QRectF rect(rectSize * i, rectSize * j, rectSize, rectSize);
              QSGRectangleNode* rectNode = window()->createRectangleNode();
              rectNode->setRect(rect);
              rectNode->setColor(color);
              rootNode->appendChildNode(rectNode);
            }
          }
        }
        return rootNode;
      }
      

      The funny thing is that Qt seems to think it is batching. When I set QSG_VISUALIZE=batches then it shows a big single colored rectangle (see screenshot). But the draw calls are not combined. Even the colored overlay for the batching visualization is rendered rectangle for rectangle

      It could be related to https://bugreports.qt.io/browse/QTBUG-97557

      When I debug into the application in qsgbatchrenderer.cpp then canMerge fails because "g->indexCount()" is zero:
      https://github.com/qt/qtdeclarative/commit/f9e95c9d447f8b4223ce02e7ddf6c4ed0bfc5ec9

      Attachments

        1. batching-broken.png
          batching-broken.png
          54 kB
        2. batching-working.png
          batching-working.png
          67 kB
        3. QuickItemTest.zip
          3 kB
        4. visiualize-batching.png
          visiualize-batching.png
          12 kB

        Issue Links

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

          Activity

            People

              qt.team.graphics.and.multimedia Qt Graphics Team
              scheungrab@cipsoft.com Anton Scheungrab
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes