On Thu, Jun 11, 2026 at 4:00 PM Akihiko Odaki
<[email protected]> wrote:
>
> Mesa's eglGetDisplay() chooses the native EGL platform from
> EGL_PLATFORM, limited autodetection, or the build-time default. If that
> selects Wayland while SDL is using the X11 video backend, Mesa can treat
> the X11 Display pointer as a wl_display and crash during eglInitialize().
>
> Probe EGL with the X11 platform explicitly before enabling
> SDL_HINT_VIDEO_X11_FORCE_EGL.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3540
> Signed-off-by: Akihiko Odaki <[email protected]>

Reviewed-by: Marc-André Lureau <[email protected]>

> ---
> Resolving the issue described in the GitLab work item also requires:
> https://github.com/libsdl-org/SDL/pull/15806
> ---
>  include/ui/egl-helpers.h | 5 +++++
>  ui/egl-helpers.c         | 4 ++--
>  ui/sdl2.c                | 3 ++-
>  3 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
> index acf993fcf52f..c97a0d5c248f 100644
> --- a/include/ui/egl-helpers.h
> +++ b/include/ui/egl-helpers.h
> @@ -61,6 +61,11 @@ void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
>
>  EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType 
> win);
>
> +#if defined(CONFIG_X11) || defined(CONFIG_GBM) || defined(WIN32)
> +EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
> +                                EGLenum platform);
> +#endif
> +
>  #if defined(CONFIG_X11) || defined(CONFIG_GBM)
>
>  int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode);
> diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
> index e3f2872cc14b..069a52495541 100644
> --- a/ui/egl-helpers.c
> +++ b/ui/egl-helpers.c
> @@ -520,8 +520,8 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, 
> EGLNativeWindowType win)
>   * platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
>   * like mesa will be able to advertise these (even though it can do EGL 1.5).
>   */
> -static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
> -                                       EGLenum platform)
> +EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
> +                                EGLenum platform)
>  {
>      EGLDisplay dpy = EGL_NO_DISPLAY;
>
> diff --git a/ui/sdl2.c b/ui/sdl2.c
> index 4fcdbd79d3c0..ce14bd1f4e15 100644
> --- a/ui/sdl2.c
> +++ b/ui/sdl2.c
> @@ -862,7 +862,8 @@ static void sdl2_set_hint_x11_force_egl(void)
>      }
>
>      /* Prefer EGL over GLX to get dma-buf support. */
> -    egl_display = eglGetDisplay((EGLNativeDisplayType)x_disp);
> +    egl_display = qemu_egl_get_display((EGLNativeDisplayType)x_disp,
> +                                       EGL_PLATFORM_X11_KHR);
>
>      if (egl_display != EGL_NO_DISPLAY) {
>          /*
>
> ---
> base-commit: 2db91528542672cf0db78b3f2cc0e22b36302b38
> change-id: 20260611-sdl-a148cd469727
>
> Best regards,
> --
> Akihiko Odaki <[email protected]>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#238450): 
https://lists.openembedded.org/g/openembedded-core/message/238450
Mute This Topic: https://lists.openembedded.org/mt/119755052/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to