qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH v2 16/18] ui: introduce egl_init()
Date: Fri, 10 Mar 2023 10:06:19 +0000	[thread overview]
Message-ID: <ZAsBG9DQp07DuzTL@redhat.com> (raw)
In-Reply-To: <20230307115637.2464377-17-marcandre.lureau@redhat.com>

On Tue, Mar 07, 2023 at 03:56:35PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Future patches will introduce EGL support on win32 (too late for 8.0
> though). Having a common place for EGL initialization and error handling
> will make it simpler.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/ui/egl-helpers.h |  2 ++
>  ui/dbus.c                |  7 +------
>  ui/egl-headless.c        | 16 ++++++++--------
>  ui/egl-helpers.c         | 25 +++++++++++++++++++++++++
>  ui/spice-core.c          |  7 +------
>  5 files changed, 37 insertions(+), 20 deletions(-)
> 
> diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
> index c92dd90e33..53d953ddf4 100644
> --- a/include/ui/egl-helpers.h
> +++ b/include/ui/egl-helpers.h
> @@ -65,4 +65,6 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
>  EGLContext qemu_egl_init_ctx(void);
>  bool qemu_egl_has_dmabuf(void);
>  
> +bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp);
> +
>  #endif /* EGL_HELPERS_H */
> diff --git a/ui/dbus.c b/ui/dbus.c
> index f529928f0b..ebf03bd84d 100644
> --- a/ui/dbus.c
> +++ b/ui/dbus.c
> @@ -451,12 +451,7 @@ early_dbus_init(DisplayOptions *opts)
>      DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF;
>  
>      if (mode != DISPLAYGL_MODE_OFF) {
> -        if (egl_rendernode_init(opts->u.dbus.rendernode, mode) < 0) {
> -            error_report("dbus: render node init failed");
> -            exit(1);
> -        }
> -
> -        display_opengl = 1;
> +        egl_init(opts->u.dbus.rendernode, mode, &error_fatal);
>      }
>  
>      type_register(&dbus_vc_type_info);
> diff --git a/ui/egl-headless.c b/ui/egl-headless.c
> index ae07e91302..ef70e6a18e 100644
> --- a/ui/egl-headless.c
> +++ b/ui/egl-headless.c
> @@ -1,7 +1,7 @@
>  #include "qemu/osdep.h"
>  #include "qemu/error-report.h"
>  #include "qemu/module.h"
> -#include "sysemu/sysemu.h"
> +#include "qapi/error.h"
>  #include "ui/console.h"
>  #include "ui/egl-helpers.h"
>  #include "ui/egl-context.h"
> @@ -191,21 +191,21 @@ static const DisplayGLCtxOps eglctx_ops = {
>  
>  static void early_egl_headless_init(DisplayOptions *opts)
>  {
> -    display_opengl = 1;
> +    DisplayGLMode mode = DISPLAYGL_MODE_ON;
> +
> +    if (opts->has_gl) {
> +        mode = opts->gl;
> +    }
> +
> +    egl_init(opts->u.egl_headless.rendernode, mode, &error_fatal);
>  }
>  
>  static void egl_headless_init(DisplayState *ds, DisplayOptions *opts)
>  {
> -    DisplayGLMode mode = opts->has_gl ? opts->gl : DISPLAYGL_MODE_ON;
>      QemuConsole *con;
>      egl_dpy *edpy;
>      int idx;
>  
> -    if (egl_rendernode_init(opts->u.egl_headless.rendernode, mode) < 0) {
> -        error_report("egl: render node init failed");
> -        exit(1);
> -    }
> -
>      for (idx = 0;; idx++) {
>          DisplayGLCtx *ctx;

Why isn't the egl_init() call being made from this egl_headless_init
method, so egl_rendernode_init() is called at the same logical point
as before this change ?


> diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
> index 10772b6471..36b4fc51d9 100644
> --- a/ui/egl-helpers.c
> +++ b/ui/egl-helpers.c
> @@ -19,6 +19,8 @@
>  #include "qemu/error-report.h"
>  #include "ui/console.h"
>  #include "ui/egl-helpers.h"
> +#include "sysemu/sysemu.h"
> +#include "qapi/error.h"
>  
>  EGLDisplay *qemu_egl_display;
>  EGLConfig qemu_egl_config;
> @@ -569,3 +571,26 @@ EGLContext qemu_egl_init_ctx(void)
>  
>      return ectx;
>  }
> +
> +bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp)
> +{
> +    ERRP_GUARD();
> +
> +    if (mode == DISPLAYGL_MODE_OFF) {
> +        error_setg(errp, "egl: turning off GL doesn't make sense");
> +        return false;
> +    }
> +
> +#ifdef CONFIG_GBM
> +    if (egl_rendernode_init(rendernode, mode) < 0) {
> +        error_setg(errp, "egl: render node init failed");
> +        return false;
> +    }
> +#else
> +    error_setg(errp, "egl: not available on this platform");
> +    return false;
> +#endif
> +
> +    display_opengl = 1;
> +    return true;
> +}

Surely this is going to result in compile errors when !CONFIG_GBM
because these two lines are going to be flagged as unreachable
code, due to the 'return false' in the #else branch.

> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index 76f7c2bc3d..b05c830086 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -820,12 +820,7 @@ static void qemu_spice_init(void)
>                           "incompatible with -spice port/tls-port");
>              exit(1);
>          }
> -        if (egl_rendernode_init(qemu_opt_get(opts, "rendernode"),
> -                                DISPLAYGL_MODE_ON) != 0) {
> -            error_report("Failed to initialize EGL render node for SPICE GL");
> -            exit(1);
> -        }
> -        display_opengl = 1;
> +        egl_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON, &error_fatal);
>          spice_opengl = 1;
>      }
>  #endif
> -- 
> 2.39.2
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2023-03-10 10:06 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 11:56 [PATCH v2 00/18] ui: dbus & misc fixes marcandre.lureau
2023-03-07 11:56 ` [PATCH v2 01/18] ui/dbus: initialize cursor_fb marcandre.lureau
2023-03-09 16:30   ` Philippe Mathieu-Daudé
2023-03-07 11:56 ` [PATCH v2 02/18] ui/dbus: unregister clipboard on connection close marcandre.lureau
2023-03-10  9:45   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 03/18] audio/dbus: there are no sender for p2p mode marcandre.lureau
2023-03-10  9:47   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 04/18] ui/dbus: set mouse is-absolute during console creation marcandre.lureau
2023-03-09 16:32   ` Philippe Mathieu-Daudé
2023-03-07 11:56 ` [PATCH v2 05/18] meson: ensure dbus-display generated code is built before other units marcandre.lureau
2023-03-10  9:49   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 06/18] ui: rename cursor_{put->unref} marcandre.lureau
2023-03-10  9:51   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 07/18] ui: rename cursor_{get->ref}, return it marcandre.lureau
2023-03-10  9:52   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 08/18] ui: keep current cursor with QemuConsole marcandre.lureau
2023-03-10  9:54   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 09/18] ui: set cursor upon listener registration marcandre.lureau
2023-03-10  9:57   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 10/18] ui: set cursor position " marcandre.lureau
2023-03-10  9:58   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 11/18] ui/sdl: get the GL context from the window marcandre.lureau
2023-03-10 10:00   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 12/18] ui/shader: fix #version directive must occur on first line marcandre.lureau
2023-03-10 10:00   ` Daniel P. Berrangé
2023-03-07 11:56 ` [PATCH v2 13/18] ui/egl: print EGL error, helping debugging marcandre.lureau
2023-03-09 16:38   ` Philippe Mathieu-Daudé
2023-03-07 11:56 ` [PATCH v2 14/18] ui/sdl: add optional logging when _SDL_DEBUG is set marcandre.lureau
2023-03-09 16:39   ` Philippe Mathieu-Daudé
2023-03-10  5:17     ` Marc-André Lureau
2023-03-10  6:10       ` Sam Lantinga
2023-03-07 11:56 ` [PATCH v2 15/18] ui/sdl: try to instantiate the matching opengl renderer marcandre.lureau
2023-03-10 10:02   ` Daniel P. Berrangé
2023-03-13  9:42     ` Marc-André Lureau
2023-03-07 11:56 ` [PATCH v2 16/18] ui: introduce egl_init() marcandre.lureau
2023-03-10 10:06   ` Daniel P. Berrangé [this message]
2023-03-13  9:59     ` Marc-André Lureau
2023-03-07 11:56 ` [PATCH v2 17/18] ui/dbus: do not require opengl & gbm marcandre.lureau
2023-03-07 13:32   ` Marc-André Lureau
2023-03-07 11:56 ` [PATCH v2 18/18] ui/dbus: restrict opengl to gbm-enabled config marcandre.lureau
2023-03-09 15:51 ` [PATCH v2 00/18] ui: dbus & misc fixes Marc-André Lureau

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=ZAsBG9DQp07DuzTL@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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).