diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-04-21 08:46:43 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-05-03 06:46:50 +0200 |
commit | 6d8e7567d7d1737c240cfca4402bf6ec5a67b02e (patch) | |
tree | dabeabdcaaee30525194b267f51384cf27c83103 | |
parent | e58eb814c84d506b47469d000b4913b6d3d61dc2 (diff) | |
download | qtwayland-6d8e7567d7d1737c240cfca4402bf6ec5a67b02e.tar.gz |
Allow multiple client buffer integrations to initialize
This amends 585f20dce37c398d8b2e6367008e3329dac79e24 where
support for multiple client buffer integrations was added.
Previously, this would not work unless you also set
QT_WAYLAND_IGNORE_BIND_DISPLAY in the environment, because
we would fail if eglBindWaylandDisplayWL() returned false,
which it will when the display is already bound.
Instead, we assume the display is correctly bound when the
function returns false, and then we make sure we unbind from
the same integration that originally did the bind.
The patch adds unbind to the destructor of linux-dmabuf and
eglstream integrations. This was previously missing.
[ChangeLog][QtWaylandCompositor] Enabled support for multiple
client buffer integrations without the need to set the
QT_WAYLAND_IGNORE_BIND_DISPLAY environment variable.
Fixes: QTBUG-101366
Change-Id: Iefeb865b540d96a55d3be9b9c1fb41bf388638ca
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
4 files changed, 23 insertions, 25 deletions
diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp index 3cc7c4e6..24e80ed1 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp @@ -267,6 +267,12 @@ LinuxDmabufClientBufferIntegration::LinuxDmabufClientBufferIntegration() LinuxDmabufClientBufferIntegration::~LinuxDmabufClientBufferIntegration() { m_importedBuffers.clear(); + + if (egl_unbind_wayland_display != nullptr && m_displayBound) { + Q_ASSERT(m_wlDisplay != nullptr); + if (!egl_unbind_wayland_display(m_eglDisplay, m_wlDisplay)) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "eglUnbindWaylandDisplayWL failed"; + } } void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display *display) @@ -320,14 +326,9 @@ void LinuxDmabufClientBufferIntegration::initializeHardware(struct ::wl_display if (egl_bind_wayland_display && egl_unbind_wayland_display) { m_displayBound = egl_bind_wayland_display(m_eglDisplay, display); - if (!m_displayBound) { - if (ignoreBindDisplay) { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; - } else { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Failed to initialize EGL display. Could not bind Wayland display."; - return; - } - } + if (!m_displayBound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; + m_wlDisplay = display; } // request and sent formats/modifiers only after egl_display is bound diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h index 35417d79..f4c1b768 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.h @@ -92,6 +92,7 @@ private: QList<uint64_t> supportedDrmModifiers(uint32_t format); EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; + ::wl_display *m_wlDisplay = nullptr; bool m_displayBound = false; QList<QOpenGLTexture *> m_orphanedTextures; QHash<EGLint, YuvFormatConversion> m_yuvFormats; diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index c707f6e9..0936f8f8 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -458,15 +458,8 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { d->display_bound = d->egl_bind_wayland_display(d->egl_display, display); - if (!d->display_bound) { - if (!ignoreBindDisplay) { - qCWarning(qLcWaylandCompositorHardwareIntegration) - << "Failed to initialize EGL display. Could not bind Wayland display."; - return; - } else { - qCWarning(qLcWaylandCompositorHardwareIntegration) << "Could not bind Wayland display. Ignoring."; - } - } + if (!d->display_bound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; d->wlDisplay = display; } diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp index 9bdf8eb5..f4feb2e9 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp @@ -155,6 +155,7 @@ public: EGLDisplay egl_display = EGL_NO_DISPLAY; bool display_bound = false; + ::wl_display *wlDisplay = nullptr; QOffscreenSurface *offscreenSurface = nullptr; QOpenGLContext *localContext = nullptr; QList<QOpenGLTexture *> orphanedTextures; @@ -282,7 +283,13 @@ WaylandEglStreamClientBufferIntegration::WaylandEglStreamClientBufferIntegration WaylandEglStreamClientBufferIntegration::~WaylandEglStreamClientBufferIntegration() { + Q_D(WaylandEglStreamClientBufferIntegration); WaylandEglStreamClientBufferIntegrationPrivate::shuttingDown = true; + if (d->egl_unbind_wayland_display != nullptr && d->display_bound) { + Q_ASSERT(d->wlDisplay != nullptr); + if (!d->egl_unbind_wayland_display(d->egl_display, d->wlDisplay)) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "eglUnbindWaylandDisplayWL failed"; + } } void WaylandEglStreamClientBufferIntegration::attachEglStreamConsumer(struct ::wl_resource *wl_surface, struct ::wl_resource *wl_buffer) @@ -336,14 +343,10 @@ void WaylandEglStreamClientBufferIntegration::initializeHardware(struct wl_displ if (d->egl_bind_wayland_display && d->egl_unbind_wayland_display) { d->display_bound = d->egl_bind_wayland_display(d->egl_display, display); - if (!d->display_bound) { - if (!ignoreBindDisplay) { - qWarning("QtCompositor: Failed to initialize EGL display. Could not bind Wayland display."); - return; - } else { - qWarning("QtCompositor: Could not bind Wayland display. Ignoring."); - } - } + if (!d->display_bound) + qCDebug(qLcWaylandCompositorHardwareIntegration) << "Wayland display already bound by other client buffer integration."; + + d->wlDisplay = display; } d->eglStreamController = new WaylandEglStreamController(display, this); |