[vlc-devel] [PATCH 1/2] egl: Import GLES symbols with a direct library dlopen

Thomas Guillem thomas at gllm.fr
Tue May 22 16:43:48 CEST 2018


On Tue, May 22, 2018, at 16:41, Paul Kocialkowski wrote:
> Hi,
> 
> On Tue, 2018-05-22 at 16:40 +0200, Thomas Guillem wrote:
> > Hi,
> > 
> > On Tue, May 22, 2018, at 16:32, Paul Kocialkowski wrote:
> > > It appears that some EGL blobs (usually used with GLES) don't expose all
> > > the required core GLES API functions through eglGetProcAddress.
> > > 
> > > Resort to mapping these symbols using dlopen directly instead.
> > > 
> > > Signed-off-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
> > > ---
> > >  modules/video_output/opengl/egl.c | 28 ++++++++++++++++++++++++++--
> > >  1 file changed, 26 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/
> > > opengl/egl.c
> > > index 9162675447..0477be5474 100644
> > > --- a/modules/video_output/opengl/egl.c
> > > +++ b/modules/video_output/opengl/egl.c
> > > @@ -26,6 +26,7 @@
> > >  
> > >  #include <stdlib.h>
> > >  #include <assert.h>
> > > +#include <dlfcn.h>
> > >  #include <EGL/egl.h>
> > >  #include <EGL/eglext.h>
> > >  
> > > @@ -43,6 +44,8 @@
> > >  # include "../android/utils.h"
> > >  #endif
> > >  
> > > +#define LIBGLESv2_DL_NAME "libGLESv2.so.2"
> > > +
> > >  typedef struct vlc_gl_sys_t
> > >  {
> > >      EGLDisplay display;
> > > @@ -57,6 +60,8 @@ typedef struct vlc_gl_sys_t
> > >  #endif
> > >      PFNEGLCREATEIMAGEKHRPROC    eglCreateImageKHR;
> > >      PFNEGLDESTROYIMAGEKHRPROC   eglDestroyImageKHR;
> > > +    bool is_gles;
> > > +    void *gles_handle;
> > >  } vlc_gl_sys_t;
> > >  
> > >  static int MakeCurrent (vlc_gl_t *gl)
> > > @@ -101,8 +106,12 @@ static void SwapBuffers (vlc_gl_t *gl)
> > >  
> > >  static void *GetSymbol(vlc_gl_t *gl, const char *procname)
> > >  {
> > > -    (void) gl;
> > > -    return (void *)eglGetProcAddress (procname);
> > > +    vlc_gl_sys_t *sys = gl->sys;
> > > +
> > > +    if (sys->is_gles)
> > > +        return dlsym(sys->gles_handle, procname);
> > > +    else
> > > +        return (void *)eglGetProcAddress (procname);
> > >  }
> > >  
> > >  static const char *QueryString(vlc_gl_t *gl, int32_t name)
> > > @@ -220,6 +229,10 @@ static void Close (vlc_object_t *obj)
> > >      AWindowHandler_releaseANativeWindow(gl->surface->handle.anativewindow,
> > >                                          AWindow_Video);
> > >  #endif
> > > +
> > > +    if (sys->is_gles && sys->gles_handle != NULL)
> > > +        dlclose(sys->gles_handle);
> > > +
> > >      free (sys);
> > >  }
> > >  
> > > @@ -238,6 +251,8 @@ static int Open (vlc_object_t *obj, const struct 
> > > gl_api *api)
> > >      sys->surface = EGL_NO_SURFACE;
> > >      sys->eglCreateImageKHR = NULL;
> > >      sys->eglDestroyImageKHR = NULL;
> > > +    sys->is_gles = api->api == EGL_OPENGL_ES_API;
> > 
> > You should set the gl->getProcAddress pointer to a different function (like GLesGetSymbol) instead of using this new is_gles boolean.
> 
> Noted! Is a suffix instead of a prefix fine as well? I was thinking of
> something like GetSymbolGLES.

Fine with me.

You should also add $(LIBDL) to all egl plugins _LIBADD in modules/video_output/Makefile.am

> 
> Thanks for the review !
> 
> Cheers,
> 
> Paul
> 
> > > +    sys->gles_handle = NULL;
> > >  
> > >      vout_window_t *wnd = gl->surface;
> > >      EGLSurface (*createSurface)(EGLDisplay, EGLConfig, void *, const 
> > > EGLint *)
> > > @@ -392,6 +407,15 @@ static int Open (vlc_object_t *obj, const struct 
> > > gl_api *api)
> > >      }
> > >      sys->context = ctx;
> > >  
> > > +    if (sys->is_gles) {
> > > +        sys->gles_handle = dlopen(LIBGLESv2_DL_NAME, RTLD_NOW);
> > > +	if (sys->gles_handle == NULL)
> > > +        {
> > > +            msg_Err (obj, "cannot get GLES library handle from dlopen");
> > > +            goto error;
> > > +        }
> > > +    }
> > > +
> > >      /* Initialize OpenGL callbacks */
> > >      gl->ext = VLC_GL_EXT_EGL;
> > >      gl->makeCurrent = MakeCurrent;
> > > -- 
> > > 2.17.0
> > > 
> > > _______________________________________________
> > > vlc-devel mailing list
> > > To unsubscribe or modify your subscription options:
> > > https://mailman.videolan.org/listinfo/vlc-devel
> > 
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> -- 
> Paul Kocialkowski, Bootlin (formerly Free Electrons)
> Embedded Linux and kernel engineering
> https://bootlin.com
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> Email had 1 attachment:
> + signature.asc
>   1k (application/pgp-signature)


More information about the vlc-devel mailing list