Skip to content

Commit

Permalink
configure: Link to either OpenGL or OpenGL ES - not both
Browse files Browse the repository at this point in the history
- linking to both libraries causes unexpected behaviour on some legacy
drivers - notably nvidia (and maybe some Intel mesa) - leading to either
a hard crash at startup or falling back to llvm pipe (software
rendering)
- it also appears to impact behaviour of EGL DMABUF support on the Pi4 -
which needs an additional fix following this change
- we default to OpenGL and check whether Qt was compiled for GLES2 - and
if so only search for GLES2.
- in case Qt support is misdetected an additional configure option is
added to force OpenGL ES
- note however that this is ONLY intended as a workaround for
misdetection - Qt will still load the version of OpenGL it was compiled
for. Linking to GLES is not required to actually use GLES on desktop
platforms (this can be enabled with 'MYTHTV_NO_EGL=1
MYTHTV_OPENGL_ES=1')
- refs #13538
  • Loading branch information
mark-kendall committed Feb 3, 2020
1 parent 83152a6 commit ce373bb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 36 deletions.
85 changes: 55 additions & 30 deletions mythtv/configure
Expand Up @@ -131,6 +131,7 @@ Advanced options (experts only):
directory with frontend.h [$dvb_path_default]
--disable-asi disable support for DVEO ASI recorder
--disable-x11 disable X11 support
--enable-opengles link to OpenGL ES (auto)
--x11-path=X11LOC location of X11 include files [$x11_path_default]
--disable-xrandr disable X11 resolution switching
--disable-vdpau disable NVidia VDPAU hardware acceleration.
Expand Down Expand Up @@ -2768,7 +2769,6 @@ enable mheg
enable mmal
enable mythtranscode
enable opengl
enable opengles
enable egl
enable symbol_visibility
enable deprecation_warnings
Expand Down Expand Up @@ -3000,6 +3000,8 @@ for opt do
;;
--enable-mac-bundle) enable mac_bundle
;;
--enable-opengles) enable opengles && disable opengl
;;
--previous|--prev)
echo "No history of previous configure parameters."
;;
Expand Down Expand Up @@ -5995,27 +5997,6 @@ enabled libx264 && { use_pkg_config libx264 x264 "stdint.h x264.h" x26
{ check_cpp_condition x264.h "X264_MPEG2" &&
enable libx262; }
enabled libxml2 && require_pkg_config libxml2 libxml-2.0 libxml/xmlversion.h xmlCheckVersion
enabled opengl && { check_lib opengl GL/glx.h glXGetProcAddress "-lGL" ||
check_lib opengl windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
check_lib opengl OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" ||
check_lib opengl ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
check_lib opengl GLES/gl.h glGetError "-Wl,-framework,OpenGLES" ||
{ check_pkg_config GLESv2 glesv2 GLES2/gl2.h glGetError &&
check_pkg_config EGL egl EGL/egl.h eglGetProcAddress &&
enable opengl
} ||
{ check_lib GLESv2 GLES2/gl2.h glGetError "-lGLESv2" &&
check_lib EGL EGL/egl.h eglGetProcAddress "-lEGL" &&
enable opengl
} ||
die "ERROR: opengl not found."
}

enabled egl && { check_lib EGL EGL/egl.h eglGetProcAddress "-lEGL" ||
{
check_pkg_config EGL egl EGL/egl.h eglGetProcAddress && enable egl
}
}

enabled drm && use_pkg_config libdrm libdrm xf86drm.h drmGetVersion || disable drm
enabled drm && check_cpp_condition drm_fourcc.h 'defined(DRM_FORMAT_MOD_LINEAR)' || disable drm
Expand Down Expand Up @@ -6507,6 +6488,57 @@ case "$cc_type" in
;;
esac

# we need either OpenGL or OpenGL ES and 'ideally' the same version that Qt was
# configured with. Linking to both can cause problems on some systems.
# opengl is enabled by default (and hence opengles is disabled by default)

qt_opengles_check() {
log "qt_opengles_check $@"
"qt_opengles_check $@" >> $logfile 2>&1
check_ecxx ${qt_inc} <<EOF
#include <QtCore/QtCore>
#if QT_VERSION >= QT_VERSION_CHECK(5,8,0)
#include <QtGui/qtguiglobal.h>
#endif
#if !defined(QT_OPENGL_ES_2)
No OpenGL ES here!
#endif
int x;
EOF
}

qt_opengles_check && enable opengles && disable opengl && echo Qt built for OpenGL ES

enabled opengl && { check_lib opengl GL/glx.h glXGetProcAddress "-lGL" ||
check_lib opengl windows.h wglGetProcAddress "-lopengl32 -lgdi32" ||
check_lib opengl OpenGL/gl3.h glGetError "-Wl,-framework,OpenGL" || disable opengl
}

disabled opengl || enabled opengles && {
check_lib opengl ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
check_lib opengl GLES/gl.h glGetError "-Wl,-framework,OpenGLES" ||
{ check_pkg_config GLESv2 glesv2 GLES2/gl2.h glGetError &&
check_pkg_config EGL egl EGL/egl.h eglGetProcAddress &&
enable opengles
} ||
{ check_lib GLESv2 GLES2/gl2.h glGetError "-lGLESv2" &&
check_lib EGL EGL/egl.h eglGetProcAddress "-lEGL" &&
enable opengles
} ||
disable opengles
}

enabled opengles && enable opengl
if disabled opengl; then
die "Neither OpenGL or OpenGLES found!"
fi

enabled egl && { check_lib EGL EGL/egl.h eglGetProcAddress "-lEGL" ||
{
check_pkg_config EGL egl EGL/egl.h eglGetProcAddress && enable egl
}
}

enable enforce_wshadow
case $target_os in
android)
Expand Down Expand Up @@ -6639,12 +6671,6 @@ if enabled taglib; then
taglib_libs=`taglib-config --libs`
fi

if enabled x11; then
if enabled opengles; then
check_libx gl_lib GLES2/gl2.h glClear -lGLESv2 || disable opengles
fi
fi

enabled x11 && check_lib X11 "X11/Xdefs.h X11/Xlib.h" XQueryExtension -lX11 || disable x11
enabled xrandr && check_lib Xrandr "X11/Xdefs.h X11/Xlib.h X11/extensions/Xrandr.h" XRRSelectInput -lXrandr || disable xrandr

Expand Down Expand Up @@ -7405,8 +7431,7 @@ fi
echo "DRM support ${drm-no}"
echo "Video4Linux codecs ${v4l2-no} (DRM ${v4l2prime-no})"
echo "MMAL decoder support ${mmal-no}"
echo "OpenGL support ${opengl-no}"
echo "OpenGL ES 2.0 ${opengles-no}"
echo "OpenGL ${opengl-no} (OpenGLES ${opengles-no})"
echo "EGL support ${egl-no}"
if test x"$target_os" = x"mingw32" ; then
echo "Windows (Direct3D) yes"
Expand Down
2 changes: 0 additions & 2 deletions mythtv/libs/libmythtv/libmythtv.pro
Expand Up @@ -462,8 +462,6 @@ using_frontend {

using_opengl {
DEFINES += USING_OPENGL
using_opengles: DEFINES += USING_OPENGLES

HEADERS += opengl/mythopenglvideo.h
HEADERS += opengl/mythvideooutopengl.h
HEADERS += opengl/mythopenglvideoshaders.h
Expand Down
4 changes: 0 additions & 4 deletions mythtv/libs/libmythui/libmythui.pro
Expand Up @@ -199,10 +199,6 @@ using_opengl {
HEADERS += opengl/mythegl.h
SOURCES += opengl/mythegl.cpp

using_opengles {
DEFINES += USING_OPENGLES
}

using_egl {
LIBS += -lEGL
DEFINES += USING_EGL
Expand Down
4 changes: 4 additions & 0 deletions mythtv/settings.pro
Expand Up @@ -223,6 +223,10 @@ win32 {

EXTRA_LIBS += $$LOCAL_LIBDIR_OGL
EXTRA_LIBS += $$LOCAL_LIBDIR_X11
# FIXME MK Jan/20 I'm not sure this is necessary or necessarily accurate.
# FFmpeg OpenGL is an option that we do not (and should not imho) enable -
# and we should in that case be stripping out GLES etc as well.
# and CONFIG_OPENGL_LIBS is always empty as we never set gl_lib anymore
!isEmpty( CONFIG_OPENGL_LIBS ) {
# Replace FFmpeg's OpenGL with OpenGLES
EXTRA_LIBS -= -lGL
Expand Down

0 comments on commit ce373bb

Please sign in to comment.