diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-12-16 09:39:30 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-01-04 08:49:36 +0100 |
commit | 3054da0de0429f089b3325ed574a7f097bff68b3 (patch) | |
tree | f26803a88d21caad2ac1ce6f7f04cb9e578dc6f5 | |
parent | faeb189b9372b9aa6e1a8a50b9c0c7383f9c43d1 (diff) | |
download | qtwayland-3054da0de0429f089b3325ed574a7f097bff68b3.tar.gz |
Fix leak in multi-output compositor examples
When closing windows in e.g. multi-output, you will see warnings
that textures are leaking because the current context is not
shared with the context owning the texture.
The way Qt Wayland Compositor internals are made, they depend
on AA_ShareOpenGLContexts to be set, because buffers are consistently
referenced across window/context boundaries. Change
f1407493d6d25f24a3c71fbcedc00598baa44b56 mentions the requirement
on EGLStreams, but this is also required on multi-output compositors
to avoid leaks (and possibly sometimes crashes on some drivers).
Task-number: QTBUG-87597
Change-Id: Ib0ccc61dee5dbc63704b0af1432fbf69645d39eb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
7 files changed, 21 insertions, 0 deletions
diff --git a/examples/wayland/multi-output/doc/src/multi-output.qdoc b/examples/wayland/multi-output/doc/src/multi-output.qdoc index 233b29ba..e57ffd02 100644 --- a/examples/wayland/multi-output/doc/src/multi-output.qdoc +++ b/examples/wayland/multi-output/doc/src/multi-output.qdoc @@ -38,4 +38,8 @@ WaylandSurface is displayed in a GridView on one of the outputs, while a ShellSurface associated with the WaylandSurface is displayed with desktop-style composition on the other output. + + \note In order to support multiple Wayland outputs in the same compositor, the + \l Qt::AA_ShareOpenGLContexts attribute must be set before the \l QGuiApplication + object is constructed. */ diff --git a/examples/wayland/multi-output/main.cpp b/examples/wayland/multi-output/main.cpp index 304b13c4..1edb18c3 100644 --- a/examples/wayland/multi-output/main.cpp +++ b/examples/wayland/multi-output/main.cpp @@ -57,6 +57,8 @@ int main(int argc, char *argv[]) { + // AA_ShareOpenGLContexts is required for compositors with multiple outputs + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QGuiApplication app(argc, argv); QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); diff --git a/examples/wayland/multi-screen/doc/src/multi-screen.qdoc b/examples/wayland/multi-screen/doc/src/multi-screen.qdoc index cd60213b..5e8e7455 100644 --- a/examples/wayland/multi-screen/doc/src/multi-screen.qdoc +++ b/examples/wayland/multi-screen/doc/src/multi-screen.qdoc @@ -42,4 +42,8 @@ * WaylandQuickItem::setPrimary() is called at appropriate times to set the * primary view for the ShellSurface, which is used when the client asks to be * maximized or fullscreen. + * + * \note In order to support multiple Wayland outputs in the same compositor, the + * \l Qt::AA_ShareOpenGLContexts attribute must be set before the \l QGuiApplication + * object is constructed. */ diff --git a/examples/wayland/multi-screen/main.cpp b/examples/wayland/multi-screen/main.cpp index 304b13c4..1edb18c3 100644 --- a/examples/wayland/multi-screen/main.cpp +++ b/examples/wayland/multi-screen/main.cpp @@ -57,6 +57,8 @@ int main(int argc, char *argv[]) { + // AA_ShareOpenGLContexts is required for compositors with multiple outputs + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QGuiApplication app(argc, argv); QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); diff --git a/examples/wayland/spanning-screens/doc/src/spanning-screens.qdoc b/examples/wayland/spanning-screens/doc/src/spanning-screens.qdoc index 3ab0b91f..2594a54c 100644 --- a/examples/wayland/spanning-screens/doc/src/spanning-screens.qdoc +++ b/examples/wayland/spanning-screens/doc/src/spanning-screens.qdoc @@ -33,4 +33,8 @@ * * Spanning screens is a Wayland compositor example that maximizes clients * across a top and a bottom screen. + * + * \note In order to support multiple Wayland outputs in the same compositor, the + * \l Qt::AA_ShareOpenGLContexts attribute must be set before the \l QGuiApplication + * object is constructed. */ diff --git a/examples/wayland/spanning-screens/main.cpp b/examples/wayland/spanning-screens/main.cpp index 435b4e3f..8efb6e04 100644 --- a/examples/wayland/spanning-screens/main.cpp +++ b/examples/wayland/spanning-screens/main.cpp @@ -57,6 +57,8 @@ int main(int argc, char *argv[]) { + // AA_ShareOpenGLContexts is required for compositors with multiple outputs + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QGuiApplication app(argc, argv); QQmlApplicationEngine appEngine(QUrl("qrc:///main.qml")); diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 0f5e79d8..3bdb0082 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -258,6 +258,9 @@ QWaylandOutput::QWaylandOutput() a screen managed by the WaylandCompositor. The type corresponds to the \c wl_output interface in the Wayland protocol. + + \note If the compositor has multiple Wayland outputs, the \l Qt::AA_ShareOpenGLContexts + attribute must be set before the \l QGuiApplication object is constructed. */ /*! |