[Mesa-dev] [PATCH] egl/dri: link directly to libglapi.so

Tomasz Figa tfiga at chromium.org
Sat Sep 23 04:37:29 UTC 2017


On Wed, Sep 20, 2017 at 7:47 PM, Eric Engestrom
<eric.engestrom at imgtec.com> wrote:
> On Tuesday, 2017-09-19 17:19:59 +0000, Emil Velikov wrote:
>> From: Emil Velikov <emil.velikov at collabora.com>
>>
>> In order to build EGL, one has to use shared glapi - libglapi.so.
>>
>> Thus the dlopen/dlsym dance is no longer needed and we can link to the
>> library directly.
>>
>> This allows us to remove a handful of platform specific names of the
>> library.
>>
>> Cc: Jonathan Gray <jsg at jsg.id.au>
>> Cc: Jon Turney <jon.turney at dronecode.org.uk>
>> Cc: Julien Isorce <julien.isorce at gmail.com>
>> Cc: Rob Herring <robh at kernel.org>
>> Cc: Tomasz Figa <tfiga at chromium.org>
>> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
>
> Nice cleanup!
> Assuming the build systems stuff works (with Rob's suggested change?):
> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
>
> struct dri2_egl_driver now only contains the glFlush() pointer and
> _EGLDriver.  Could we move the _glapi_get_proc_address() call to
> the two places that use glFlush() (ie. dri2_make_current() and
> dri2_client_wait_sync()), and get rid of this struct, as well as
> the whole dri2_load() function?
>
> I'm happy to do this, just want to check that it would be ok :)

Wouldn't that mean going through the series of strcmp()s over all the
symbols every time EGL wants to call glFlush?

Best regards,
Tomasz

>
>> ---
>>  src/egl/Android.mk              |  2 ++
>>  src/egl/Makefile.am             |  2 ++
>>  src/egl/drivers/dri2/egl_dri2.c | 40 ++++------------------------------------
>>  src/egl/drivers/dri2/egl_dri2.h |  2 --
>>  4 files changed, 8 insertions(+), 38 deletions(-)
>>
>> diff --git a/src/egl/Android.mk b/src/egl/Android.mk
>> index d7a6e88918f..4c112c20be2 100644
>> --- a/src/egl/Android.mk
>> +++ b/src/egl/Android.mk
>> @@ -44,6 +44,7 @@ LOCAL_CFLAGS := \
>>       -DHAVE_ANDROID_PLATFORM
>>
>>  LOCAL_C_INCLUDES := \
>> +     $(MESA_TOP)/src/mapi \
>>       $(MESA_TOP)/src/egl/main \
>>       $(MESA_TOP)/src/egl/drivers/dri2
>>
>> @@ -53,6 +54,7 @@ LOCAL_STATIC_LIBRARIES := \
>>
>>  LOCAL_SHARED_LIBRARIES := \
>>       libdl \
>> +     libglapi \
>>       libhardware \
>>       liblog \
>>       libcutils \
>> diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
>> index 8ff1ffaba18..451b2199c6e 100644
>> --- a/src/egl/Makefile.am
>> +++ b/src/egl/Makefile.am
>> @@ -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)
>>
>> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
>> index 42bca61cfda..c67117212c8 100644
>> --- a/src/egl/drivers/dri2/egl_dri2.c
>> +++ b/src/egl/drivers/dri2/egl_dri2.c
>> @@ -64,6 +64,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
>> @@ -1556,7 +1557,7 @@ 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*
>> @@ -3159,7 +3160,6 @@ dri2_unload(_EGLDriver *drv)
>>  {
>>     struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
>>
>> -   dlclose(dri2_drv->handle);
>>     free(dri2_drv);
>>  }
>>
>> @@ -3167,49 +3167,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;
>>  }
>>
>>  /**
>> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
>> index 10a41518172..c70a84bb917 100644
>> --- a/src/egl/drivers/dri2/egl_dri2.h
>> +++ b/src/egl/drivers/dri2/egl_dri2.h
>> @@ -83,8 +83,6 @@ struct dri2_egl_driver
>>  {
>>     _EGLDriver base;
>>
>> -   void *handle;
>> -   _EGLProc (*get_proc_address)(const char *procname);
>>     void (*glFlush)(void);
>>  };
>>
>> --
>> 2.14.1
>>


More information about the mesa-dev mailing list