summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2019-02-19 14:08:06 +0000
committerEmil Velikov <[email protected]>2019-02-28 12:02:19 +0000
commit893421f3159ac6d82bb56b3feccf79dd71eb250e (patch)
tree70abc81dd8d847b050da65ebf3a90ffad28fad1a /src/egl/drivers
parentb43b55d4619489e603780adf3c92a36dadcc362b (diff)
egl/sl: split out swrast probe into separate function
Make the code a bit easier to read. As a bonus point this makes it obvious that we forgot to call _eglAddDevice() for the device - do so. v2: - s/dpy/disp/ (Eric) - free(driver_name) on dri2_load_driver_swrast() failure (Eric) Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Mathias Fröhlich <[email protected]> (v1) Reviewed-by: Gurchetan Singh <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r--src/egl/drivers/dri2/platform_surfaceless.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index 0c018a35234..42bd17e8341 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -322,25 +322,30 @@ surfaceless_probe_device(_EGLDisplay *disp, bool swrast)
dri2_dpy->loader_extensions = NULL;
}
- /* No DRM device, so attempt to fall back to software path w/o DRM. */
- if (swrast) {
- _eglLog(_EGL_DEBUG, "Falling back to surfaceless swrast without DRM.");
- dri2_dpy->fd = -1;
- dri2_dpy->driver_name = strdup("swrast");
- if (!dri2_dpy->driver_name) {
- return false;
- }
+ return false;
+}
- if (dri2_load_driver_swrast(disp)) {
- dri2_dpy->loader_extensions = swrast_loader_extensions;
- return true;
- }
+static bool
+surfaceless_probe_device_sw(_EGLDisplay *disp)
+{
+ struct dri2_egl_display *dri2_dpy = disp->DriverData;
+
+ dri2_dpy->fd = -1;
+ disp->Device = _eglAddDevice(dri2_dpy->fd, true);
+ assert(disp->Device);
+
+ dri2_dpy->driver_name = strdup("swrast");
+ if (!dri2_dpy->driver_name)
+ return false;
+ if (!dri2_load_driver_swrast(disp)) {
free(dri2_dpy->driver_name);
dri2_dpy->driver_name = NULL;
+ return false;
}
- return false;
+ dri2_dpy->loader_extensions = swrast_loader_extensions;
+ return true;
}
EGLBoolean
@@ -364,9 +369,15 @@ dri2_initialize_surfaceless(_EGLDriver *drv, _EGLDisplay *disp)
"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;
+ if (!driver_loaded)
+ driver_loaded = surfaceless_probe_device(disp, true);
+
+ if (!driver_loaded) {
+ _eglLog(_EGL_DEBUG, "Falling back to surfaceless swrast without DRM.");
+ if (!surfaceless_probe_device_sw(disp)) {
+ err = "DRI2: failed to load driver";
+ goto cleanup;
+ }
}
if (!dri2_create_screen(disp)) {