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

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34609>
(cherry picked from commit 8a339cdebccdea0610bdd7a1ecc9a5ec63951940)
This commit is contained in:
Mike Blumenkrantz
2025-04-18 09:33:46 -04:00
committed by Eric Engestrom
parent 746f2986ec
commit cdafaef206
2 changed files with 16 additions and 11 deletions

View File

@@ -24,7 +24,7 @@
"description": "egl: fix sw fallback rejection in non-sw EGL_PLATFORM=device",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@@ -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;
}
}
if (!dri2_load_driver(disp))