https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34609 From a7cee8cdab8b36344e5621a8a8b5035c42e3e253 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 18 Apr 2025 09:33:46 -0400 Subject: [PATCH] egl: fix sw fallback rejection in non-sw EGL_PLATFORM=device previously progress could still be made during sw fallback here, which would lead to unpredictable results with driver loading e.g., crashing cc: mesa-stable --- src/egl/drivers/dri2/platform_device.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/egl/drivers/dri2/platform_device.c b/src/egl/drivers/dri2/platform_device.c index 0394b7c2a8fe1..bcd5b69aff31c 100644 --- a/src/egl/drivers/dri2/platform_device.c +++ b/src/egl/drivers/dri2/platform_device.c @@ -282,16 +282,21 @@ device_probe_device(_EGLDisplay *disp) if (!dri2_dpy->driver_name) goto err_name; - /* When doing software rendering, some times user still want to explicitly - * choose the render node device since cross node import doesn't work between - * vgem/virtio_gpu yet. It would be nice to have a new EXTENSION for this. - * For now, just fallback to kms_swrast. */ - if (disp->Options.ForceSoftware && !request_software && - (strcmp(dri2_dpy->driver_name, "vgem") == 0 || - strcmp(dri2_dpy->driver_name, "virtio_gpu") == 0)) { - free(dri2_dpy->driver_name); - _eglLog(_EGL_WARNING, "NEEDS EXTENSION: falling back to kms_swrast"); - dri2_dpy->driver_name = strdup("kms_swrast"); + /* this is software fallback */ + if (disp->Options.ForceSoftware && !request_software) { + /* When doing software rendering, some times user still want to explicitly + * choose the render node device since cross node import doesn't work between + * vgem/virtio_gpu yet. It would be nice to have a new EXTENSION for this. + * For now, just fallback to kms_swrast. */ + if (strcmp(dri2_dpy->driver_name, "vgem") == 0 || + strcmp(dri2_dpy->driver_name, "virtio_gpu") == 0) { + free(dri2_dpy->driver_name); + _eglLog(_EGL_WARNING, "NEEDS EXTENSION: falling back to kms_swrast"); + dri2_dpy->driver_name = strdup("kms_swrast"); + } else if (strcmp(dri2_dpy->driver_name, "vmwgfx")) { + /* this is software fallback; deny progress since a hardware device was requested */ + return false; + } } dri2_detect_swrast(disp); -- GitLab