egl: Mention if swrast is being forced
[mesa.git] / src / egl / main / egldriver.c
index ee3dc86e388512c291b0ccce27483fb71e66740c..526de02e53b66dc26eff6400533ad1c84008ac8a 100644 (file)
@@ -54,8 +54,14 @@ _eglGetDriver(void)
 {
    mtx_lock(&_eglModuleMutex);
 
 {
    mtx_lock(&_eglModuleMutex);
 
-   if (!_eglDriver)
-      _eglDriver = _eglBuiltInDriver();
+   if (!_eglDriver) {
+      _eglDriver = calloc(1, sizeof(*_eglDriver));
+      if (!_eglDriver) {
+         mtx_unlock(&_eglModuleMutex);
+         return NULL;
+      }
+      _eglInitDriver(_eglDriver);
+   }
 
    mtx_unlock(&_eglModuleMutex);
 
 
    mtx_unlock(&_eglModuleMutex);
 
@@ -63,10 +69,10 @@ _eglGetDriver(void)
 }
 
 static _EGLDriver *
 }
 
 static _EGLDriver *
-_eglMatchAndInitialize(_EGLDisplay *dpy)
+_eglMatchAndInitialize(_EGLDisplay *disp)
 {
    if (_eglGetDriver())
 {
    if (_eglGetDriver())
-      if (_eglDriver->API.Initialize(_eglDriver, dpy))
+      if (_eglDriver->API.Initialize(_eglDriver, disp))
          return _eglDriver;
 
    return NULL;
          return _eglDriver;
 
    return NULL;
@@ -77,27 +83,27 @@ _eglMatchAndInitialize(_EGLDisplay *dpy)
  * driver that can initialize the display.
  */
 _EGLDriver *
  * driver that can initialize the display.
  */
 _EGLDriver *
-_eglMatchDriver(_EGLDisplay *dpy)
+_eglMatchDriver(_EGLDisplay *disp)
 {
    _EGLDriver *best_drv;
 
 {
    _EGLDriver *best_drv;
 
-   assert(!dpy->Initialized);
+   assert(!disp->Initialized);
 
    /* set options */
 
    /* set options */
-   dpy->Options.ForceSoftware =
+   disp->Options.ForceSoftware =
       env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
       env_var_as_boolean("LIBGL_ALWAYS_SOFTWARE", false);
+   if (disp->Options.ForceSoftware)
+      _eglLog(_EGL_DEBUG, "Found 'LIBGL_ALWAYS_SOFTWARE' set, will use a CPU renderer");
 
 
-   best_drv = _eglMatchAndInitialize(dpy);
-   if (!best_drv) {
-      dpy->Options.ForceSoftware = EGL_TRUE;
-      best_drv = _eglMatchAndInitialize(dpy);
+   best_drv = _eglMatchAndInitialize(disp);
+   if (!best_drv && !disp->Options.ForceSoftware) {
+      disp->Options.ForceSoftware = EGL_TRUE;
+      best_drv = _eglMatchAndInitialize(disp);
    }
 
    if (best_drv) {
    }
 
    if (best_drv) {
-      _eglLog(_EGL_DEBUG, "the best driver is %s",
-            best_drv->Name);
-      dpy->Driver = best_drv;
-      dpy->Initialized = EGL_TRUE;
+      disp->Driver = best_drv;
+      disp->Initialized = EGL_TRUE;
    }
 
    return best_drv;
    }
 
    return best_drv;
@@ -106,7 +112,7 @@ _eglMatchDriver(_EGLDisplay *dpy)
 __eglMustCastToProperFunctionPointerType
 _eglGetDriverProc(const char *procname)
 {
 __eglMustCastToProperFunctionPointerType
 _eglGetDriverProc(const char *procname)
 {
-   if (_eglGetDriver())
+   if (_eglGetDriver() && _eglDriver->API.GetProcAddress)
       return _eglDriver->API.GetProcAddress(_eglDriver, procname);
 
    return NULL;
       return _eglDriver->API.GetProcAddress(_eglDriver, procname);
 
    return NULL;