[vlc-devel] [RFC PATCH] opengl: vaapi: add a way to get the X11 display
Thomas Guillem
thomas at gllm.fr
Wed Jun 21 10:20:58 CEST 2017
On Wed, Jun 21, 2017, at 09:46, Thomas Guillem wrote:
>
>
>
> On Wed, Jun 21, 2017, at 09:31, Rémi Denis-Courmont wrote:
>> Le 21 juin 2017 10:19:05 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a
>> écrit :>>> I forgot to fix the TODO (ugly way to get the X11 Display via
>>> EGL) in
>>>>>>
>>>
>>>
>>> converter_vaapi.c before pushing it.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> I think, there are 3 ways to fix this issues:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> - What I do in this patch: get the same X11 display that is created
>>> by x11_egl.
>>>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> - Just do an other XOpenDisplay(wnd->display.x11) from
>>> converter_vaapi.c. I
>>>>>>
>>>
>>>
>>> guess this will safely use the same dpy instance created by
>>> x11_egl, no ?
>>>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> - have x11_egl saving the X11 dpy in the wmd->display struct
>>>
>>>
>>>
>>>
>>> ---
>>>
>>>
>>>
>>>
>>> include/vlc_opengl.h | 6 ++++++
>>>
>>>
>>>
>>>
>>> modules/video_output/opengl/converter_vaapi.c | 13 +++----------
>>>>>>
>>>
>>>
>>> modules/video_output/opengl/egl.c | 11 +++++++++++
>>>>>>
>>>
>>>
>>> 3 files changed, 20 insertions(+), 10 deletions(-)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
>>>
>>>
>>>
>>>
>>> index 6642f78554..d536d271d7 100644
>>>
>>>
>>>
>>>
>>> --- a/include/vlc_opengl.h
>>>
>>>
>>>
>>>
>>> +++ b/include/vlc_opengl.h
>>>
>>>
>>>
>>>
>>> @@ -50,6 +50,7 @@ struct vlc_gl_t
>>>
>>>
>>>
>>>
>>> void (*resize)(vlc_gl_t *, unsigned, unsigned);
>>>
>>>
>>>
>>>
>>> void (*swap)(vlc_gl_t *);
>>>
>>>
>>>
>>>
>>> void*(*getProcAddress)(vlc_gl_t *, const char *);
>>>
>>>
>>>
>>>
>>> + void*(*getNativeDpy)(vlc_gl_t *);
>>>
>>>
>>>
>>>
>>> };
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> enum {
>>>
>>>
>>>
>>>
>>> @@ -86,6 +87,11 @@ static inline void
>>> *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
>>>>>>
>>>
>>>
>>> return (gl->getProcAddress != NULL) ? gl->getProcAddress(gl,
>>> name) : NULL;
>>>>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> +static inline void *vlc_gl_GetNativeDpy(vlc_gl_t *gl)
>>>
>>>
>>>
>>>
>>> +{
>>>
>>>
>>>
>>>
>>> + return gl->getNativeDpy != NULL ? gl->getNativeDpy(gl) : NULL;
>>>>>>
>>>
>>>
>>> +}
>>>
>>>
>>>
>>>
>>> +
>>>
>>>
>>>
>>>
>>> VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
>>>
>>>
>>>
>>>
>>> const struct
>>> vout_window_cfg_t *,
>>>>>>
>>>
>>>
>>> struct vout_window_t **)
>>> VLC_USED;
>>>>>>
>>>
>>>
>>> diff --git a/modules/video_output/opengl/converter_vaapi.c
>>> b/modules/video_output/opengl/converter_vaapi.c
>>>>>>
>>>
>>>
>>> index 7c9f9947b6..4096f072dd 100644
>>>
>>>
>>>
>>>
>>> --- a/modules/video_output/opengl/converter_vaapi.c
>>>
>>>
>>>
>>>
>>> +++ b/modules/video_output/opengl/converter_vaapi.c
>>>
>>>
>>>
>>>
>>> @@ -38,14 +38,6 @@
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> #ifdef HAVE_VA_X11
>>>
>>>
>>>
>>>
>>> # include <va/va_x11.h>
>>>
>>>
>>>
>>>
>>> -/* TODO ugly way to get the X11 Display via EGL. */
>>>
>>>
>>>
>>>
>>> -struct vlc_gl_sys_t
>>>
>>>
>>>
>>>
>>> -{
>>>
>>>
>>>
>>>
>>> - EGLDisplay display;
>>>
>>>
>>>
>>>
>>> - EGLSurface surface;
>>>
>>>
>>>
>>>
>>> - EGLContext context;
>>>
>>>
>>>
>>>
>>> - Display *x11;
>>>
>>>
>>>
>>>
>>> -};
>>>
>>>
>>>
>>>
>>> #endif
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> struct priv
>>>
>>>
>>>
>>>
>>> @@ -315,8 +307,9 @@ opengl_tex_converter_vaapi_init(video_format_t
>>> *fmt, opengl_tex_converter_t *tc)
>>>>>>
>>>
>>>
>>> #ifdef HAVE_VA_X11
>>>
>>>
>>>
>>>
>>> case VOUT_WINDOW_TYPE_XID:
>>>
>>>
>>>
>>>
>>> {
>>>
>>>
>>>
>>>
>>> - struct vlc_gl_sys_t *glsys = tc->gl->sys;
>>>
>>>
>>>
>>>
>>> - fshader = tc_vaegl_init(fmt, tc, priv, vaGetDisplay(glsys-
>>> >x11));
>>>>>>
>>>
>>>
>>> + void *x11_dpy = vlc_gl_GetNativeDpy(tc->gl);
>>>
>>>
>>>
>>>
>>> + if (x11_dpy != NULL)
>>>
>>>
>>>
>>>
>>> + fshader = tc_vaegl_init(fmt, tc, priv,
>>> vaGetDisplay(x11_dpy));
>>>>>>
>>>
>>>
>>> break;
>>>
>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>>
>>> #endif
>>>
>>>
>>>
>>>
>>> diff --git a/modules/video_output/opengl/egl.c
>>> b/modules/video_output/opengl/egl.c
>>>>>>
>>>
>>>
>>> index 22cf3545c9..ccb4891640 100644
>>>
>>>
>>>
>>>
>>> --- a/modules/video_output/opengl/egl.c
>>>
>>>
>>>
>>>
>>> +++ b/modules/video_output/opengl/egl.c
>>>
>>>
>>>
>>>
>>> @@ -103,6 +103,14 @@ static void *GetSymbol(vlc_gl_t *gl, const char
>>> *procname)
>>>>>>
>>>
>>>
>>> return (void *)eglGetProcAddress (procname);
>>>
>>>
>>>
>>>
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> +#if defined (USE_PLATFORM_X11)
>>>
>>>
>>>
>>>
>>> +static void *GetNativeDpy(vlc_gl_t *gl)
>>>
>>>
>>>
>>>
>>> +{
>>>
>>>
>>>
>>>
>>> + vlc_gl_sys_t *sys = gl->sys;
>>>
>>>
>>>
>>>
>>> + return sys->x11;
>>>
>>>
>>>
>>>
>>> +}
>>>
>>>
>>>
>>>
>>> +#endif
>>>
>>>
>>>
>>>
>>> +
>>>
>>>
>>>
>>>
>>> static bool CheckToken(const char *haystack, const char *needle)
>>>>>>
>>>
>>>
>>> {
>>>
>>>
>>>
>>>
>>> size_t len = strlen(needle);
>>>
>>>
>>>
>>>
>>> @@ -371,6 +379,9 @@ static int Open (vlc_object_t *obj, const struct
>>> gl_api *api)
>>>>>>
>>>
>>>
>>> gl->resize = Resize;
>>>
>>>
>>>
>>>
>>> gl->swap = SwapBuffers;
>>>
>>>
>>>
>>>
>>> gl->getProcAddress = GetSymbol;
>>>
>>>
>>>
>>>
>>> +#if defined (USE_PLATFORM_X11)
>>>
>>>
>>>
>>>
>>> + gl->getNativeDpy = GetNativeDpy;
>>>
>>>
>>>
>>>
>>> +#endif
>>>
>>>
>>>
>>>
>>> return VLC_SUCCESS;
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> error:
>>>
>>>
>>>
>>>
>>
>> GL does not know what backend it runs on (GLX, EGL/X11, EGL/Wayland,
>> maybe EGL/GBM soon) so it does not know the type of the native
>> display pointer (if that even means anything). So I don't really see
>> how that would work.>
> In my first version I added an enum in vlc_gt_t:
> enum {
> GL_EXT_CUSTOM,
> GL_EXT_EGL,
> GL_EXT_GLX,
> } ext;
>
> But I think the 2nd solution is the best (call XOpenDisplay)
Finally, I prefer the 3rd solution (patches incoming). We have to link
with X11 libs if I choose the 2nd solution.
>
>> --
>> Rémi Denis-Courmont
>> Typed on an inconvenient virtual keyboard
>> _________________________________________________
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170621/1162a438/attachment.html>
More information about the vlc-devel
mailing list