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

High CPU load with vsync patch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.14.0 Alpha
    • 5.13.0 Beta 1
    • QPA: EGLFS
    • None

    Description

      This patch adds support for vsync for Nvidia eglstreams: https://codereview.qt-project.org/#/c/244792/

      However, it causes the CPU load to increase significantly, because of the busy wait for the page flip (while (m_framePending)). The following patch improves that: 

      diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cp
      index f327fd2..bec3a09 100644
      --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
      +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
      @@ -45,6 +45,7 @@
       #include "private/qeglfswindow_p.h"
       #include "private/qeglfscursor_p.h"
       #include <QLoggingCategory>
      +#include <QThread>
       #include <private/qmath_p.h>
       
       QT_BEGIN_NAMESPACE
      @@ -262,13 +263,17 @@ void QEglFSKmsEglDeviceWindow::flip()
       
           m_framePending = true;
       
      -    while (m_framePending) {
      -        drmEventContext drmEvent;
      -        memset(&drmEvent, 0, sizeof(drmEvent));
      -        drmEvent.version = 3;
      -        drmEvent.vblank_handler = nullptr;
      -        drmEvent.page_flip_handler = pageFlipHandler;
      +    drmEventContext drmEvent;
      +    memset(&drmEvent, 0, sizeof(drmEvent));
      +    drmEvent.version = 3;
      +    drmEvent.vblank_handler = nullptr;
      +    drmEvent.page_flip_handler = pageFlipHandler;
      +
      +    while (m_framePending)
      +    {
               drmHandleEvent(m_integration->m_device->fd(), &drmEvent);
      +
      +        QThread::msleep(1);
           }
       } 
      

      The goal is to find the best suited solution for this problem, which is probably not the one above. Instead usage of drmWaitVBlank() or polling for the file descriptor to become readable could be considered.

       

      Attachments

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

        Activity

          People

            gagi Dominik Holland
            bweimer Bernd Weimer
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes