@@ -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);
@@ -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;
@@ -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) {
/*
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> --- 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(-) --- base-commit: 2db91528542672cf0db78b3f2cc0e22b36302b38 change-id: 20260611-sdl-a148cd469727 Best regards, -- Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>