[vlc-devel] [PATCH 5/7] egl_pbuffer: add support for surfaceless context

Rémi Denis-Courmont remi at remlab.net
Wed Mar 3 17:43:42 UTC 2021


Le keskiviikkona 3. maaliskuuta 2021, 19.36.38 EET Romain Vimont a écrit :
> From: Alexandre Janniaux <ajanni at videolabs.io>
> 
> If the EGL extension EGL_KHR_surfaceless_context is available, create a
> surfaceless context.
> 
> Co-authored-by: Romain Vimont <rom1v at videolabs.io>
> ---
>  modules/video_filter/egl_pbuffer.c | 37 ++++++++++++++++++++++++------
>  1 file changed, 30 insertions(+), 7 deletions(-)
> 
> diff --git a/modules/video_filter/egl_pbuffer.c
> b/modules/video_filter/egl_pbuffer.c index 5ede974602..ff4ba946ce 100644
> --- a/modules/video_filter/egl_pbuffer.c
> +++ b/modules/video_filter/egl_pbuffer.c
> @@ -155,7 +155,11 @@ static int InitEGL(vlc_gl_t *gl, unsigned width,
> unsigned height) #endif
>              );
> 
> -    const EGLint conf_attr[] = {
> +    const char *extensions = eglQueryString(sys->display, EGL_EXTENSIONS);
> +    bool need_surface =
> +        !vlc_gl_StrHasToken(extensions, "EGL_KHR_surfaceless_context");
> +
> +    const EGLint conf_attr_surface[] = {
>          EGL_RED_SIZE, 8,
>          EGL_GREEN_SIZE, 8,
>          EGL_BLUE_SIZE, 8,
> @@ -167,6 +171,19 @@ static int InitEGL(vlc_gl_t *gl, unsigned width,
> unsigned height) EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
>          EGL_NONE,
>      };
> +
> +    const EGLint conf_attr_surfaceless[] = {
> +#ifdef USE_OPENGL_ES2
> +        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
> +#else
> +        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
> +#endif
> +        EGL_NONE,
> +    };
> +
> +    const EGLint *conf_attr = need_surface ? conf_attr_surface
> +                                           : conf_attr_surfaceless;

This seems to kind-of assume (incorrectly) that the tables are static.

> +
>      EGLConfig cfgv[1];
>      EGLint cfgc;
> 
> @@ -184,14 +201,20 @@ static int InitEGL(vlc_gl_t *gl, unsigned width,
> unsigned height) goto error;
>      }
> 
> -    /* Create a drawing surface */
> -    sys->surface = eglCreatePbufferSurface(sys->display, cfgv[0],
> surface_attr); -    if (sys->surface == EGL_NO_SURFACE)
> +    if (need_surface)
>      {
> -        msg_Err (gl, "cannot create EGL window surface");
> -        assert(false);
> -        goto error;
> +        /* Create a drawing surface */
> +        sys->surface = eglCreatePbufferSurface(sys->display, cfgv[0],
> +                                               surface_attr);
> +        if (sys->surface == EGL_NO_SURFACE)
> +        {
> +            msg_Err (gl, "cannot create EGL window surface");
> +            assert(false);
> +            goto error;
> +        }
>      }
> +    else
> +        sys->surface = EGL_NO_SURFACE;
> 
>  #ifdef USE_OPENGL_ES2
>      if (eglBindAPI (EGL_OPENGL_ES_API) != EGL_TRUE)


-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the vlc-devel mailing list