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

Scenegraph nodes batching broken beginning with Qt 6.5.3

    XMLWordPrintable

Details

    • Windows
    • 0933e62b2 (dev), 302a7530d (6.8), 280f289fa (6.7), 59743e96b (tqtc/lts-6.5)

    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
          54 kB
          Anton Scheungrab
        2. batching-working.png
          67 kB
          Anton Scheungrab
        3. QuickItemTest.zip
          3 kB
          Anton Scheungrab
        4. visiualize-batching.png
          12 kB
          Anton Scheungrab

        Issue Links

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

          Activity

            People

              lagocs Laszlo Agocs
              scheungrab@cipsoft.com Anton Scheungrab
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: