summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c4
-rw-r--r--src/egl/drivers/glx/egl_glx.c3
-rw-r--r--src/egl/main/egldisplay.h5
-rw-r--r--src/egl/main/egldriver.c121
-rw-r--r--src/egl/main/egldriver.h12
5 files changed, 61 insertions, 84 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f6bca4abf72..2e827f4f3e5 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1472,10 +1472,14 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
{
switch (disp->Platform) {
case _EGL_PLATFORM_X11:
+ if (disp->Options.TestOnly)
+ return EGL_TRUE;
return dri2_initialize_x11(drv, disp);
#ifdef HAVE_LIBUDEV
case _EGL_PLATFORM_DRM:
+ if (disp->Options.TestOnly)
+ return EGL_TRUE;
return dri2_initialize_drm(drv, disp);
#endif
diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index 84b04f7967e..aecebae40c2 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -589,6 +589,9 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp)
if (disp->Platform != _EGL_PLATFORM_X11)
return EGL_FALSE;
+ if (disp->Options.TestOnly)
+ return EGL_TRUE;
+
GLX_dpy = CALLOC_STRUCT(GLX_egl_display);
if (!GLX_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index faeb2906478..b42760befab 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -90,6 +90,11 @@ struct _egl_display
_EGLDriver *Driver; /**< Matched driver of the display */
EGLBoolean Initialized; /**< True if the display is initialized */
+ /* options that affect how the driver initializes the display */
+ struct {
+ EGLBoolean TestOnly; /**< Driver should not set fields when true */
+ } Options;
+
/* these fields are set by the driver during init */
void *DriverData; /**< Driver private data */
EGLint VersionMajor; /**< EGL major version */
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 1ae030db448..7baa24fbf86 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -525,100 +525,75 @@ _eglAddDrivers(void)
/**
- * Match a display to a driver. The display is initialized unless use_probe is
- * true.
- *
- * The matching is done by finding the first driver that can initialize the
- * display, or when use_probe is true, the driver with highest score.
+ * A helper function for _eglMatchDriver. It finds the first driver that can
+ * initialize the display and return.
*/
-_EGLDriver *
-_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe)
+static _EGLDriver *
+_eglMatchAndInitialize(_EGLDisplay *dpy)
{
- _EGLModule *mod;
- _EGLDriver *best_drv = NULL;
- EGLint best_score = 0;
- EGLint i;
-
- _eglLockMutex(&_eglModuleMutex);
+ _EGLDriver *drv = NULL;
+ EGLint i = 0;
if (!_eglAddDrivers()) {
- _eglUnlockMutex(&_eglModuleMutex);
_eglLog(_EGL_WARNING, "failed to find any driver");
- return EGL_FALSE;
+ return NULL;
}
- /* match the loaded modules */
- for (i = 0; i < _eglModules->Size; i++) {
- mod = (_EGLModule *) _eglModules->Elements[i];
- if (!mod->Driver)
- break;
+ if (dpy->Driver) {
+ drv = dpy->Driver;
+ /* no re-matching? */
+ if (!drv->API.Initialize(drv, dpy))
+ drv = NULL;
+ return drv;
+ }
- if (use_probe) {
- EGLint score = (mod->Driver->Probe) ?
- mod->Driver->Probe(mod->Driver, dpy) : 1;
- if (score > best_score) {
- best_drv = mod->Driver;
- best_score = score;
- }
+ while (i < _eglModules->Size) {
+ _EGLModule *mod = (_EGLModule *) _eglModules->Elements[i];
+
+ if (!_eglLoadModule(mod)) {
+ /* remove invalid modules */
+ _eglEraseArray(_eglModules, i, _eglFreeModule);
+ continue;
+ }
+
+ if (mod->Driver->API.Initialize(mod->Driver, dpy)) {
+ drv = mod->Driver;
+ break;
}
else {
- if (mod->Driver->API.Initialize(mod->Driver, dpy)) {
- best_drv = mod->Driver;
- best_score = 100;
- }
+ i++;
}
- /* perfect match */
- if (best_score >= 100)
- break;
}
- /* load more modules */
- if (!best_drv) {
- EGLint first_unloaded = i;
+ return drv;
+}
- while (i < _eglModules->Size) {
- mod = (_EGLModule *) _eglModules->Elements[i];
- assert(!mod->Driver);
- if (!_eglLoadModule(mod)) {
- /* remove invalid modules */
- _eglEraseArray(_eglModules, i, _eglFreeModule);
- continue;
- }
+/**
+ * Match a display to a driver. The display is initialized unless test_only is
+ * true. The matching is done by finding the first driver that can initialize
+ * the display.
+ */
+_EGLDriver *
+_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only)
+{
+ _EGLDriver *best_drv;
- if (use_probe) {
- best_score = (mod->Driver->Probe) ?
- mod->Driver->Probe(mod->Driver, dpy) : 1;
- }
- else {
- if (mod->Driver->API.Initialize(mod->Driver, dpy))
- best_score = 100;
- }
+ assert(!dpy->Initialized);
- if (best_score > 0) {
- best_drv = mod->Driver;
- /* loaded modules come before unloaded ones */
- if (first_unloaded != i) {
- void *tmp = _eglModules->Elements[i];
- _eglModules->Elements[i] =
- _eglModules->Elements[first_unloaded];
- _eglModules->Elements[first_unloaded] = tmp;
- }
- break;
- }
- else {
- _eglUnloadModule(mod);
- i++;
- }
- }
- }
+ _eglLockMutex(&_eglModuleMutex);
+
+ /* set options */
+ dpy->Options.TestOnly = test_only;
+
+ best_drv = _eglMatchAndInitialize(dpy);
_eglUnlockMutex(&_eglModuleMutex);
if (best_drv) {
- _eglLog(_EGL_DEBUG, "the best driver is %s (score %d)",
- best_drv->Name, best_score);
- if (!use_probe) {
+ _eglLog(_EGL_DEBUG, "the best driver is %s%s",
+ best_drv->Name, (test_only) ? " (test only) " : "");
+ if (!test_only) {
dpy->Driver = best_drv;
dpy->Initialized = EGL_TRUE;
}
diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
index d6177579193..3cde102d12d 100644
--- a/src/egl/main/egldriver.h
+++ b/src/egl/main/egldriver.h
@@ -44,16 +44,6 @@ struct _egl_driver
const char *Name; /**< name of this driver */
/**
- * Probe a display and return a score.
- *
- * Roughly,
- * 50 means the driver supports the display;
- * 90 means the driver can accelerate the display;
- * 100 means a perfect match.
- */
- EGLint (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy);
-
- /**
* Release the driver resource.
*
* It is called before dlclose().
@@ -81,7 +71,7 @@ _eglMain(const char *args);
extern _EGLDriver *
-_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean probe_only);
+_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only);
extern __eglMustCastToProperFunctionPointerType