egl/android: rework device probing
[mesa.git] / src / egl / main / egldriver.c
index 33f8f57aeb11e06f92f2c5623207f1cd2289850b..218b3daef25bf476c601d074183178cb835c647d 100644 (file)
@@ -44,6 +44,8 @@
 #include "egldriver.h"
 #include "egllog.h"
 
+#include "util/debug.h"
+
 static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP;
 static _EGLDriver *_eglDriver;
 
@@ -52,12 +54,8 @@ _eglGetDriver(void)
 {
    mtx_lock(&_eglModuleMutex);
 
-   if (!_eglDriver) {
-      _eglDriver = calloc(1, sizeof(*_eglDriver));
-      if (!_eglDriver)
-         return NULL;
-      _eglInitDriver(_eglDriver);
-   }
+   if (!_eglDriver)
+      _eglDriver = _eglBuiltInDriver();
 
    mtx_unlock(&_eglModuleMutex);
 
@@ -86,15 +84,18 @@ _eglMatchDriver(_EGLDisplay *dpy)
    assert(!dpy->Initialized);
 
    /* set options */
-   dpy->Options.UseFallback = EGL_FALSE;
+   dpy->Options.ForceSoftware =
+      env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
 
    best_drv = _eglMatchAndInitialize(dpy);
-   if (!best_drv) {
-      dpy->Options.UseFallback = EGL_TRUE;
+   if (!best_drv && !dpy->Options.ForceSoftware) {
+      dpy->Options.ForceSoftware = EGL_TRUE;
       best_drv = _eglMatchAndInitialize(dpy);
    }
 
    if (best_drv) {
+      _eglLog(_EGL_DEBUG, "the best driver is %s",
+            best_drv->Name);
       dpy->Driver = best_drv;
       dpy->Initialized = EGL_TRUE;
    }