From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
akihiko.odaki@gmail.com
Subject: [PATCH v3 02/12] ui/console: move dcl compatiblity check to a callback
Date: Mon, 7 Mar 2022 11:46:22 +0400 [thread overview]
Message-ID: <20220307074632.238049-3-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20220307074632.238049-1-marcandre.lureau@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
As expected from the "compatible_dcl" comment, a simple comparison of
ops isn't enough. The following patch will fix a regression introduced
by this limited check by extending the compatibility callback for
egl-headless.
For now, this patch simply replaces the the "compatible_dcl" ops pointer
with a "dpy_gl_ctx_is_compatible_ctx" callback.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/console.h | 9 ++-------
ui/console.c | 3 ++-
ui/dbus.c | 9 ++++++++-
ui/egl-headless.c | 9 ++++++++-
ui/gtk.c | 18 ++++++++++++++++--
ui/sdl2.c | 9 ++++++++-
ui/spice-display.c | 9 ++++++++-
7 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/include/ui/console.h b/include/ui/console.h
index f590819880b5..18a10c0b7db0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -282,13 +282,8 @@ struct DisplayChangeListener {
};
typedef struct DisplayGLCtxOps {
- /*
- * We only check if the GLCtx is compatible with a DCL via ops. A natural
- * evolution of this would be a callback to check some runtime requirements
- * and allow various DCL kinds.
- */
- const DisplayChangeListenerOps *compatible_dcl;
-
+ bool (*dpy_gl_ctx_is_compatible_dcl)(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl);
QEMUGLContext (*dpy_gl_ctx_create)(DisplayGLCtx *dgc,
QEMUGLParams *params);
void (*dpy_gl_ctx_destroy)(DisplayGLCtx *dgc,
diff --git a/ui/console.c b/ui/console.c
index 57e431d9e609..c9318552871b 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1482,7 +1482,8 @@ static bool dpy_compatible_with(QemuConsole *con,
flags = con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0;
- if (console_has_gl(con) && con->gl->ops->compatible_dcl != dcl->ops) {
+ if (console_has_gl(con) &&
+ !con->gl->ops->dpy_gl_ctx_is_compatible_dcl(con->gl, dcl)) {
error_setg(errp, "Display %s is incompatible with the GL context",
dcl->ops->dpy_name);
return false;
diff --git a/ui/dbus.c b/ui/dbus.c
index 0074424c1fed..f00a44421cf7 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -48,8 +48,15 @@ static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc,
return qemu_egl_create_context(dgc, params);
}
+static bool
+dbus_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &dbus_gl_dcl_ops;
+}
+
static const DisplayGLCtxOps dbus_gl_ops = {
- .compatible_dcl = &dbus_gl_dcl_ops,
+ .dpy_gl_ctx_is_compatible_dcl = dbus_is_compatible_dcl,
.dpy_gl_ctx_create = dbus_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = qemu_egl_make_context_current,
diff --git a/ui/egl-headless.c b/ui/egl-headless.c
index 94082a9da951..9aff115280bc 100644
--- a/ui/egl-headless.c
+++ b/ui/egl-headless.c
@@ -166,8 +166,15 @@ static const DisplayChangeListenerOps egl_ops = {
.dpy_gl_update = egl_scanout_flush,
};
+static bool
+egl_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &egl_ops;
+}
+
static const DisplayGLCtxOps eglctx_ops = {
- .compatible_dcl = &egl_ops,
+ .dpy_gl_ctx_is_compatible_dcl = egl_is_compatible_dcl,
.dpy_gl_ctx_create = egl_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = qemu_egl_make_context_current,
diff --git a/ui/gtk.c b/ui/gtk.c
index a8567b9ddc8f..1b24a67d7964 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -614,8 +614,15 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+static bool
+gd_gl_area_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &dcl_gl_area_ops;
+}
+
static const DisplayGLCtxOps gl_area_ctx_ops = {
- .compatible_dcl = &dcl_gl_area_ops,
+ .dpy_gl_ctx_is_compatible_dcl = gd_gl_area_is_compatible_dcl,
.dpy_gl_ctx_create = gd_gl_area_create_context,
.dpy_gl_ctx_destroy = gd_gl_area_destroy_context,
.dpy_gl_ctx_make_current = gd_gl_area_make_current,
@@ -641,8 +648,15 @@ static const DisplayChangeListenerOps dcl_egl_ops = {
.dpy_has_dmabuf = gd_has_dmabuf,
};
+static bool
+gd_egl_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &dcl_egl_ops;
+}
+
static const DisplayGLCtxOps egl_ctx_ops = {
- .compatible_dcl = &dcl_egl_ops,
+ .dpy_gl_ctx_is_compatible_dcl = gd_egl_is_compatible_dcl,
.dpy_gl_ctx_create = gd_egl_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = gd_egl_make_current,
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 46a252d7d9d7..d3741f9b754d 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -788,8 +788,15 @@ static const DisplayChangeListenerOps dcl_gl_ops = {
.dpy_gl_update = sdl2_gl_scanout_flush,
};
+static bool
+sdl2_gl_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &dcl_gl_ops;
+}
+
static const DisplayGLCtxOps gl_ctx_ops = {
- .compatible_dcl = &dcl_gl_ops,
+ .dpy_gl_ctx_is_compatible_dcl = sdl2_gl_is_compatible_dcl,
.dpy_gl_ctx_create = sdl2_gl_create_context,
.dpy_gl_ctx_destroy = sdl2_gl_destroy_context,
.dpy_gl_ctx_make_current = sdl2_gl_make_context_current,
diff --git a/ui/spice-display.c b/ui/spice-display.c
index a3078adf91ec..494168e7fe75 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -1125,8 +1125,15 @@ static const DisplayChangeListenerOps display_listener_gl_ops = {
.dpy_gl_update = qemu_spice_gl_update,
};
+static bool
+qemu_spice_is_compatible_dcl(DisplayGLCtx *dgc,
+ DisplayChangeListener *dcl)
+{
+ return dcl->ops == &display_listener_gl_ops;
+}
+
static const DisplayGLCtxOps gl_ctx_ops = {
- .compatible_dcl = &display_listener_gl_ops,
+ .dpy_gl_ctx_is_compatible_dcl = qemu_spice_is_compatible_dcl,
.dpy_gl_ctx_create = qemu_spice_gl_create_context,
.dpy_gl_ctx_destroy = qemu_egl_destroy_context,
.dpy_gl_ctx_make_current = qemu_egl_make_context_current,
--
2.35.1.273.ge6ebfd0e8cbb
next prev parent reply other threads:[~2022-03-07 7:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 7:46 [PATCH v3 00/12] GL & D-Bus display related fixes marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 01/12] ui/console: move check for compatible GL context marcandre.lureau
2022-03-07 7:46 ` marcandre.lureau [this message]
2022-03-07 7:46 ` [PATCH v3 03/12] ui/console: egl-headless is compatible with non-gl listeners marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 04/12] ui/dbus: associate the DBusDisplayConsole listener with the given console marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 05/12] ui/console: move console compatibility check to dcl_display_console() marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 06/12] ui/shader: fix potential leak of shader on error marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 07/12] ui/shader: free associated programs marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 08/12] ui/console: add a dpy_gfx_switch callback helper marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 09/12] ui/console: optionally update after gfx switch marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 10/12] ui/dbus: fix texture sharing marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 11/12] ui/dbus: do not send 2d scanout until gfx_update marcandre.lureau
2022-03-07 7:46 ` [PATCH v3 12/12] ui/console: call gfx_switch() even if the current scanout is GL marcandre.lureau
2022-03-07 8:08 ` Akihiko Odaki
2022-03-07 10:19 ` Marc-André Lureau
2022-03-07 10:34 ` Akihiko Odaki
2022-03-07 11:50 ` Marc-André Lureau
2022-03-07 12:24 ` Akihiko Odaki
2022-03-07 12:32 ` Marc-André Lureau
2022-03-07 12:49 ` Akihiko Odaki
2022-03-08 14:26 ` Marc-André Lureau
2022-03-08 14:42 ` Akihiko Odaki
2022-03-09 8:02 ` Marc-André Lureau
2022-03-09 8:05 ` Akihiko Odaki
2022-03-09 8:11 ` Marc-André Lureau
2022-03-09 8:21 ` Akihiko Odaki
2022-03-09 8:33 ` Marc-André Lureau
2022-03-09 8:34 ` Akihiko Odaki
2022-03-09 8:40 ` Marc-André Lureau
2022-03-09 8:49 ` Akihiko Odaki
2022-03-09 8:54 ` Marc-André Lureau
2022-03-09 9:02 ` Akihiko Odaki
2022-03-09 9:26 ` Gerd Hoffmann
2022-03-09 9:32 ` Akihiko Odaki
2022-03-09 9:53 ` Marc-André Lureau
2022-03-09 10:01 ` Akihiko Odaki
2022-03-09 10:07 ` Marc-André Lureau
2022-03-09 10:20 ` Akihiko Odaki
2022-03-09 10:27 ` Marc-André Lureau
2022-03-09 10:38 ` Akihiko Odaki
2022-03-09 10:45 ` Marc-André Lureau
2022-03-09 10:54 ` Akihiko Odaki
2022-03-09 10:13 ` Gerd Hoffmann
2022-03-09 10:15 ` [PATCH v3 00/12] GL & D-Bus display related fixes Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307074632.238049-3-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=akihiko.odaki@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).