[Mesa-dev] [PATCH 2/2] egl/surfaceless: Allow DRMless fallback.
David Riley
davidriley at chromium.org
Thu Jul 12 23:13:55 UTC 2018
Allow platform_surfaceless to use swrast even if DRM is not available.
To be used to allow a fuzzer for virgl to be run on a jailed VM without
hardware GL or DRM support.
Signed-off-by: David Riley <davidriley at chromium.org>
---
src/egl/drivers/dri2/platform_surfaceless.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c
index f5fe711..3b17e95 100644
--- a/src/egl/drivers/dri2/platform_surfaceless.c
+++ b/src/egl/drivers/dri2/platform_surfaceless.c
@@ -293,6 +293,7 @@ surfaceless_probe_device(_EGLDisplay *dpy, bool swrast)
int fd;
int i;
+ // Attempt to find DRM device.
for (i = 0; i < limit; ++i) {
char *card_path;
if (asprintf(&card_path, DRM_RENDER_DEV_NAME, DRM_DIR_NAME, base + i) < 0)
@@ -327,6 +328,25 @@ surfaceless_probe_device(_EGLDisplay *dpy, 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;
+ }
+
+ if (dri2_load_driver_swrast(dpy)) {
+ dri2_dpy->loader_extensions = swrast_loader_extensions;
+ return true;
+ }
+
+ dri2_dpy->fd = -1;
+ free(dri2_dpy->driver_name);
+ dri2_dpy->driver_name = NULL;
+ }
+
return false;
}
--
2.7.4
More information about the mesa-dev
mailing list