Hello community, here is the log from the commit of package libepoxy for openSUSE:Factory checked in at 2018-10-25 08:09:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libepoxy (Old) and /work/SRC/openSUSE:Factory/.libepoxy.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libepoxy" Thu Oct 25 08:09:44 2018 rev:11 rq:642992 version:1.5.3 Changes: -------- --- /work/SRC/openSUSE:Factory/libepoxy/libepoxy.changes 2018-03-04 11:52:26.286501209 +0100 +++ /work/SRC/openSUSE:Factory/.libepoxy.new/libepoxy.changes 2018-10-25 08:09:45.860289351 +0200 @@ -1,0 +2,31 @@ +Fri Oct 5 11:51:19 UTC 2018 - [email protected] + +- Update to version 1.5.3: + + Fix build with uClibc + + Fix GLES3 symbol lookup + + Fix conditional compilation + + Require Meson 0.47 + + Fix Autotools build with EGL-X11 support +- Changes from version 1.5.2: + + Fix the detection of the -z,relro linker flag + + Query the EGL context version when bootstrapping on GLES + + Avoid inadvertedly loading libraries when probing for them + + Consistently use abort() instead of exit() for internal state + checks + + Fix a performance regression in the global function pointer + trampolines introduced by using -Bsymbolic-functions + + Improve performance when using GL function pointers like + glAlphaFunc +- Changes from version 1.5.1: + + Generalise checks for dlvsym + + Add an option for disabling building the test suite + + Typo fixes in the comments and documentation + + Simplify the Meson configuration logic for EGL and GLX + + Use assert when no context is found + + Remove a test superceded by GLVND + + Avoid Meson warnings when testing for linker arguments +- Pass tests=false to meson, ensure we do not build the test-suite. +- Drop la files removal, they are no longer built. +- Run spec-cleaner, modernize spec. + +------------------------------------------------------------------- Old: ---- libepoxy-1.5.0.tar.gz New: ---- libepoxy-1.5.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libepoxy.spec ++++++ --- /var/tmp/diff_new_pack.igZpcA/_old 2018-10-25 08:09:46.408288992 +0200 +++ /var/tmp/diff_new_pack.igZpcA/_new 2018-10-25 08:09:46.416288986 +0200 @@ -1,7 +1,7 @@ # # spec file for package libepoxy # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,22 +12,22 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: libepoxy %define sonum 0 -Version: 1.5.0 +Version: 1.5.3 Release: 0 Summary: OpenGL function pointer management library License: MIT Group: Development/Libraries/C and C++ -Url: https://github.com/anholt/libepoxy +URL: https://github.com/anholt/libepoxy Source0: https://github.com/anholt/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: baselibs.conf -BuildRequires: meson >= 0.44.1 +BuildRequires: meson >= 0.47 BuildRequires: pkgconfig BuildRequires: python3 BuildRequires: pkgconfig(egl) @@ -79,17 +79,17 @@ %autosetup %build -%{meson} \ +%meson \ -D docs=false \ -D glx=yes \ -D egl=yes \ -D x11=true \ + -D tests=false \ %{nil} -%{meson_build} +%meson_build %install -%{meson_install} -find %{buildroot} -type f -name "*.la" -delete -print +%meson_install %post -n %{name}%{sonum} -p /sbin/ldconfig %postun -n %{name}%{sonum} -p /sbin/ldconfig ++++++ libepoxy-1.5.0.tar.gz -> libepoxy-1.5.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.gitignore new/libepoxy-1.5.3/.gitignore --- old/libepoxy-1.5.0/.gitignore 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/.gitignore 2018-10-05 01:12:11.000000000 +0200 @@ -66,7 +66,6 @@ *.l[oa] *.[oa] *.obj -*.patch *.so *.pcf.gz *.pdb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.travis/Dockerfile new/libepoxy-1.5.3/.travis/Dockerfile --- old/libepoxy-1.5.0/.travis/Dockerfile 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/.travis/Dockerfile 2018-10-05 01:12:11.000000000 +0200 @@ -27,5 +27,3 @@ RUN pip3 install meson WORKDIR /root - -COPY epoxy-run-tests.sh . diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.travis/epoxy-ci-linux.sh new/libepoxy-1.5.3/.travis/epoxy-ci-linux.sh --- old/libepoxy-1.5.0/.travis/epoxy-ci-linux.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/libepoxy-1.5.3/.travis/epoxy-ci-linux.sh 2018-10-05 01:12:11.000000000 +0200 @@ -0,0 +1,32 @@ +#!/bin/bash + +dump_log_and_quit() { + local exitcode=$1 + + cat meson-logs/testlog.txt + + exit $exitcode +} + +# Start Xvfb +XVFB_WHD=${XVFB_WHD:-1280x720x16} + +Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp & +xvfb=$! + +export DISPLAY=:99 + +srcdir=$( pwd ) +builddir=$( mktemp -d build_XXXXXX ) + +meson --prefix /usr "$@" $builddir $srcdir || exit $? + +cd $builddir + +ninja || exit $? +meson test || dump_log_and_quit $? + +cd .. + +# Stop Xvfb +kill -9 ${xvfb} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.travis/epoxy-ci-osx.sh new/libepoxy-1.5.3/.travis/epoxy-ci-osx.sh --- old/libepoxy-1.5.0/.travis/epoxy-ci-osx.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/libepoxy-1.5.3/.travis/epoxy-ci-osx.sh 2018-10-05 01:12:11.000000000 +0200 @@ -0,0 +1,27 @@ +#!/bin/sh + +dump_log_and_quit() { + local exitcode=$1 + + cat meson-logs/testlog.txt + + exit $exitcode +} + +export SDKROOT=$( xcodebuild -version -sdk macosx Path ) +export CPPFLAGS=-I/usr/local/include +export LDFLAGS=-L/usr/local/lib +export OBJC=$CC +export PATH=$HOME/tools:$PATH + +srcdir=$( pwd ) +builddir=$( mktemp -d build_XXXXXX ) + +meson ${BUILDOPTS} $builddir $srcdir || exit $? + +cd $builddir + +ninja || exit $? +meson test || dump_log_and_quit $? + +cd .. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.travis/epoxy-run-tests.sh new/libepoxy-1.5.3/.travis/epoxy-run-tests.sh --- old/libepoxy-1.5.0/.travis/epoxy-run-tests.sh 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/.travis/epoxy-run-tests.sh 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ -#!/bin/bash - -# Start Xvfb -XVFB_WHD=${XVFB_WHD:-1280x720x16} - -Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp & -xvfb=$! - -export DISPLAY=:99 - -mkdir _build - -meson --prefix /usr "$@" _build . || exit $? -ninja -C _build || exit $? -meson test -C _build || exit $? - -rm -rf _build - -# Stop Xvfb -kill -9 ${xvfb} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/.travis.yml new/libepoxy-1.5.3/.travis.yml --- old/libepoxy-1.5.0/.travis.yml 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/.travis.yml 2018-10-05 01:12:11.000000000 +0200 @@ -7,6 +7,7 @@ os: - linux + - osx compiler: - gcc @@ -18,16 +19,36 @@ services: - docker +matrix: + exclude: + - os: osx + compiler: gcc + before_install: - - docker pull ebassi/epoxyci + - | + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update + brew install python@3 meson + # Use a Ninja with QuLogic's patch: https://github.com/ninja-build/ninja/issues/1219 + mkdir -p $HOME/tools; curl -L http://nirbheek.in/files/binaries/ninja/macos/ninja -o $HOME/tools/ninja; chmod +x $HOME/tools/ninja + fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker pull ebassi/epoxyci ; fi before_script: - - echo FROM ebassi/epoxyci > Dockerfile - - echo ADD . /root >> Dockerfile - - docker build -t withgit . + - | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + echo FROM ebassi/epoxyci > Dockerfile + echo ADD . /root >> Dockerfile + echo WORKDIR /root >> Dockerfile + docker build -t withgit . + fi + +env: + - BUILD_OPTS="" + - BUILD_OPTS="-Dglx=no" + - BUILD_OPTS="-Degl=no" + - BUILD_OPTS="-Dx11=false" script: - - docker run withgit /bin/sh -c "CC=$CC ./epoxy-run-tests.sh" - - docker run withgit /bin/sh -c "CC=$CC ./epoxy-run-tests.sh -Dglx=no" - - docker run withgit /bin/sh -c "CC=$CC ./epoxy-run-tests.sh -Degl=no" - - docker run withgit /bin/sh -c "CC=$CC ./epoxy-run-tests.sh -Dx11=false" + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker run withgit /bin/sh -c "CC=$CC .travis/epoxy-ci-linux.sh $BUILD_OPTS" ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then /bin/sh -c "CC=$CC .travis/epoxy-ci-osx.sh $BUILD_OPTS" ; fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/configure.ac new/libepoxy-1.5.3/configure.ac --- old/libepoxy-1.5.0/configure.ac 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/configure.ac 2018-10-05 01:12:11.000000000 +0200 @@ -22,7 +22,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([libepoxy], - [1.5.0], + [1.5.3], [https://github.com/anholt/libepoxy], [libepoxy]) AC_CONFIG_SRCDIR([Makefile.am]) @@ -124,7 +124,7 @@ build_wgl=yes has_znow=yes # On windows, the DLL has to have all of its functions - # resolved at link time, so we have to link directly aginst + # resolved at link time, so we have to link directly against # opengl32.dll. But that's the only GL provider, anyway. EPOXY_LINK_LIBS="-lopengl32" @@ -137,7 +137,6 @@ [darwin*], [ build_wgl=no - build_apple=yes has_znow=no EPOXY_LINK_LIBS="" ], @@ -158,6 +157,8 @@ AC_MSG_ERROR([GLX support is explicitly enabled, but X11 was disabled]) fi build_glx=no +else + AC_DEFINE([ENABLE_X11], [1], [Whether X11 support is enabled]) fi AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes) @@ -177,11 +178,6 @@ AC_DEFINE([BUILD_WGL], [1], [build WGL tests]) fi -AM_CONDITIONAL(BUILD_APPLE, test x$build_apple = xyes) -if test x$build_apple = xyes; then - AC_DEFINE([BUILD_APPLE], [1], [build APPLE is apple (for testing)]) -fi - AM_CONDITIONAL(HAS_ZNOW, test x$has_znow = xyes) AC_CHECK_LIB([GLESv1_CM], [glFlush], [has_gles1=yes], [has_gles1=no]) @@ -190,6 +186,12 @@ AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"]) AC_SUBST([DLOPEN_LIBS]) +savelibs=$LIBS +LIBS=$DLOPEN_LIBS +AC_CHECK_FUNCS([dlvsym], [have_dlvsym=1], [have_dlvsym=0]) +AM_CONDITIONAL(HAVE_DLVSYM, test $have_dlvsym = 1) +LIBS=$savelibs + VISIBILITY_CFLAGS="" AS_CASE(["$host"], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/meson.build new/libepoxy-1.5.3/meson.build --- old/libepoxy-1.5.0/meson.build 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/meson.build 2018-10-05 01:12:11.000000000 +0200 @@ -1,11 +1,11 @@ -project('libepoxy', 'c', version: '1.5.0', +project('libepoxy', 'c', version: '1.5.3', default_options: [ 'buildtype=debugoptimized', 'c_std=gnu99', 'warning_level=1', ], license: 'MIT', - meson_version: '>= 0.44.0') + meson_version: '>= 0.47.0') epoxy_version = meson.project_version().split('.') epoxy_major_version = epoxy_version[0].to_int() @@ -28,7 +28,7 @@ conf.set_quoted('PACKAGE_LIBDIR', join_paths(get_option('prefix'), get_option('libdir'))) conf.set_quoted('PACKAGE_LOCALEDIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) conf.set_quoted('PACKAGE_LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir'))) -conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h', required: false)) +conf.set('HAVE_KHRPLATFORM_H', cc.has_header('KHR/khrplatform.h')) # GLX can be used on different platforms, so we expose a # configure time switch to enable or disable it; in case @@ -36,38 +36,16 @@ # support on Linux and Unix enable_glx = get_option('glx') if enable_glx == 'auto' - if host_system == 'windows' - build_glx = false - elif host_system == 'darwin' - build_glx = false - elif host_system == 'android' - build_glx = false - elif host_system == 'haiku' - build_glx = false - else - build_glx = true - endif -elif enable_glx == 'yes' - build_glx = true -elif enable_glx == 'no' - build_glx = false + build_glx = not ['windows', 'darwin', 'android', 'haiku'].contains(host_system) +else + build_glx = enable_glx == 'yes' endif enable_egl = get_option('egl') if enable_egl == 'auto' - if host_system == 'windows' - build_egl = false - elif host_system == 'darwin' - build_egl = false - elif host_system == 'android' - build_egl = true - else - build_egl = true - endif -elif enable_egl == 'yes' - build_egl = true -elif enable_egl == 'no' - build_egl = false + build_egl = not ['windows', 'darwin'].contains(host_system) +else + build_egl = enable_egl == 'yes' endif enable_x11 = get_option('x11') @@ -81,15 +59,12 @@ # The remaining platform specific API for GL/GLES are enabled # depending on the platform we're building for if host_system == 'windows' - build_apple = false build_wgl = true has_znow = true elif host_system == 'darwin' - build_apple = true build_wgl = false has_znow = false else - build_apple = false build_wgl = false has_znow = true endif @@ -208,7 +183,7 @@ endif # On windows, the DLL has to have all of its functions -# resolved at link time, so we have to link directly aginst +# resolved at link time, so we have to link directly against # opengl32. But that's the only GL provider, anyway. if host_system == 'windows' opengl32_dep = cc.find_library('opengl32', required: true) @@ -242,7 +217,10 @@ subdir('include/epoxy') subdir('src') -subdir('test') + +if get_option('tests') + subdir('test') +endif if get_option('docs') doxygen = find_program('doxygen', required: false) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/meson_options.txt new/libepoxy-1.5.3/meson_options.txt --- old/libepoxy-1.5.0/meson_options.txt 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/meson_options.txt 2018-10-05 01:12:11.000000000 +0200 @@ -15,3 +15,7 @@ type: 'boolean', value: true, description: 'Enable X11 support (GLX or EGL-X11)') +option('tests', + type: 'boolean', + value: true, + description: 'Build the test suite') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/Makefile.am new/libepoxy-1.5.3/src/Makefile.am --- old/libepoxy-1.5.0/src/Makefile.am 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/Makefile.am 2018-10-05 01:12:11.000000000 +0200 @@ -116,7 +116,7 @@ libepoxy_la_LDFLAGS = \ -no-undefined \ - -Bsymbolic \ + -Bsymbolic-functions \ $() libepoxy_la_LIBADD = \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/dispatch_common.c new/libepoxy-1.5.3/src/dispatch_common.c --- old/libepoxy-1.5.0/src/dispatch_common.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/dispatch_common.c 2018-10-05 01:12:11.000000000 +0200 @@ -173,24 +173,24 @@ #include "dispatch_common.h" -#ifdef __APPLE__ +#if defined(__APPLE__) #define GLX_LIB "/opt/X11/lib/libGL.1.dylib" +#define OPENGL_LIB "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL" +#define GLES1_LIB "libGLESv1_CM.so" +#define GLES2_LIB "libGLESv2.so" #elif defined(__ANDROID__) #define GLX_LIB "libGLESv2.so" -#else -#define GLVND_GLX_LIB "libGLX.so.1" -#define GLX_LIB "libGL.so.1" -#endif - -#ifdef __ANDROID__ #define EGL_LIB "libEGL.so" #define GLES1_LIB "libGLESv1_CM.so" #define GLES2_LIB "libGLESv2.so" -#elif defined _WIN32 +#elif defined(_WIN32) #define EGL_LIB "libEGL.dll" #define GLES1_LIB "libGLES_CM.dll" #define GLES2_LIB "libGLESv2.dll" +#define OPENGL_LIB "OPENGL32" #else +#define GLVND_GLX_LIB "libGLX.so.1" +#define GLX_LIB "libGL.so.1" #define EGL_LIB "libEGL.so.1" #define GLES1_LIB "libGLESv1_CM.so.1" #define GLES2_LIB "libGLESv2.so.2" @@ -290,7 +290,7 @@ } static bool -get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail) +get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail, bool load) { if (*handle) return true; @@ -305,11 +305,15 @@ #else pthread_mutex_lock(&api.mutex); if (!*handle) { - *handle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL); + int flags = RTLD_LAZY | RTLD_LOCAL; + if (!load) + flags |= RTLD_NOLOAD; + + *handle = dlopen(lib_name, flags); if (!*handle) { if (exit_on_fail) { fprintf(stderr, "Couldn't open %s: %s\n", lib_name, dlerror()); - exit(1); + abort(); } else { (void)dlerror(); } @@ -322,15 +326,11 @@ } static void * -do_dlsym(void **handle, const char *lib_name, const char *name, - bool exit_on_fail) +do_dlsym(void **handle, const char *name, bool exit_on_fail) { void *result; const char *error = ""; - if (!get_dlopen_handle(handle, lib_name, exit_on_fail)) - return NULL; - #ifdef _WIN32 result = GetProcAddress(*handle, name); #else @@ -339,8 +339,8 @@ error = dlerror(); #endif if (!result && exit_on_fail) { - fprintf(stderr,"%s() not found in %s: %s\n", name, lib_name, error); - exit(1); + fprintf(stderr, "%s() not found: %s\n", name, error); + abort(); } return result; @@ -410,7 +410,7 @@ if (scanf_count != 2) { fprintf(stderr, "Unable to interpret GL_VERSION string: %s\n", version); - exit(1); + abort(); } if (minor >= 10) @@ -487,7 +487,7 @@ * is supported by the client, this probably isn't the function you want. * * Some parts of the spec for OpenGL and friends will return an OpenGL formatted - * extension string that is seperate from the usual extension strings for the + * extension string that is separate from the usual extension strings for the * spec. This function provides easy parsing of those strings. * * @see epoxy_has_gl_extension() @@ -548,16 +548,29 @@ } } -void * -epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails) +bool +epoxy_load_glx(bool exit_if_fails, bool load) { -#ifdef GLVND_GLX_LIB +#if PLATFORM_HAS_GLX +# ifdef GLVND_GLX_LIB /* prefer the glvnd library if it exists */ if (!api.glx_handle) - get_dlopen_handle(&api.glx_handle, GLVND_GLX_LIB, false); + get_dlopen_handle(&api.glx_handle, GLVND_GLX_LIB, false, load); +# endif + if (!api.glx_handle) + get_dlopen_handle(&api.glx_handle, GLX_LIB, exit_if_fails, load); #endif + return api.glx_handle != NULL; +} - return do_dlsym(&api.glx_handle, GLX_LIB, name, exit_if_fails); +void * +epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails) +{ +#if PLATFORM_HAS_GLX + if (epoxy_load_glx(exit_if_fails, exit_if_fails)) + return do_dlsym(&api.glx_handle, name, exit_if_fails); +#endif + return NULL; } /** @@ -572,23 +585,7 @@ #else void *sym; - /* If we've been called already, don't load more */ - if (!api.egl_handle != !api.glx_handle) { - if (api.glx_handle) - return true; - else if (api.egl_handle) - return false; - } - - /* If the application hasn't explicitly called some of our GLX - * or EGL code but has presumably set up a context on its own, - * then we need to figure out how to getprocaddress anyway. - * - * If there's a public GetProcAddress loaded in the - * application's namespace, then use that. - */ - - sym = dlsym(NULL, "glXGetCurrentContext"); + sym = epoxy_conservative_glx_dlsym("glXGetCurrentContext", false); if (sym) { if (glXGetCurrentContext()) return true; @@ -597,7 +594,7 @@ } #if PLATFORM_HAS_EGL - sym = dlsym(NULL, "eglGetCurrentContext"); + sym = epoxy_conservative_egl_dlsym("eglGetCurrentContext", false); if (sym) { if (epoxy_egl_get_current_gl_context_api() != EGL_NONE) return false; @@ -606,21 +603,6 @@ } #endif /* PLATFORM_HAS_EGL */ - /* OK, couldn't find anything in the app's address space. - * Presumably they dlopened with RTLD_LOCAL, which hides it - * from us. Just go dlopen()ing likely libraries and try them. - */ - sym = epoxy_conservative_glx_dlsym("glXGetCurrentContext", false); - if (sym && glXGetCurrentContext()) - return true; - -#if PLATFORM_HAS_EGL - sym = do_dlsym(&api.egl_handle, EGL_LIB, "eglGetCurrentContext", - false); - if (sym && epoxy_egl_get_current_gl_context_api() != EGL_NONE) - return false; -#endif /* PLATFORM_HAS_EGL */ - return false; #endif /* PLATFORM_HAS_GLX */ } @@ -651,10 +633,24 @@ return epoxy_internal_has_gl_extension(ext, true); } +bool +epoxy_load_egl(bool exit_if_fails, bool load) +{ +#if PLATFORM_HAS_EGL + return get_dlopen_handle(&api.egl_handle, EGL_LIB, exit_if_fails, load); +#else + return false; +#endif +} + void * epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails) { - return do_dlsym(&api.egl_handle, EGL_LIB, name, exit_if_fails); +#if PLATFORM_HAS_EGL + if (epoxy_load_egl(exit_if_fails, exit_if_fails)) + return do_dlsym(&api.egl_handle, name, exit_if_fails); +#endif + return NULL; } void * @@ -669,31 +665,32 @@ return epoxy_conservative_glx_dlsym(name, true); } -void * -epoxy_gl_dlsym(const char *name) +static void +epoxy_load_gl(void) { -#ifdef _WIN32 - return do_dlsym(&api.gl_handle, "OPENGL32", name, true); -#elif defined(__APPLE__) - return do_dlsym(&api.gl_handle, - "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", - name, true); + if (api.gl_handle) + return; + +#if defined(_WIN32) || defined(__APPLE__) + get_dlopen_handle(&api.gl_handle, OPENGL_LIB, true, true); #else - void *sym; -# if defined(OPENGL_LIB) +#if defined(OPENGL_LIB) if (!api.gl_handle) - get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false); -# endif + get_dlopen_handle(&api.gl_handle, OPENGL_LIB, false, true); +#endif - if (api.gl_handle) - return do_dlsym(&api.gl_handle, NULL, name, true); + get_dlopen_handle(&api.glx_handle, GLX_LIB, true, true); + api.gl_handle = api.glx_handle; +#endif +} - sym = do_dlsym(&api.glx_handle, GLX_LIB, name, true); - api.gl_handle = api.glx_handle; /* skip the dlopen next time */ +void * +epoxy_gl_dlsym(const char *name) +{ + epoxy_load_gl(); - return sym; -#endif + return do_dlsym(&api.gl_handle, name, true); } void * @@ -702,7 +699,8 @@ if (epoxy_current_context_is_glx()) { return epoxy_get_proc_address(name); } else { - return do_dlsym(&api.gles1_handle, GLES1_LIB, name, true); + get_dlopen_handle(&api.gles1_handle, GLES1_LIB, true, true); + return do_dlsym(&api.gles1_handle, name, true); } } @@ -712,7 +710,8 @@ if (epoxy_current_context_is_glx()) { return epoxy_get_proc_address(name); } else { - return do_dlsym(&api.gles2_handle, GLES2_LIB, name, true); + get_dlopen_handle(&api.gles2_handle, GLES2_LIB, true, true); + return do_dlsym(&api.gles2_handle, name, true); } } @@ -732,10 +731,12 @@ if (epoxy_current_context_is_glx()) { return epoxy_get_proc_address(name); } else { - void *func = do_dlsym(&api.gles2_handle, GLES2_LIB, name, false); + if (get_dlopen_handle(&api.gles2_handle, GLES2_LIB, false, true)) { + void *func = do_dlsym(&api.gles2_handle, name, false); - if (func) - return func; + if (func) + return func; + } return epoxy_get_proc_address(name); } @@ -810,22 +811,22 @@ * non-X11 ES2 context from loading a bunch of X11 junk). */ #if PLATFORM_HAS_EGL - get_dlopen_handle(&api.egl_handle, EGL_LIB, false); + get_dlopen_handle(&api.egl_handle, EGL_LIB, false, true); if (api.egl_handle) { + int version = 0; switch (epoxy_egl_get_current_gl_context_api()) { case EGL_OPENGL_API: return epoxy_gl_dlsym(name); case EGL_OPENGL_ES_API: - /* We can't resolve the GL version, because - * epoxy_glGetString() is one of the two things calling - * us. Try the GLES2 implementation first, and fall back - * to GLES1 otherwise. - */ - get_dlopen_handle(&api.gles2_handle, GLES2_LIB, false); - if (api.gles2_handle) - return epoxy_gles2_dlsym(name); - else - return epoxy_gles1_dlsym(name); + if (eglQueryContext(eglGetCurrentDisplay(), + eglGetCurrentContext(), + EGL_CONTEXT_CLIENT_VERSION, + &version)) { + if (version >= 2) + return epoxy_gles2_dlsym(name); + else + return epoxy_gles1_dlsym(name); + } } } #endif /* PLATFORM_HAS_EGL */ @@ -859,7 +860,7 @@ #elif PLATFORM_HAS_GLX if (epoxy_current_context_is_glx()) return glXGetProcAddressARB((const GLubyte *)name); - errx(1, "Couldn't find current GLX or EGL context.\n"); + assert(0 && "Couldn't find current GLX or EGL context.\n"); #endif return NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/dispatch_common.h new/libepoxy-1.5.3/src/dispatch_common.h --- old/libepoxy-1.5.0/src/dispatch_common.h 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/dispatch_common.h 2018-10-05 01:12:11.000000000 +0200 @@ -28,7 +28,7 @@ #define PLATFORM_HAS_GLX ENABLE_GLX #define PLATFORM_HAS_WGL 1 #elif defined(__APPLE__) -#define PLATFORM_HAS_EGL ENABLE_EGL +#define PLATFORM_HAS_EGL 0 #define PLATFORM_HAS_GLX ENABLE_GLX #define PLATFORM_HAS_WGL 0 #elif defined(ANDROID) @@ -85,10 +85,11 @@ #define WRAPPER(x) x ## _wrapped #define GEN_GLOBAL_REWRITE_PTR(name, args, passthrough) \ - static void EPOXY_CALLSPEC \ + static void EPOXY_CALLSPEC \ name##_global_rewrite_ptr args \ { \ - name = (void *)name##_resolver(); \ + if (name == (void *)name##_global_rewrite_ptr) \ + name = (void *)name##_resolver(); \ name passthrough; \ } @@ -96,7 +97,8 @@ static ret EPOXY_CALLSPEC \ name##_global_rewrite_ptr args \ { \ - name = (void *)name##_resolver(); \ + if (name == (void *)name##_global_rewrite_ptr) \ + name = (void *)name##_resolver(); \ return name passthrough; \ } @@ -172,6 +174,9 @@ void *epoxy_conservative_egl_dlsym(const char *name, bool exit_if_fails); void *epoxy_conservative_glx_dlsym(const char *name, bool exit_if_fails); +bool epoxy_load_glx(bool exit_if_fails, bool load); +bool epoxy_load_egl(bool exit_if_fails, bool load); + #define glBegin_unwrapped epoxy_glBegin_unwrapped #define glEnd_unwrapped epoxy_glEnd_unwrapped extern void UNWRAPPED_PROTO(glBegin_unwrapped)(GLenum primtype); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/dispatch_egl.c new/libepoxy-1.5.3/src/dispatch_egl.c --- old/libepoxy-1.5.0/src/dispatch_egl.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/dispatch_egl.c 2018-10-05 01:12:11.000000000 +0200 @@ -109,11 +109,13 @@ #if !PLATFORM_HAS_EGL return false; #else - EGLDisplay* (* pf_eglGetCurrentDisplay) (void); + if (epoxy_load_egl(false, true)) { + EGLDisplay* (* pf_eglGetCurrentDisplay) (void); - pf_eglGetCurrentDisplay = epoxy_conservative_egl_dlsym("eglGetCurrentDisplay", false); - if (pf_eglGetCurrentDisplay) - return true; + pf_eglGetCurrentDisplay = epoxy_conservative_egl_dlsym("eglGetCurrentDisplay", false); + if (pf_eglGetCurrentDisplay) + return true; + } return false; #endif /* PLATFORM_HAS_EGL */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/dispatch_glx.c new/libepoxy-1.5.3/src/dispatch_glx.c --- old/libepoxy-1.5.0/src/dispatch_glx.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/dispatch_glx.c 2018-10-05 01:12:11.000000000 +0200 @@ -158,12 +158,14 @@ #if !PLATFORM_HAS_GLX return false; #else - Bool (* pf_glXQueryExtension) (Display *, int *, int *); - int error_base, event_base; + if (epoxy_load_glx(false, true)) { + Bool (* pf_glXQueryExtension) (Display *, int *, int *); + int error_base, event_base; - pf_glXQueryExtension = epoxy_conservative_glx_dlsym("glXQueryExtension", false); - if (pf_glXQueryExtension && pf_glXQueryExtension(dpy, &error_base, &event_base)) - return true; + pf_glXQueryExtension = epoxy_conservative_glx_dlsym("glXQueryExtension", false); + if (pf_glXQueryExtension && pf_glXQueryExtension(dpy, &error_base, &event_base)) + return true; + } return false; #endif /* !PLATFORM_HAS_GLX */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/src/meson.build new/libepoxy-1.5.3/src/meson.build --- old/libepoxy-1.5.0/src/meson.build 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/src/meson.build 2018-10-05 01:12:11.000000000 +0200 @@ -49,12 +49,8 @@ common_ldflags = [] -if host_system == 'linux' - foreach f: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ] - if cc.has_argument(f) - common_ldflags += f - endif - endforeach +if host_system == 'linux' and cc.get_id() == 'gcc' + common_ldflags += cc.get_supported_link_arguments([ '-Wl,-Bsymbolic-functions', '-Wl,-z,relro' ]) endif # Maintain compatibility with autotools; see: https://github.com/anholt/libepoxy/issues/108 @@ -93,10 +89,10 @@ # not needed when building Epoxy; we do want to add them to the generated # pkg-config file, for consumers of Epoxy gl_reqs = [] -if gl_dep.found() +if gl_dep.found() and gl_dep.type_name() == 'pkgconfig' gl_reqs += 'gl' endif -if build_egl and egl_dep.found() +if build_egl and egl_dep.found() and egl_dep.type_name() == 'pkgconfig' gl_reqs += 'egl' endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/Makefile.am new/libepoxy-1.5.3/test/Makefile.am --- old/libepoxy-1.5.0/test/Makefile.am 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/Makefile.am 2018-10-05 01:12:11.000000000 +0200 @@ -65,7 +65,6 @@ check_BINARIES = $(EGL_AND_GLX_BIN) XFAIL_TESTS = \ - egl_and_glx_different_pointers_egl_glx \ $() check_PROGRAMS = $(TESTS) @@ -96,19 +95,16 @@ if BUILD_EGL if BUILD_GLX -if !BUILD_APPLE +if HAVE_DLVSYM EGL_AND_GLX_TESTS = \ egl_gl \ - egl_and_glx_different_pointers_egl_glx \ - egl_and_glx_different_pointers_egl \ - egl_and_glx_different_pointers_glx \ $() endif endif endif -if !BUILD_APPLE -GLX_NON_APPLE_TESTS = \ +if HAVE_DLVSYM +GLX_DLVSYM_TESTS = \ glx_alias_prefer_same_name \ glx_gles2 \ $() @@ -122,7 +118,7 @@ glx_has_extension_nocontext \ glx_static \ $(GLX_SHARED_ZNOW) \ - $(GLX_NON_APPLE_TESTS) \ + $(GLX_DLVSYM_TESTS) \ $() GLX_UTIL_LIB = libglx_common.la @@ -153,21 +149,6 @@ egl_gles2_without_glx_SOURCES = egl_without_glx.c egl_gles2_without_glx_LDADD = $(EPOXY) $(DLOPEN_LIBS) libegl_common.la $(X11_LIBS) -egl_and_glx_different_pointers_egl_SOURCES = egl_and_glx_different_pointers.c dlwrap.c dlwrap.h -egl_and_glx_different_pointers_egl_LDADD = libegl_common.la libglx_common.la $(DLOPEN_LIBS) $(EPOXY) $(X11_LIBS) -egl_and_glx_different_pointers_egl_LDFLAGS = -rdynamic -egl_and_glx_different_pointers_egl_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_EGL - -egl_and_glx_different_pointers_glx_SOURCES = egl_and_glx_different_pointers.c dlwrap.c dlwrap.h -egl_and_glx_different_pointers_glx_LDADD = libegl_common.la libglx_common.la $(DLOPEN_LIBS) $(EPOXY) $(X11_LIBS) -egl_and_glx_different_pointers_glx_LDFLAGS = -rdynamic -egl_and_glx_different_pointers_glx_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_GLX - -egl_and_glx_different_pointers_egl_glx_SOURCES = egl_and_glx_different_pointers.c dlwrap.c dlwrap.h -egl_and_glx_different_pointers_egl_glx_LDADD = libegl_common.la libglx_common.la $(DLOPEN_LIBS) $(EPOXY) $(X11_LIBS) -egl_and_glx_different_pointers_egl_glx_LDFLAGS = -rdynamic -egl_and_glx_different_pointers_egl_glx_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_EGL -DUSE_GLX - glx_alias_prefer_same_name_SOURCES = glx_alias_prefer_same_name.c dlwrap.c dlwrap.h glx_alias_prefer_same_name_LDFLAGS = -rdynamic glx_alias_prefer_same_name_LDADD = $(EPOXY) libglx_common.la $(X11_LIBS) $(DLOPEN_LIBS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/cgl_core.c new/libepoxy-1.5.3/test/cgl_core.c --- old/libepoxy-1.5.0/test/cgl_core.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libepoxy-1.5.3/test/cgl_core.c 2018-10-05 01:12:11.000000000 +0200 @@ -0,0 +1,54 @@ +/* This is a copy of the test used by HomeBrew's libepoxy recipe, + * originally written by Mikko Lehtonen. + * + * The Homebrew recipe is released under the BSD 2-Clause license. + * + * Copyright (c) 2009-present, Homebrew contributors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <epoxy/gl.h> +#include <Carbon/Carbon.h> +#include <OpenGL/OpenGL.h> +#include <OpenGL/CGLTypes.h> +#include <OpenGL/CGLCurrent.h> +#include <OpenGL/CGLContext.h> + +int +main (void) +{ + CGLPixelFormatAttribute attribs[] = {0}; + CGLPixelFormatObj pix; + CGLContextObj ctx; + int npix; + + CGLChoosePixelFormat(attribs, &pix, &npix); + CGLCreateContext(pix, (void *) 0, &ctx); + + glClear(GL_COLOR_BUFFER_BIT); + + CGLReleaseContext(ctx); + CGLReleasePixelFormat(pix); + + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/cgl_epoxy_api.c new/libepoxy-1.5.3/test/cgl_epoxy_api.c --- old/libepoxy-1.5.0/test/cgl_epoxy_api.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libepoxy-1.5.3/test/cgl_epoxy_api.c 2018-10-05 01:12:11.000000000 +0200 @@ -0,0 +1,83 @@ +/* + * Copyright 2018 Emmanuele Bassi + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** + * @file cgl_epoxy_api.c + * + * Tests the Epoxy API using the CoreGraphics OpenGL framework. + */ + +#include <epoxy/gl.h> +#include <Carbon/Carbon.h> +#include <OpenGL/OpenGL.h> +#include <OpenGL/CGLTypes.h> +#include <OpenGL/CGLCurrent.h> +#include <OpenGL/CGLContext.h> + +int +main (void) +{ + CGLPixelFormatAttribute attribs[] = {0}; + CGLPixelFormatObj pix; + CGLContextObj ctx; + const char *string; + bool pass = true; + int npix; + GLint shader; + + CGLChoosePixelFormat(attribs, &pix, &npix); + CGLCreateContext(pix, (void *) 0, &ctx); + CGLSetCurrentContext(ctx); + + if (!epoxy_is_desktop_gl()) { + fputs("Claimed not to be desktop\n", stderr); + pass = false; + } + + if (epoxy_gl_version() < 20) { + fprintf(stderr, "Claimed to be GL version %d\n", + epoxy_gl_version()); + pass = false; + } + + if (epoxy_glsl_version() < 100) { + fprintf(stderr, "Claimed to have GLSL version %d\n", + epoxy_glsl_version()); + pass = false; + } + + string = (const char *)glGetString(GL_VERSION); + printf("GL version: %s - Epoxy: %d\n", string, epoxy_gl_version()); + + string = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); + printf("GLSL version: %s - Epoxy: %d\n", string, epoxy_glsl_version()); + + shader = glCreateShader(GL_FRAGMENT_SHADER); + pass = glIsShader(shader); + + CGLSetCurrentContext(NULL); + CGLReleaseContext(ctx); + CGLReleasePixelFormat(pix); + + return pass != true; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/dlwrap.c new/libepoxy-1.5.3/test/dlwrap.c --- old/libepoxy-1.5.0/test/dlwrap.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/dlwrap.c 2018-10-05 01:12:11.000000000 +0200 @@ -242,7 +242,8 @@ "GLIBC_2.3", "GLIBC_2.2.5", "GLIBC_2.2", - "GLIBC_2.0" + "GLIBC_2.0", + "FBSD_1.0" }; int num_versions = sizeof(version) / sizeof(version[0]); int i; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/egl_and_glx_different_pointers.c new/libepoxy-1.5.3/test/egl_and_glx_different_pointers.c --- old/libepoxy-1.5.0/test/egl_and_glx_different_pointers.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/egl_and_glx_different_pointers.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,246 +0,0 @@ -/* - * Copyright © 2014 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/** - * @file egl_and_glx_different_pointers.c - * - * Tests that epoxy correctly handles an EGL and GLX implementation - * that return different function pointers between the two. - * - * This is the case for EGL and GLX on nvidia binary drivers - * currently, but is also the case if someone has nvidia binary GLX - * installed but still has Mesa (software) EGL installed. This seems - * common enough that we should make sure things work. - */ - -#define _GNU_SOURCE - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> -#include <err.h> -#include <dlfcn.h> -#include "epoxy/gl.h" -#include "epoxy/egl.h" -#include "epoxy/glx.h" - -#include "egl_common.h" -#include "glx_common.h" -#include "dlwrap.h" - -#define GLX_FAKED_VENDOR_STRING "libepoxy override GLX" -#define EGL_FAKED_VENDOR_STRING "libepoxy override EGL" - -#define GL_CREATESHADER_VALUE 1234 -#define GLES2_CREATESHADER_VALUE 5678 - -const char *override_GLES2_glGetString(GLenum e); -const char *override_GL_glGetString(GLenum e); -GLuint override_GLES2_glCreateShader(GLenum e); -GLuint override_GL_glCreateShader(GLenum e); - -const char * -override_GL_glGetString(GLenum e) -{ - if (e == GL_VENDOR) - return GLX_FAKED_VENDOR_STRING; - - return DEFER_TO_GL("libGL.so.1", override_GL_glGetString, - "glGetString", (e)); -} - -const char * -override_GLES2_glGetString(GLenum e) -{ - if (e == GL_VENDOR) - return EGL_FAKED_VENDOR_STRING; - - return DEFER_TO_GL("libGLESv2.so.2", override_GLES2_glGetString, - "glGetString", (e)); -} - -GLuint -override_GL_glCreateShader(GLenum type) -{ - return GL_CREATESHADER_VALUE; -} - -GLuint -override_GLES2_glCreateShader(GLenum type) -{ - return GLES2_CREATESHADER_VALUE; -} - -#ifdef USE_GLX -static bool -make_glx_current_and_test(Display *dpy, GLXContext ctx, Drawable draw) -{ - const char *string; - GLuint shader; - bool pass = true; - - glXMakeCurrent(dpy, draw, ctx); - - if (!epoxy_is_desktop_gl()) { - fputs("Claimed to be ES\n", stderr); - pass = false; - } - - string = (const char *)glGetString(GL_VENDOR); - printf("GLX vendor: %s\n", string); - - shader = glCreateShader(GL_FRAGMENT_SHADER); - if (shader != GL_CREATESHADER_VALUE) { - fprintf(stderr, "glCreateShader() returned %d instead of %d\n", - shader, GL_CREATESHADER_VALUE); - pass = false; - } - - pass = pass && !strcmp(string, GLX_FAKED_VENDOR_STRING); - - return pass; -} - -static void -init_glx(Display **out_dpy, GLXContext *out_ctx, Drawable *out_draw) -{ - Display *dpy = get_display_or_skip(); - make_glx_context_current_or_skip(dpy); - - *out_dpy = dpy; - *out_ctx = glXGetCurrentContext(); - *out_draw= glXGetCurrentDrawable(); -} -#endif /* USE_GLX */ - -#ifdef USE_EGL -static bool -make_egl_current_and_test(EGLDisplay *dpy, EGLContext ctx) -{ - const char *string; - GLuint shader; - bool pass = true; - - eglMakeCurrent(dpy, NULL, NULL, ctx); - - if (epoxy_is_desktop_gl()) { - fputs("Claimed to be desktop\n", stderr); - pass = false; - } - - if (epoxy_gl_version() < 20) { - fprintf(stderr, "Claimed to be GL version %d\n", - epoxy_gl_version()); - pass = false; - } - - shader = glCreateShader(GL_FRAGMENT_SHADER); - if (shader != GLES2_CREATESHADER_VALUE) { - fprintf(stderr, "glCreateShader() returned %d instead of %d\n", - shader, GLES2_CREATESHADER_VALUE); - pass = false; - } - - string = (const char *)glGetString(GL_VENDOR); - printf("EGL vendor: %s\n", string); - - pass = pass && !strcmp(string, EGL_FAKED_VENDOR_STRING); - - return pass; -} - -static void -init_egl(EGLDisplay **out_dpy, EGLContext *out_ctx) -{ - EGLDisplay *dpy = get_egl_display_or_skip(); - static const EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - EGL_NONE - }; - static const EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - EGLContext ctx; - EGLConfig cfg; - EGLint count; - - if (!epoxy_has_egl_extension(dpy, "EGL_KHR_surfaceless_context")) - errx(77, "Test requires EGL_KHR_surfaceless_context"); - - eglBindAPI(EGL_OPENGL_ES_API); - - if (!eglChooseConfig(dpy, config_attribs, &cfg, 1, &count)) - errx(77, "Couldn't get an EGLConfig\n"); - - ctx = eglCreateContext(dpy, cfg, NULL, context_attribs); - if (!ctx) - errx(77, "Couldn't create a GLES2 context\n"); - - *out_dpy = dpy; - *out_ctx = ctx; -} -#endif /* USE_EGL */ - -int -main(int argc, char **argv) -{ - bool pass = true; -#ifdef USE_EGL - EGLDisplay *egl_dpy; - EGLContext egl_ctx; -#endif -#ifdef USE_GLX - Display *glx_dpy; - GLXContext glx_ctx; - Drawable glx_draw; -#endif - - /* Force epoxy to have loaded both EGL and GLX libs already -- we - * can't assume anything about symbol resolution based on having - * EGL or GLX loaded. - */ - (void)glXGetCurrentContext(); - (void)eglGetCurrentContext(); - -#ifdef USE_GLX - init_glx(&glx_dpy, &glx_ctx, &glx_draw); - pass = make_glx_current_and_test(glx_dpy, glx_ctx, glx_draw) && pass; -#endif -#ifdef USE_EGL - init_egl(&egl_dpy, &egl_ctx); - pass = make_egl_current_and_test(egl_dpy, egl_ctx) && pass; -#endif - -#if defined(USE_GLX) && defined(USE_EGL) - pass = make_glx_current_and_test(glx_dpy, glx_ctx, glx_draw) && pass; - pass = make_egl_current_and_test(egl_dpy, egl_ctx) && pass; -#endif - - return pass != true; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/egl_epoxy_api.c new/libepoxy-1.5.3/test/egl_epoxy_api.c --- old/libepoxy-1.5.0/test/egl_epoxy_api.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/egl_epoxy_api.c 2018-10-05 01:12:11.000000000 +0200 @@ -27,6 +27,7 @@ * Tests the Epoxy API using EGL. */ +#define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <stdlib.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/egl_has_extension_nocontext.c new/libepoxy-1.5.3/test/egl_has_extension_nocontext.c --- old/libepoxy-1.5.0/test/egl_has_extension_nocontext.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/egl_has_extension_nocontext.c 2018-10-05 01:12:11.000000000 +0200 @@ -28,6 +28,7 @@ * no context bound would fail out in dispatch. */ +#define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <stdlib.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/egl_without_glx.c new/libepoxy-1.5.3/test/egl_without_glx.c --- old/libepoxy-1.5.0/test/egl_without_glx.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/egl_without_glx.c 2018-10-05 01:12:11.000000000 +0200 @@ -54,15 +54,17 @@ { void * (*dlopen_unwrapped)(const char *filename, int flag); - if (!strcmp(filename, "libGL.so.1")) - return NULL; + if (filename) { + if (!strcmp(filename, "libGL.so.1")) + return NULL; #if GLES_VERSION == 2 - if (!strcmp(filename, "libGLESv1_CM.so.1")) - return NULL; + if (!strcmp(filename, "libGLESv1_CM.so.1")) + return NULL; #else - if (!strcmp(filename, "libGLESv2.so.2")) - return NULL; + if (!strcmp(filename, "libGLESv2.so.2")) + return NULL; #endif + } dlopen_unwrapped = dlsym(RTLD_NEXT, "dlopen"); assert(dlopen_unwrapped); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/glx_public_api_core.c new/libepoxy-1.5.3/test/glx_public_api_core.c --- old/libepoxy-1.5.0/test/glx_public_api_core.c 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/glx_public_api_core.c 2018-10-05 01:12:11.000000000 +0200 @@ -131,6 +131,12 @@ return true; } +static int +error_handler(Display *d, XErrorEvent *ev) +{ + return 0; +} + int main(int argc, char **argv) { @@ -148,6 +154,7 @@ None }; GLXContext ctx; + int (*old_handler)(Display *, XErrorEvent *); dpy = get_display_or_skip(); @@ -157,9 +164,12 @@ visinfo = get_glx_visual(dpy); win = get_glx_window(dpy, visinfo, false); config = get_fbconfig_for_visinfo(dpy, visinfo); + + old_handler = XSetErrorHandler(error_handler); ctx = glXCreateContextAttribsARB(dpy, config, NULL, True, attribs); if (ctx == None) errx(77, "glXCreateContext failed"); + XSetErrorHandler(old_handler); glXMakeCurrent(dpy, win, ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libepoxy-1.5.0/test/meson.build new/libepoxy-1.5.3/test/meson.build --- old/libepoxy-1.5.0/test/meson.build 2018-02-24 15:09:37.000000000 +0100 +++ new/libepoxy-1.5.3/test/meson.build 2018-10-05 01:12:11.000000000 +0200 @@ -1,11 +1,17 @@ +dl_dep = cc.find_library('dl', required: false) +has_dlvsym = cc.has_function('dlvsym', dependencies: dl_dep) + has_gles1 = gles1_dep.found() has_gles2 = gles2_dep.found() build_x11_tests = enable_x11 and x11_dep.found() -test_cflags = common_cflags + [ +test_cflags = common_cflags +if not has_dlvsym +test_cflags += [ '-D_XOPEN_SOURCE', '-D_POSIX_C_SOURCE=200809L', ] +endif # Unconditionally built tests test('header_guards', @@ -92,8 +98,8 @@ [ 'glx_has_extension_nocontext', [ 'glx_has_extension_nocontext.c' ], [], [], true ], [ 'glx_static', [ 'glx_static.c' ], [ '-DNEEDS_TO_BE_STATIC'], [ '-static' ], libtype == 'static' ], [ 'glx_shared_znow', [ 'glx_static.c', ], [], [ '-Wl,-z,now' ], has_znow ], - [ 'glx_alias_prefer_same_name', [ 'glx_alias_prefer_same_name.c', 'dlwrap.c', 'dlwrap.h' ], [], [ '-rdynamic' ], not build_apple ], - [ 'glx_gles2', [ 'glx_gles2.c', 'dlwrap.c', 'dlwrap.h' ], [], [ '-rdynamic' ], not build_apple ], + [ 'glx_alias_prefer_same_name', [ 'glx_alias_prefer_same_name.c', 'dlwrap.c', 'dlwrap.h' ], [], [ '-rdynamic' ], has_dlvsym ], + [ 'glx_gles2', [ 'glx_gles2.c', 'dlwrap.c', 'dlwrap.h' ], [], [ '-rdynamic' ], has_dlvsym ], ] foreach test: glx_tests @@ -113,41 +119,6 @@ test(test_name, test_bin) endif endforeach - - if not build_apple - # GLX/EGL tests - if build_egl - glx_egl_sources = [ - 'egl_and_glx_different_pointers.c', - 'dlwrap.c', - 'dlwrap.h', - ] - - glx_egl_deps = [ libepoxy_dep, x11_dep, dl_dep ] - glx_egl_link_flags = [ '-rdynamic' ] - glx_egl_link_with = [ glx_common_lib, egl_common_lib ] - - glx_egl_tests = [ - [ 'egl_and_glx_different_pointers_glx', [ '-DUSE_GLX' ], false ], - [ 'egl_and_glx_different_pointers_egl', [ '-DUSE_EGL' ], false ], - [ 'egl_and_glx_different_pointers_egl_glx', [ '-DUSE_EGL', '-DUSE_GLX' ], true ], - ] - - foreach test: glx_egl_tests - test_name = test[0] - test_c_args = test[1] - test_should_fail = test[2] - - test_bin = executable(test_name, glx_egl_sources, - c_args: common_cflags + test_c_args, - include_directories: libepoxy_inc, - dependencies: glx_egl_deps, - link_with: glx_egl_link_with, - link_args: glx_egl_link_flags) - test(test_name, test_bin, should_fail: test_should_fail) - endforeach - endif - endif endif # WGL @@ -181,3 +152,27 @@ test(test_name, test_bin) endforeach endif + +# Apple +if host_machine.system().contains('darwin') + opengl_dep = dependency('appleframeworks', modules: ['OpenGL', 'Carbon'], required: true) + + cgl_tests = [ + [ 'cgl_core', [ 'cgl_core.c' ] ], + [ 'cgl_epoxy_api', [ 'cgl_epoxy_api.c' ] ], + ] + + foreach t: cgl_tests + test_name = t[0] + test_sources = t[1] + + test(test_name, + executable( + test_name, test_sources, + c_args: test_cflags, + include_directories: libepoxy_inc, + dependencies: [ libepoxy_dep, opengl_dep ], + ), + ) + endforeach +endif
