diff options
author | Otto Ryynänen <otto.ryynanen@qt.io> | 2020-05-20 09:54:44 +0300 |
---|---|---|
committer | Otto Ryynänen <otto.ryynanen@qt.io> | 2020-06-16 09:05:14 +0300 |
commit | 6193d8c200ec4389998ef173985bf8693a11406b (patch) | |
tree | 4896db01f14621878d5896d680e3b19936c9693c | |
parent | 32c423c4fc354631c8ac7ca167b188eac215caff (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)
-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 6b9776e9c..6f2156169 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -313,9 +313,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"; @@ -558,7 +564,7 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) m_blitter->blit(window); } - 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 9e876ac17..e704792ea 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h @@ -92,7 +92,7 @@ private: DecorationsBlitter *m_blitter = nullptr; bool mUseNativeDefaultFbo = false; uint m_api; - bool mSupportNonBlockingSwap = true; + bool m_supportNonBlockingSwap = true; friend class DecorationsBlitter; }; |