diff options
author | Gurchetan Singh <[email protected]> | 2017-10-02 13:48:24 -0700 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2017-10-03 17:56:15 +0100 |
commit | 9d9a46d4efc00b256d2c0d04dda6c4ee3f0dc47a (patch) | |
tree | 6458dfbe48043385ca116d7379a66c71c59a3f39 /src/egl/drivers/dri2 | |
parent | 540c804297d813aa7df28d570e0407e332873c88 (diff) |
egl/surfaceless: Use KMS swrast fallback
The kms_swrast extension is an actively developed software fallback,
and platform_surfaceless can use it if there are no available
hardware drivers.
v2: Split into 2 patches, use booleans, check LIBGL_ALWAYS_SOFTWARE,
and modify the eglLog level (Emil, Eric, Tomasz).
Reviewed-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl/drivers/dri2')
-rw-r--r-- | src/egl/drivers/dri2/platform_surfaceless.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c index f6aa217d39c..2af4a40b1a6 100644 --- a/src/egl/drivers/dri2/platform_surfaceless.c +++ b/src/egl/drivers/dri2/platform_surfaceless.c @@ -36,6 +36,7 @@ #include "egl_dri2.h" #include "egl_dri2_fallbacks.h" #include "loader.h" +#include "util/debug.h" static __DRIimage* surfaceless_alloc_image(struct dri2_egl_display *dri2_dpy, @@ -268,7 +269,7 @@ static const __DRIextension *image_loader_extensions[] = { }; static bool -surfaceless_probe_device(_EGLDisplay *dpy) +surfaceless_probe_device(_EGLDisplay *dpy, bool swrast) { struct dri2_egl_display *dri2_dpy = dpy->DriverData; const int limit = 64; @@ -286,7 +287,10 @@ surfaceless_probe_device(_EGLDisplay *dpy) if (fd < 0) continue; - dri2_dpy->driver_name = loader_get_driver_for_fd(fd); + if (swrast) + dri2_dpy->driver_name = strdup("kms_swrast"); + else + dri2_dpy->driver_name = loader_get_driver_for_fd(fd); if (!dri2_dpy->driver_name) { close(fd); continue; @@ -310,7 +314,7 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; const char* err; - int driver_loaded = 0; + bool driver_loaded = false; loader_set_logger(_eglLog); @@ -320,7 +324,15 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->fd = -1; disp->DriverData = (void *) dri2_dpy; - if (!surfaceless_probe_device(disp)) { + + if (!env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false)) { + driver_loaded = surfaceless_probe_device(disp, false); + if (!driver_loaded) + _eglLog(_EGL_WARNING, + "No hardware driver found, falling back to software rendering"); + } + + if (!driver_loaded && !surfaceless_probe_device(disp, true)) { err = "DRI2: failed to load driver"; goto cleanup; } |