summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>2026-06-11 20:58:03 +0900
committerMichael Tokarev <mjt@tls.msk.ru>2026-06-24 10:36:22 +0300
commit45ebaadb273f4abe7f47a21081341ad0618648b0 (patch)
tree28cb07b0c5c807788b54bd8c6ce019d14a0fb461
parenta7f9127b5978ea1e6ed1bdbc8d1c874cea9221b8 (diff)
downloadqemu-45ebaadb273f4abe7f47a21081341ad0618648b0.tar.gz
qemu-45ebaadb273f4abe7f47a21081341ad0618648b0.zip
ui/sdl2: Explicitly specify EGL platform
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 <odaki@rsg.ci.i.u-tokyo.ac.jp> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260611-sdl-v1-1-93d4a51684bb@rsg.ci.i.u-tokyo.ac.jp> (cherry picked from commit 6157908503f9a5a14d17a8ecf8cc3308107e1458) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--include/ui/egl-helpers.h5
-rw-r--r--ui/egl-helpers.c4
-rw-r--r--ui/sdl2.c3
3 files changed, 9 insertions, 3 deletions
diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index acf993fcf5..c97a0d5c24 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 e3f2872cc1..069a524955 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 987ad334bb..9dd5e305e1 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) {
/*