diff options
author | Otto Ryynänen <otto.ryynanen@qt.io> | 2020-05-20 09:54:44 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-06-04 20:38:14 +0000 |
commit | eaeb21284ab7a3714c735ee8d7c348aa3bc3a07a (patch) | |
tree | 9cb25040e841ffcd520d8b888668eccebe8d85e5 | |
parent | f5a84adfe9d7a57de31813167acea55adb7f309d (diff) |
Add means for forcing non-blocking buffer swap support
In case of a driver that does not properly indicate its capability of
supporting non-blocking eglSwapBuffers() call, the need arises to be
able to manually force the resolution of that check.
New environment variable QT_WAYLAND_FORCE_NONBLOCKING_SWAP_SUPPORT
added. If it is defined to 0 (i.e. false), the non-blocking swap
support is forced to behave as if the driver had been detected not to
be supported. Equally setting it to 1 causes the non-blocking swap
support resolution to remain true (default) even if driver reports it
does not support it.
[ChangeLog][Client] Added support for environment variable
QT_WAYLAND_FORCE_NONBLOCKING_SWAP_SUPPORT, which can be used to force
the resolution of detecting if EGL driver supports non-blocking
eglSwapBuffers call. If you encounter application freezing while
waiting indefinitely for a buffer swap, then try setting variable to 0.
Task-number: QTBUG-84226
Change-Id: I92dc505d12daf4d78dc18e4f85f3a55ecdf109f3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 765ad803579c09ea5e827c60efbc89c5ac4fcd42)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp | 12 | ||||
-rw-r--r-- | src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index 02affe31b..ccebf43d0 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -322,9 +322,15 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis if (!eglGetConfigAttrib(m_eglDisplay, m_config, a, &a) || !eglGetConfigAttrib(m_eglDisplay, m_config, b, &b) || a > 0) { - mSupportNonBlockingSwap = false; + m_supportNonBlockingSwap = false; } - if (!mSupportNonBlockingSwap) { + { + bool ok; + int supportNonBlockingSwap = qEnvironmentVariableIntValue("QT_WAYLAND_FORCE_NONBLOCKING_SWAP_SUPPORT", &ok); + if (ok) + m_supportNonBlockingSwap = supportNonBlockingSwap != 0; + } + if (!m_supportNonBlockingSwap) { qWarning(lcQpaWayland) << "Non-blocking swap buffers not supported." << "Subsurface rendering can be affected." << "It may also cause the event loop to freeze in some situations"; @@ -478,7 +484,7 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) eglMakeCurrent(currentDisplay, currentSurfaceDraw, currentSurfaceRead, currentContext); } - int swapInterval = mSupportNonBlockingSwap ? 0 : m_format.swapInterval(); + int swapInterval = m_supportNonBlockingSwap ? 0 : m_format.swapInterval(); eglSwapInterval(m_eglDisplay, swapInterval); if (swapInterval == 0 && m_format.swapInterval() > 0) { // Emulating a blocking swap diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h index 0e86ca4f5..46c7bb76d 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h @@ -92,7 +92,7 @@ private: QSurfaceFormat m_format; DecorationsBlitter *m_blitter = nullptr; uint m_api; - bool mSupportNonBlockingSwap = true; + bool m_supportNonBlockingSwap = true; }; } |