[vlc-devel] [PATCH v2 2/2] opengl: split into convenience library
Rémi Denis-Courmont
remi at remlab.net
Fri Jun 26 16:07:10 CEST 2020
Le perjantaina 26. kesäkuuta 2020, 11.56.07 EEST Alexandre Janniaux a écrit :
> Create a libvlc_opengl and libvlc_opengles library that are built only
> if one other target is needing it, avoiding to compile the OpenGL code
> once per module using it and removing the need for OPENGL_COMMON* vars.
>
> As the fact we're using OpenGL or OpenGL ES is defined at compile time,
> the clients must use the correct variant depending on what they use.
>
> In addition, this patch refactor the glesv2 detection in order to
> enable both the gles2 display plugin and the libvlc_opengles.la target
> which must not be built on Windows target for example.
> ---
> configure.ac | 9 ++++-
> modules/video_output/Makefile.am | 24 ++++++-------
> modules/video_output/opengl/Makefile.am | 46 ++++++++++++++++++++-----
> 3 files changed, 58 insertions(+), 21 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index e6fb7da932c..77397617831 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3311,7 +3311,14 @@ AS_IF([test "${have_gl}" = "yes"], [
> ])
>
> dnl OpenGL ES 2: depends on EGL 1.1
> -PKG_ENABLE_MODULES_VLC([GLES2], [], [glesv2], [OpenGL ES v2 support],
> [disabled]) +have_gles2="no"
> +AC_ARG_ENABLE(gles2,
> + [AS_HELP_STRING([--enable-gles2],
> + [enable GLES2 support (default disabled)])])
> +AS_IF([test "$enable_gles2" = "yes"], [
> + PKG_CHECK_MODULES([GLES2], [glesv2], [have_gles2="yes"], [])
> + ])
> +AM_CONDITIONAL([HAVE_GLES2], [test "${have_gles2}" = "yes"])
>
> dnl
> dnl Vulkan
> diff --git a/modules/video_output/Makefile.am
> b/modules/video_output/Makefile.am index 33d7d91cbb1..3b9d0fae122 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -27,15 +27,15 @@ libglinterop_cvpx_plugin_la_LDFLAGS = $(AM_LDFLAGS)
> -rpath '$(voutdir)' \ -Wl,-framework,Foundation,-framework,CoreVideo
>
> if HAVE_OSX
> -libvout_macosx_plugin_la_SOURCES = video_output/macosx.m
> $(OPENGL_COMMONSOURCES) -libvout_macosx_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(OPENGL_COMMONCFLAGS) -DHAVE_GL_CORE_SYMBOLS
> -libvout_macosx_plugin_la_LIBADD = $(OPENGL_COMMONLIBS)
> +libvout_macosx_plugin_la_SOURCES = video_output/macosx.m
> +libvout_macosx_plugin_la_CFLAGS = $(AM_CFLAGS) -DHAVE_GL_CORE_SYMBOLS
> +libvout_macosx_plugin_la_LIBADD = libvlc_opengl.la
> libvout_macosx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
> -Wl,-framework,OpenGL,-framework,Cocoa
>
> -libcaopengllayer_plugin_la_SOURCES = video_output/caopengllayer.m
> $(OPENGL_COMMONSOURCES) -libcaopengllayer_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(OPENGL_COMMONCFLAGS) -DHAVE_GL_CORE_SYMBOLS
> -libcaopengllayer_plugin_la_LIBADD = $(OPENGL_COMMONLIBS)
> +libcaopengllayer_plugin_la_SOURCES = video_output/caopengllayer.m
> +libcaopengllayer_plugin_la_CFLAGS = $(AM_CFLAGS) -DHAVE_GL_CORE_SYMBOLS
> +libcaopengllayer_plugin_la_LIBADD = libvlc_opengl.la
> libcaopengllayer_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
> -Wl,-framework,OpenGL,-framework,Cocoa,-framework,QuartzCore
>
> @@ -47,9 +47,9 @@ if HAVE_IOS
> libglinterop_cvpx_plugin_la_CFLAGS = $(AM_CFLAGS) -DUSE_OPENGL_ES2
> endif
>
> -libvout_ios_plugin_la_SOURCES = video_output/ios.m $(OPENGL_COMMONSOURCES)
> +libvout_ios_plugin_la_SOURCES = video_output/ios.m
> libvout_ios_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCFLAGS)
> -DUSE_OPENGL_ES2 -libvout_ios_plugin_la_LIBADD = $(OPENGL_COMMONLIBS)
> +libvout_ios_plugin_la_LIBADD = libvlc_opengles.la
> libvout_ios_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
> -Wl,-framework,Foundation,-framework,OpenGLES,-
framework,QuartzCore,-frame
> work,UIKit if HAVE_IOS
> @@ -114,19 +114,19 @@ libdirect3d11_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath
> '$(voutdir)' vout_LTLIBRARIES += $(LTLIBdirect3d11)
> EXTRA_LTLIBRARIES += libdirect3d11_plugin.la
>
> -libglwin32_plugin_la_SOURCES = $(OPENGL_COMMONSOURCES) \
> +libglwin32_plugin_la_SOURCES = \
> video_output/win32/glwin32.c \
> video_output/win32/common.c video_output/win32/common.h \
> video_output/win32/events.c video_output/win32/events.h \
> video_output/win32/sensors.cpp \
> video_output/win32/win32touch.c video_output/win32/win32touch.h
> -libwgl_plugin_la_SOURCES = video_output/win32/wgl.c $(OPENGL_COMMONSOURCES)
> +libwgl_plugin_la_SOURCES = video_output/win32/wgl.c
>
> libglwin32_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
> -DMODULE_NAME_IS_glwin32
>
> -libglwin32_plugin_la_LIBADD = libchroma_copy.la -lopengl32 -lgdi32
> $(LIBCOM) -luuid $(OPENGL_COMMONLIBS) -libwgl_plugin_la_LIBADD = -lopengl32
> -lgdi32 $(OPENGL_COMMONLIBS) +libglwin32_plugin_la_LIBADD =
> libchroma_copy.la -lopengl32 -lgdi32 $(LIBCOM) -luuid libvlc_opengl.la
> +libwgl_plugin_la_LIBADD = -lopengl32 -lgdi32 libvlc_opengl.la
>
> libglwin32_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCFLAGS)
> -DHAVE_GL_CORE_SYMBOLS libwgl_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(OPENGL_COMMONCFLAGS)
> diff --git a/modules/video_output/opengl/Makefile.am
> b/modules/video_output/opengl/Makefile.am index d64896a56d4..0dd1888bfdc
> 100644
> --- a/modules/video_output/opengl/Makefile.am
> +++ b/modules/video_output/opengl/Makefile.am
> @@ -22,18 +22,48 @@ endif
> OPENGL_COMMONCFLAGS = $(LIBPLACEBO_CFLAGS)
> OPENGL_COMMONLIBS = $(LIBPLACEBO_LIBS)
>
> +# Convenience library for OpenGL components -- OpenGL only
> +libvlc_opengl_la_SOURCES = $(OPENGL_COMMONSOURCES)
> +libvlc_opengl_la_CFLAGS = $(OPENGL_COMMONCFLAGS)
> +libvlc_opengl_la_LIBADD = $(OPENGL_COMMONLIBS) $(LIBM)
> +libvlc_opengl_la_LDFLAGS = \
> + -static \
> + -no-undefined \
> + -export-symbols-regex "^vlc_gl_|^vout_display_opengl_" \
> + -version-info 0:0:0
> +
> +if HAVE_GL
> +noinst_LTLIBRARIES += libvlc_opengl.la
> +endif
> +
> +# Convenience library for OpenGL components -- OpenGL ES only
> +libvlc_opengles_la_SOURCES = $(OPENGL_COMMONSOURCES)
> +libvlc_opengles_la_CFLAGS = $(OPENGL_COMMONCFLAGS) -DUSE_OPENGL_ES2
> +libvlc_opengles_la_LIBADD = $(OPENGL_COMMONLIBS) $(LIBM)
> +libvlc_opengles_la_LDFLAGS = \
> + -static \
> + -no-undefined \
> + -export-symbols-regex "^vlc_gl_|^vout_display_opengl_" \
> + -version-info 0:0:0
These two should have no effects and do not make much sense for a static
library.
> +
> +libvlc_opengles_la_CFLAGS += $(GLES2_CFLAGS)
> +libvlc_opengles_la_LIBADD += $(GLES2_LIBS)
> +if HAVE_GLES2
> +noinst_LTLIBRARIES += libvlc_opengles.la
> +endif
> +
> ### OpenGL ###
> -libgles2_plugin_la_SOURCES = $(OPENGL_COMMONSOURCES)
> video_output/opengl/display.c -libgles2_plugin_la_CFLAGS = $(AM_CFLAGS)
> $(GLES2_CFLAGS) -DUSE_OPENGL_ES2 $(OPENGL_COMMONCFLAGS)
> -libgles2_plugin_la_LIBADD = $(GLES2_LIBS) $(LIBM) $(OPENGL_COMMONLIBS)
> +libgles2_plugin_la_SOURCES = video_output/opengl/display.c
> +libgles2_plugin_la_CFLAGS = $(AM_CFLAGS) $(GLES2_CFLAGS) -DUSE_OPENGL_ES2
> +libgles2_plugin_la_LIBADD = $(GLES2_LIBS) libvlc_opengles.la
> libgles2_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
> +if HAVE_GLES2
> +vout_LTLIBRARIES += libgles2_plugin.la
> +endif
>
> -EXTRA_LTLIBRARIES += libgles2_plugin.la
> -vout_LTLIBRARIES += $(LTLIBgles2)
> -
> -libgl_plugin_la_SOURCES = $(OPENGL_COMMONSOURCES)
> video_output/opengl/display.c +libgl_plugin_la_SOURCES =
> video_output/opengl/display.c
> libgl_plugin_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAGS) $(OPENGL_COMMONCFLAGS)
> -libgl_plugin_la_LIBADD = $(LIBM) $(OPENGL_COMMONLIBS)
> +libgl_plugin_la_LIBADD = libvlc_opengl.la
> if HAVE_WIN32
> libgl_plugin_la_CFLAGS += -DHAVE_GL_CORE_SYMBOLS
> libgl_plugin_la_LIBADD += $(GL_LIBS)
If you remove EXTRA_LTLIB, you can also remove -rpath, AFAIK.
--
レミ・デニ-クールモン
http://www.remlab.net/
More information about the vlc-devel
mailing list