egl/dri: link directly to libglapi.so
authorEmil Velikov <emil.velikov@collabora.com>
Wed, 27 Sep 2017 16:36:29 +0000 (17:36 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 2 Oct 2017 15:26:46 +0000 (16:26 +0100)
Shared glapi (libglapi.so) has been a requirement for years, in order
to build EGL.

Remove the no longer necessary dlopen/dlsym dance and link to the
library directly.

This allows us to remove a handful of platform specific workarounds, due
to the different name of the library.

v2:
 - Android: export the include dir (RobH)
 - Drop unused local variable (Eric)

Cc: Jonathan Gray <jsg@jsg.id.au>
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Cc: Julien Isorce <julien.isorce@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (v1)
Tested-by: Tomasz Figa <tfiga@chromium.org> (v1)
Tested-by: Rob Herring <robh@kernel.org>
src/egl/Android.mk
src/egl/Makefile.am
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/mapi/Android.mk

index d7a6e88918f6fd169807d18099f9ac40a03b318a..2de842ca417205d300e13c487f7323d306daf4ab 100644 (file)
@@ -53,6 +53,7 @@ LOCAL_STATIC_LIBRARIES := \
 
 LOCAL_SHARED_LIBRARIES := \
        libdl \
+       libglapi \
        libhardware \
        liblog \
        libcutils \
index f140f5d641217989da15106e02c032963339371b..eeb745f973a98f253379d16de5fa546d730ed110 100644 (file)
@@ -27,6 +27,7 @@ BUILT_SOURCES =
 
 AM_CFLAGS = \
        -I$(top_srcdir)/include \
+       -I$(top_srcdir)/src/mapi \
        -I$(top_srcdir)/src/egl/main \
        -I$(top_srcdir)/src/gbm/main \
        -I$(top_srcdir)/src \
@@ -45,6 +46,7 @@ libEGL_common_la_SOURCES = \
        $(LIBEGL_C_FILES)
 
 libEGL_common_la_LIBADD = \
+       $(top_builddir)/src/mapi/shared-glapi/libglapi.la \
        $(top_builddir)/src/util/libmesautil.la \
        $(EGL_LIB_DEPS)
 
index adcaae0bab76d59a2735e70e1636b7a68fd81a84..c2b16d117322bb6b39096c1d069d4c6daf1336a1 100644 (file)
@@ -62,6 +62,7 @@
 #include "loader/loader.h"
 #include "util/u_atomic.h"
 #include "util/u_vector.h"
+#include "mapi/glapi/glapi.h"
 
 /* The kernel header drm_fourcc.h defines the DRM formats below.  We duplicate
  * some of the definitions here so that building Mesa won't bleeding-edge
@@ -1564,9 +1565,7 @@ dri2_surface_get_dri_drawable(_EGLSurface *surf)
 static _EGLProc
 dri2_get_proc_address(_EGLDriver *drv, const char *procname)
 {
-   struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
-
-   return dri2_drv->get_proc_address(procname);
+   return _glapi_get_proc_address(procname);
 }
 
 static _EGLSurface*
@@ -3169,7 +3168,6 @@ dri2_unload(_EGLDriver *drv)
 {
    struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
 
-   dlclose(dri2_drv->handle);
    free(dri2_drv);
 }
 
@@ -3177,49 +3175,17 @@ static EGLBoolean
 dri2_load(_EGLDriver *drv)
 {
    struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
-#ifdef HAVE_ANDROID_PLATFORM
-   const char *libname = "libglapi.so";
-#elif defined(__APPLE__)
-   const char *libname = "libglapi.0.dylib";
-#elif defined(__CYGWIN__)
-   const char *libname = "cygglapi-0.dll";
-#else
-   const char *libname = "libglapi.so.0";
-#endif
-   void *handle;
-
-   /* RTLD_GLOBAL to make sure glapi symbols are visible to DRI drivers */
-   handle = dlopen(libname, RTLD_LAZY | RTLD_GLOBAL);
-   if (!handle) {
-      _eglLog(_EGL_WARNING, "DRI2: failed to open glapi provider");
-      goto no_handle;
-   }
-
-   dri2_drv->get_proc_address = (_EGLProc (*)(const char *))
-         dlsym(handle, "_glapi_get_proc_address");
-
-   /* if glapi is not available, loading DRI drivers will fail */
-   if (!dri2_drv->get_proc_address) {
-      _eglLog(_EGL_WARNING, "DRI2: failed to find _glapi_get_proc_address");
-      goto no_symbol;
-   }
 
    dri2_drv->glFlush = (void (*)(void))
-      dri2_drv->get_proc_address("glFlush");
+      _glapi_get_proc_address("glFlush");
 
    /* if glFlush is not available things are horribly broken */
    if (!dri2_drv->glFlush) {
       _eglLog(_EGL_WARNING, "DRI2: failed to find glFlush entry point");
-      goto no_symbol;
+      return EGL_FALSE;
    }
 
-   dri2_drv->handle = handle;
    return EGL_TRUE;
-
-no_symbol:
-   dlclose(handle);
-no_handle:
-   return EGL_FALSE;
 }
 
 /**
index 10a415181720ccd435b7c6f36ca55c485eaf30ee..c70a84bb917f8b68cf762475539090961920ec5f 100644 (file)
@@ -83,8 +83,6 @@ struct dri2_egl_driver
 {
    _EGLDriver base;
 
-   void *handle;
-   _EGLProc (*get_proc_address)(const char *procname);
    void (*glFlush)(void);
 };
 
index 552bab69625b826c9a661b5da17d0cc8f2f38d04..06a764700994df2f51158cd518d03bb2bfb2588e 100644 (file)
@@ -50,6 +50,9 @@ LOCAL_CFLAGS := \
 LOCAL_C_INCLUDES := \
        $(MESA_TOP)/src/mapi
 
+LOCAL_EXPORT_C_INCLUDES := \
+       $(MESA_TOP)/src/mapi
+
 LOCAL_MODULE := libglapi
 
 LOCAL_MODULE_CLASS := SHARED_LIBRARIES