[Mesa-dev] [PATCH 6/5] egl/android: continue to next device if dri2_create_screen fails

Emil Velikov emil.l.velikov at gmail.com
Mon Aug 13 17:01:45 UTC 2018


From: Emil Velikov <emil.velikov at collabora.com>

Unlike the other platforms, here we aim do guess if the device that we
somewhat arbitrarily picked, is supported or not.

It seems a bit fiddly, but considering EGL_EXT_explicit_device and
EGL_MESA_query_renderer are MIA, this is the best we can do for the
moment.

With those (proposed) extensions userspace will be able to create a
separate EGL display for each device, query device details and make the
conscious decision which one to use.

Cc: Robert Foss <robert.foss at collabora.com>
Cc: Tomasz Figa <tfiga at chromium.org>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/drivers/dri2/platform_android.c | 29 ++++++++++++++++---------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 50dd7a5e1b4..cac59847b89 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1295,6 +1295,25 @@ droid_open_device(_EGLDisplay *disp)
          continue;
       }
       /* Found a device */
+
+      /* Check that the device is supported, by attempting to:
+       * - load the dri module
+       * - and, create a screen
+       */
+      if (!droid_load_driver(disp)) {
+         _eglLog(_EGL_WARNING, "DRI2: failed to load driver");
+         close(fd);
+         fd = -1;
+         continue;
+      }
+
+      if (!dri2_create_screen(disp)) {
+         _eglLog(_EGL_WARNING, "DRI2: failed to create screen");
+         close(fd);
+         fd = -1;
+         continue;
+      }
+
       break;
    }
    drmFreeDevices(devices, num_devices);
@@ -1346,16 +1365,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
       goto cleanup;
    }
 
-   if (!droid_load_driver(disp)) {
-      err = "DRI2: failed to load driver";
-      goto cleanup;
-   }
-
-   if (!dri2_create_screen(disp)) {
-      err = "DRI2: failed to create screen";
-      goto cleanup;
-   }
-
    if (!dri2_setup_extensions(disp)) {
       err = "DRI2: failed to setup extensions";
       goto cleanup;
-- 
2.18.0



More information about the mesa-dev mailing list