OSDN Git Service

Revert "egl: move alloc & init out of _eglBuiltInDriver{DRI2,Haiku}"
authorMarek Olšák <marek.olsak@amd.com>
Wed, 18 Oct 2017 18:23:00 +0000 (20:23 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 18 Oct 2017 18:23:42 +0000 (20:23 +0200)
This reverts commit 8cb84c8477a57ed05d703669fee1770f31b76ae6.

This fixes crashing shader-db/run.

src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/haiku/egl_haiku.cpp
src/egl/main/README.txt
src/egl/main/egldriver.c
src/egl/main/egldriver.h

index 0750dc1..d7a88b2 100644 (file)
@@ -3191,11 +3191,16 @@ dri2_interop_export_object(_EGLDisplay *dpy, _EGLContext *ctx,
 
 /**
  * This is the main entrypoint into the driver, called by libEGL.
- * Gets an _EGLDriver object and init its dispatch table.
+ * Create a new _EGLDriver object and init its dispatch table.
  */
-void
-_eglInitDriver(_EGLDriver *dri2_drv)
+_EGLDriver *
+_eglBuiltInDriver(void)
 {
+   _EGLDriver *dri2_drv = calloc(1, sizeof *dri2_drv);
+   if (!dri2_drv)
+      return NULL;
+
+   _eglInitDriverFallbacks(dri2_drv);
    dri2_drv->API.Initialize = dri2_initialize;
    dri2_drv->API.Terminate = dri2_terminate;
    dri2_drv->API.CreateContext = dri2_create_context;
@@ -3246,4 +3251,6 @@ _eglInitDriver(_EGLDriver *dri2_drv)
    dri2_drv->API.DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
 
    dri2_drv->Name = "DRI2";
+
+   return dri2_drv;
 }
index 590e43f..237cebf 100644 (file)
@@ -305,14 +305,21 @@ haiku_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
 
 /**
  * This is the main entrypoint into the driver, called by libEGL.
- * Gets an _EGLDriver object and init its dispatch table.
+ * Create a new _EGLDriver object and init its dispatch table.
  */
 extern "C"
-void
-_eglInitDriver(_EGLDriver *driver)
+_EGLDriver*
+_eglBuiltInDriver(void)
 {
        CALLED();
 
+       _EGLDriver* driver = calloc(1, sizeof(*driver));
+       if (!driver) {
+               _eglError(EGL_BAD_ALLOC, "_eglBuiltInDriverHaiku");
+               return NULL;
+       }
+
+       _eglInitDriverFallbacks(driver);
        driver->API.Initialize = init_haiku;
        driver->API.Terminate = haiku_terminate;
        driver->API.CreateContext = haiku_create_context;
@@ -328,4 +335,6 @@ _eglInitDriver(_EGLDriver *driver)
        driver->Name = "Haiku";
 
        TRACE("API Calls defined\n");
+
+       return driver;
 }
index 9b5fd41..1af9959 100644 (file)
@@ -19,12 +19,13 @@ Bootstrapping:
 When the apps calls eglInitialize() a device driver is selected and loaded
 (look for _eglAddDrivers() and _eglLoadModule() in egldriver.c).
 
-The built-in driver's entry point function is then called and given
-a freshly allocated and initialised _EGLDriver, with default fallback
-entrypoints set.
+The built-in driver's entry point function is then called.  This driver function
+allocates, initializes and returns a new _EGLDriver object (usually a
+subclass of that type).
 
 As part of initialization, the dispatch table in _EGLDriver->API must be
-populated with all the EGL entrypoints. Some functions like
+populated with all the EGL entrypoints.  Typically, _eglInitDriverFallbacks()
+can be used to plug in default/fallback functions.  Some functions like
 driver->API.Initialize and driver->API.Terminate _must_ be implemented
 with driver-specific code (no default/fallback function is possible).
 
index 9d77cb6..34a90ae 100644 (file)
@@ -54,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);
 
index ba12a06..6ab667c 100644 (file)
@@ -81,8 +81,8 @@ struct _egl_driver
 };
 
 
-extern void
-_eglInitDriver(_EGLDriver *driver);
+extern _EGLDriver*
+_eglBuiltInDriver(void);
 
 
 extern _EGLDriver *