Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.13.0 Beta 1
-
None
-
-
a2fa624c793e0c571ac2f56d6a4786060d70bc47 (qt/qtbase/dev)
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.