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

[REG] Wayland: Over 2x higher painting CPU usage when display scaling is used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.10.0 Beta2
    • 6.8.3, 6.9.0
    • QPA: Wayland
    • None
    • kwin_wayland
    • Linux/Wayland

    Description

      When scaling is set to value higher than 100% (e.g. 175%, 200%, ...) I noticed over 2x more CPU usage when painting than on 100% scaling. Bisected to this: https://codereview.qt-project.org/c/qt/qtwayland/+/604320 and https://codereview.qt-project.org/c/qt/qtwayland/+/604633

       

      Reverting mentioned commit fixes the issue.

       

      It happens when we have an alpha channel.

       

      Example program to reproduce (CPU usage at fixed 4.5GHz CPU clock, 60 FPS):

      • Qt 6.7.3: ~20% CPU usage (scale doesn't change CPU usage)
      • Qt 6.9.0:
        • 100% scale: ~25% CPU usage
        • 200% scale: ~70% CPU usage

       

      #include <QGuiApplication>
      #include <QRasterWindow>
      #include <QElapsedTimer>
      #include <QPainter>
      
      class PaintWin : public QRasterWindow
      {
      public:
          QElapsedTimer et;
      
          uint8_t brightness = 0;
          int64_t cnt = 0;
      
          PaintWin()
          {
              QSurfaceFormat surfaceFormat;
              surfaceFormat.setAlphaBufferSize(8);
              setFormat(surfaceFormat);
              et.start();
          }
      
          void paintEvent(QPaintEvent *) override
          {
              auto elapsed = et.nsecsElapsed() / 1e9;
              if (elapsed >= 1.0)
              {
                  et.restart();
                  qDebug () << cnt / elapsed << "FPS";
                  cnt = 0;
              }
              ++cnt;
      
              QPainter p(this);
              p.fillRect(QRect(QPoint(), size()), QColor(brightness, brightness, brightness));
              ++brightness;
              update();
          }
      };
      
      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
      
          auto win = new PaintWin;
          win->showMaximized();
      
          return a.exec();
      }
      

      Attachments

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

        Activity

          People

            davidedmundson David Edmundson
            zaps166 Błażej Szczygieł
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: