Commits (14)
......@@ -2,7 +2,7 @@ dnl configure.ac
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([libglvnd], [1.3.2], [kbrenneman@nvidia.com])
AC_INIT([libglvnd], [1.3.3], [kbrenneman@nvidia.com])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
......@@ -106,6 +106,16 @@ AM_CONDITIONAL([ENABLE_GLX_HEADERS], [test "x$enable_headers" = "xyes" -a "x$ena
AM_CONDITIONAL([ENABLE_GLES1_HEADERS], [test "x$enable_headers" = "xyes" -a "x$enable_gles1" = "xyes"])
AM_CONDITIONAL([ENABLE_GLES2_HEADERS], [test "x$enable_headers" = "xyes" -a "x$enable_gles2" = "xyes"])
AC_ARG_ENABLE([entrypoint-patching],
[AS_HELP_STRING([--disable-entrypoint-patching],
[Disable OpenGL entrypoint patching optimization @<:@default=enabled@:>@])],
[enable_entrypoint_patching="$enableval"],
[enable_entrypoint_patching=yes]
)
AS_IF([test "x$enable_entrypoint_patching" = "xyes"],
[AC_DEFINE([GLDISPATCH_ENABLE_PATCHING], 1,
[Define to 1 to enable entrypoint patching in libGLdispatch.])])
dnl
dnl Arch/platform-specific settings. Copied from mesa
dnl
......@@ -201,10 +211,6 @@ if test "x$enable_glx" = "xyes" ; then
PKG_CHECK_MODULES([GLPROTO], [glproto])
fi
AS_IF([test "x$gldispatch_use_tls" = "xyes"],
[AC_DEFINE([GLDISPATCH_USE_TLS], 1,
[Define to 1 if libGLdispatch should use a TLS variable for the dispatch table.])])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_TYPEOF
......@@ -236,8 +242,8 @@ AC_MSG_RESULT($HAVE_INIT_TLS)
AC_MSG_CHECKING([for entrypoint stub type])
case "x$asm_arch" in
xx86 | xx86_64)
# For x86 and x86-64, both the TLS and TSD stubs work.
xx86 | xx86_64 | xppc64)
# For x86, x86-64, and ppc64, both the TLS and TSD stubs work.
if test "x$HAVE_INIT_TLS" = "xyes" ; then
gldispatch_entry_type=${asm_arch}_tls
gldispatch_use_tls=yes
......@@ -256,16 +262,6 @@ xaarch64)
gldispatch_entry_type=aarch64_tsd
gldispatch_use_tls=no
;;
xppc64)
# For ppc64, allow both the TLS and TSD stubs for now.
if test "x$HAVE_INIT_TLS" = "xyes" ; then
gldispatch_entry_type=ppc64_tls
gldispatch_use_tls=yes
else
gldispatch_entry_type=ppc64_tsd
gldispatch_use_tls=no
fi
;;
*)
# The C stubs will work with either TLS or TSD.
gldispatch_entry_type=pure_c
......
......@@ -28,7 +28,7 @@
project(
'glvnd',
'c',
version : '1.3.2',
version : '1.3.3',
meson_version : '>= 0.48',
default_options : ['c_std=gnu99']
)
......@@ -132,17 +132,18 @@ endif
gl_dispatch_type = 'pure_c'
if use_asm
thread_type = have_tls ? 'tls' : 'tsd'
if host_machine.cpu_family().startswith('x86')
gl_dispatch_type = '@0@_@1@'.format(
host_machine.cpu_family(),
have_tls ? 'tls' : 'tsd',
thread_type,
)
elif host_machine.cpu_family() == 'arm'
gl_dispatch_type = 'armv7_tsd'
elif host_machine.cpu_family() == 'aarch64'
gl_dispatch_type = 'aarch64_tsd'
elif host_machine.cpu_family() == 'ppc64'
gl_dispatch_type = 'ppc64_@0@'.format(have_tls ? 'tls' : 'tsd')
gl_dispatch_type = 'ppc64_@0@'.format(thread_type)
endif
endif
message('Using dispatch stub type: @0@'.format(gl_dispatch_type))
......@@ -190,6 +191,10 @@ if _p != 0
add_project_arguments('-DGLDISPATCH_PAGE_SIZE=' + _p, language : ['c'])
endif
if not get_option('entrypoint-patching').disabled()
add_project_arguments('-DGLDISPATCH_ENABLE_PATCHING', language : ['c'])
endif
# Set EGL_NO_X11 unconditionally, Libglvnd doesn't make any assumptions about
# native display or drawable types, so we don't need X11-specific typedefs for
# them
......
......@@ -75,3 +75,8 @@ option(
value : true,
description : 'Install headers for enabled APIs.'
)
option(
'entrypoint-patching',
type : 'feature',
description : 'Allow vendor libraries to patch OpenGL entrypoint functions.'
)
......@@ -276,7 +276,9 @@ static EGLBoolean AddVendorDevices(__EGLvendorInfo *vendor)
}
if (!vendor->staticDispatch.queryDevicesEXT(0, NULL, &count)) {
return EGL_FALSE;
// Even if this vendor fails, we can still return the devices from any
// other vendors
return EGL_TRUE;
}
if (count <= 0) {
return EGL_TRUE;
......
......@@ -126,6 +126,10 @@ __asm__(".globl glx_entrypoint_start\n"
".balign " U_STRINGIFY(STUB_SIZE) "\n" \
"glx_entrypoint_start:\n"
#if defined(USE_ARMV7_ASM) && defined(__thumb__)
".arm\n"
#endif
#define GLX_STUBS_ASM
#include "g_glx_dispatch_stub_list.h"
......@@ -133,6 +137,10 @@ __asm__(".globl glx_entrypoint_start\n"
".hidden glx_entrypoint_end\n"
".balign " U_STRINGIFY(STUB_SIZE) "\n" \
"glx_entrypoint_end:\n"
#if defined(USE_ARMV7_ASM) && defined(__thumb__)
".thumb\n"
#endif
);
static void *DefaultDispatchFunc(void)
......
......@@ -95,6 +95,7 @@ static DEFINE_INITIALIZED_LKDHASH(__GLXvendorNameHash, __glXVendorNameHash);
typedef struct __GLXdisplayInfoHashRec {
__GLXdisplayInfo info;
Bool inTeardown;
UT_hash_handle hh;
} __GLXdisplayInfoHash;
......@@ -697,15 +698,27 @@ static int OnDisplayClosed(Display *dpy, XExtCodes *codes)
LKDHASH_WRLOCK(__glXDisplayInfoHash);
// Set the inTeardown flag for this display, but don't remove it from the
// hashtable yet. We shouldn't try to look up this display after this, but
// just in case something does, we don't want to try to set up a new
// __GLXdisplayInfoHash struct for it.
HASH_FIND_PTR(_LH(__glXDisplayInfoHash), &dpy, pEntry);
if (pEntry != NULL) {
__glXDisplayClosed(&pEntry->info);
HASH_DEL(_LH(__glXDisplayInfoHash), pEntry);
assert(!pEntry->inTeardown);
pEntry->inTeardown = True;
}
LKDHASH_UNLOCK(__glXDisplayInfoHash);
CleanupDisplayInfoEntry(NULL, pEntry);
free(pEntry);
if (pEntry != NULL) {
__glXDisplayClosed(&pEntry->info);
// Now, we can remove the display from the hashtable and free it.
LKDHASH_WRLOCK(__glXDisplayInfoHash);
HASH_DEL(_LH(__glXDisplayInfoHash), pEntry);
LKDHASH_UNLOCK(__glXDisplayInfoHash);
CleanupDisplayInfoEntry(NULL, pEntry);
free(pEntry);
}
return 0;
}
......@@ -724,6 +737,12 @@ __GLXdisplayInfo *__glXLookupDisplay(Display *dpy)
LKDHASH_UNLOCK(__glXDisplayInfoHash);
if (pEntry != NULL) {
if (pEntry->inTeardown) {
// This shouldn't happen: If we're in the process of tearing down a
// display, then we shouldn't be trying to look up the display
// again.
return NULL;
}
return &pEntry->info;
}
......
......@@ -41,6 +41,7 @@
static int entry_patch_mprotect(int prot)
{
#if GLDISPATCH_ENABLE_PATCHING
size_t size;
size_t pageSize = (size_t) sysconf(_SC_PAGESIZE);
......@@ -57,6 +58,9 @@ static int entry_patch_mprotect(int prot)
return 0;
}
return 1;
#else // GLDISPATCH_ENABLE_PATCHING
return 0;
#endif
}
int entry_patch_start(void)
......
......@@ -149,6 +149,13 @@ int main(int argc, char **argv)
}
#endif
#if !defined(GLDISPATCH_ENABLE_PATCHING)
if (enablePatching)
{
return 77;
}
#endif
__glDispatchInit();
InitDummyVendors();
......