[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libglvnd: Changes to 'upstream-unstable'



 configure.ac                          |   24 ++++
 src/EGL/libegl.c                      |   71 ++++++++-----
 src/GLdispatch/GLdispatch.c           |  177 ++++++++--------------------------
 src/GLdispatch/GLdispatchPrivate.h    |    7 -
 src/GLdispatch/vnd-glapi/Makefile.am  |   11 --
 src/GLdispatch/vnd-glapi/glapi.h      |   11 +-
 src/GLdispatch/vnd-glapi/mapi_glapi.c |    7 +
 src/GLdispatch/vnd-glapi/stub.c       |   89 +++++++----------
 src/GLdispatch/vnd-glapi/stub.h       |    2 
 src/Makefile.am                       |   26 +++-
 src/generate/gen_gldispatch_mapi.py   |   17 ---
 src/generate/gl_inittable.py          |  164 -------------------------------
 src/generate/gl_table.py              |   63 ------------
 src/generate/glvnd_gen.mk             |   22 ----
 tests/Makefile.am                     |  145 ++++++++++++++++-----------
 tests/dummy/Makefile.am               |   14 +-
 16 files changed, 288 insertions(+), 562 deletions(-)

New commits:
commit 7067ba11c58f6f95a3b1bc1a3ebe342ce806fcde
Author: Kyle Brenneman <kbrenneman@nvidia.com>
Date:   Thu Dec 22 13:03:40 2016 -0700

    configure: Change the description for --disable-gles.

diff --git a/configure.ac b/configure.ac
index 2aaa287..fdfaf00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,7 @@ AM_CONDITIONAL([ENABLE_GLX], [test "x$enable_glx" = "xyes"])
 
 AC_ARG_ENABLE([gles],
     [AS_HELP_STRING([--disable-gles],
-        [Disable GLES support @<:@default=enabled@:>@])],
+        [Do not build the libGLES*.so libraries @<:@default=enabled@:>@])],
     [enable_gles="$enableval"],
     [enable_gles=yes]
 )

commit ca0de36630bb338e95e99c6ea8fde274fea42149
Author: Kyle Brenneman <kbrenneman@nvidia.com>
Date:   Tue Dec 13 15:45:26 2016 -0700

    Add configure options for the EGL, GLX, and GLES libraries.
    
    Added three new configure options to disable building the EGL, GLX, GLES
    libraries.
    
    In the tests makefile, move the list of test scripts to separate unconditional
    variables, and add those to EXTRA_DIST. Just conditionally adding variables to
    TESTS isn't enough to include the test scripts in the dist package.

diff --git a/configure.ac b/configure.ac
index 1c0e6bf..2aaa287 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,30 @@ if test "x$ac_cv_prog_cc_c99" = xno; then
         AC_MSG_ERROR([Building libglvnd requires a C99-enabled compiler])
 fi
 
+AC_ARG_ENABLE([egl],
+    [AS_HELP_STRING([--disable-egl],
+        [Disable EGL support @<:@default=enabled@:>@])],
+    [enable_egl="$enableval"],
+    [enable_egl=yes]
+)
+AM_CONDITIONAL([ENABLE_EGL], [test "x$enable_egl" = "xyes"])
+
+AC_ARG_ENABLE([glx],
+    [AS_HELP_STRING([--disable-glx],
+        [Disable GLX support @<:@default=enabled@:>@])],
+    [enable_glx="$enableval"],
+    [enable_glx=yes]
+)
+AM_CONDITIONAL([ENABLE_GLX], [test "x$enable_glx" = "xyes"])
+
+AC_ARG_ENABLE([gles],
+    [AS_HELP_STRING([--disable-gles],
+        [Disable GLES support @<:@default=enabled@:>@])],
+    [enable_gles="$enableval"],
+    [enable_gles=yes]
+)
+AM_CONDITIONAL([ENABLE_GLES], [test "x$enable_gles" = "xyes"])
+
 dnl
 dnl Arch/platform-specific settings. Copied from mesa
 dnl
diff --git a/src/Makefile.am b/src/Makefile.am
index 6379ccf..c3f4fcf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,11 +1,21 @@
-SUBDIRS = util \
-	GLdispatch \
-	EGL \
-	GLX \
-	OpenGL \
-	GLESv1 \
-	GLESv2 \
-	GL
+SUBDIRS =
+SUBDIRS += util
+SUBDIRS += GLdispatch
+SUBDIRS += OpenGL
+
+if ENABLE_EGL
+SUBDIRS += EGL
+endif
+
+if ENABLE_GLX
+SUBDIRS += GLX
+SUBDIRS += GL
+endif
+
+if ENABLE_GLES
+SUBDIRS += GLESv1
+SUBDIRS += GLESv2
+endif
 
 EXTRA_DIST = generate
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5212a08..fb8408f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -68,12 +68,26 @@ testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testpatchentrypoints_gldispatch_LDADD += dummy/libpatchentrypoints.la
 testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/util/libutils_misc.la
 
-
-TESTS += testglxmcbasic.sh
-TESTS += testglxmcloop.sh
-TESTS += testglxmcthreads.sh
-TESTS += testglxmclate.sh
-TESTS += testglxmcoldlink.sh
+# Start of GLX-specific tests.
+# Notes that the TESTS_GLX variable must be defined outside the conditional, so
+# that we can include the test scripts in the EXTRA_DIST package. Otherwise,
+# the scripts would be missing when you run "make dist" or "make distcheck".
+
+TESTS_GLX =
+TESTS_GLX += testglxmcbasic.sh
+TESTS_GLX += testglxmcloop.sh
+TESTS_GLX += testglxmcthreads.sh
+TESTS_GLX += testglxmclate.sh
+TESTS_GLX += testglxmcoldlink.sh
+TESTS_GLX += testglxgetprocaddress.sh
+TESTS_GLX += testglxgetprocaddress_genentry.sh
+TESTS_GLX += testglxgetclientstr.sh
+TESTS_GLX += testglxqueryversion.sh
+TESTS_GLX += testpatchentrypoints.sh
+
+if ENABLE_GLX
+
+TESTS += $(TESTS_GLX)
 
 TESTGLXMAKECURRENT_SOURCES_COMMON = \
 	testglxmakecurrent.c \
@@ -96,14 +110,11 @@ testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libglvnd_pthread.la
 testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libtrace.la
 
 
-TESTS += testglxgetprocaddress.sh
-TESTS += testglxgetprocaddress_genentry.sh
 check_PROGRAMS += testglxgetprocaddress
 testglxgetprocaddress_LDADD = -lX11
 testglxgetprocaddress_LDADD += $(top_builddir)/src/GLX/libGLX.la
 
 
-TESTS += testglxgetclientstr.sh
 check_PROGRAMS += testglxgetclientstr
 testglxgetclientstr_LDADD = -lX11
 testglxgetclientstr_LDADD += $(top_builddir)/src/GLX/libGLX.la
@@ -111,14 +122,12 @@ testglxgetclientstr_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testglxgetclientstr_LDADD += $(top_builddir)/src/util/libtrace.la
 
 
-TESTS += testglxqueryversion.sh
 check_PROGRAMS += testglxqueryversion
 testglxqueryversion_LDADD = -lX11
 testglxqueryversion_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testglxqueryversion_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
 
-TESTS += testpatchentrypoints.sh
 check_PROGRAMS += testpatchentrypoints
 testpatchentrypoints_SOURCES = \
 	testpatchentrypoints.c \
@@ -129,29 +138,41 @@ testpatchentrypoints_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testpatchentrypoints_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testpatchentrypoints_LDADD += $(top_builddir)/src/util/libtrace.la
 
+endif # ENABLE_GLX
+
+
+# Start of EGL-specific tests.
+
+TESTS_EGL =
+TESTS_EGL += testegldisplay.sh
+TESTS_EGL += testegldevice.sh
+TESTS_EGL += testeglgetprocaddress.sh
+TESTS_EGL += testeglmakecurrent.sh
+TESTS_EGL += testeglerror.sh
+TESTS_EGL += testegldebug.sh
+
+if ENABLE_EGL
+
+TESTS += $(TESTS_EGL)
 
-TESTS += testegldisplay.sh
 check_PROGRAMS += testegldisplay
 testegldisplay_SOURCES = \
 	testegldisplay.c \
 	egl_test_utils.c
 testegldisplay_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
-TESTS += testegldevice.sh
 check_PROGRAMS += testegldevice
 testegldevice_SOURCES = \
 	testegldevice.c \
 	egl_test_utils.c
 testegldevice_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
-TESTS += testeglgetprocaddress.sh
 check_PROGRAMS += testeglgetprocaddress
 testeglgetprocaddress_SOURCES = \
 	testeglgetprocaddress.c \
 	egl_test_utils.c
 testeglgetprocaddress_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
-TESTS += testeglmakecurrent.sh
 check_PROGRAMS += testeglmakecurrent
 testeglmakecurrent_SOURCES = \
 	testeglmakecurrent.c \
@@ -159,7 +180,6 @@ testeglmakecurrent_SOURCES = \
 testeglmakecurrent_LDADD = $(top_builddir)/src/EGL/libEGL.la
 testeglmakecurrent_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
-TESTS += testeglerror.sh
 check_PROGRAMS += testeglerror
 testeglerror_SOURCES = \
 	testeglerror.c \
@@ -168,9 +188,12 @@ testeglerror_LDADD = $(top_builddir)/src/EGL/libEGL.la
 testeglerror_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
 
-TESTS += testegldebug.sh
 check_PROGRAMS += testegldebug
 testegldebug_SOURCES = \
 	testegldebug.c \
 	egl_test_utils.c
 testegldebug_LDADD = $(top_builddir)/src/EGL/libEGL.la
+
+endif # ENABLE_EGL
+
+EXTRA_DIST += $(TESTS_GLX) $(TESTS_EGL)
diff --git a/tests/dummy/Makefile.am b/tests/dummy/Makefile.am
index 881ce9f..419a3d8 100644
--- a/tests/dummy/Makefile.am
+++ b/tests/dummy/Makefile.am
@@ -13,6 +13,7 @@ libpatchentrypoints_la_CFLAGS = \
 libpatchentrypoints_la_SOURCES = \
 	patchentrypoints.c
 
+if ENABLE_GLX
 check_LTLIBRARIES += libGLX_dummy.la
 libGLX_dummy_la_CFLAGS = \
 	-I$(top_srcdir)/src/GLX        \
@@ -29,7 +30,9 @@ libGLX_dummy_la_LIBADD += libpatchentrypoints.la
 libGLX_dummy_la_LDFLAGS = \
 	-shared \
 	-rpath /nowhere
+endif # ENABLE_GLX
 
+if ENABLE_EGL
 EGL_DUMMY_CFLAGS_COMMON = \
 	-I$(top_srcdir)/src/util \
 	-I$(top_srcdir)/include
@@ -56,3 +59,4 @@ libEGL_dummy1_la_SOURCES = $(EGL_DUMMY_SOURCES_COMMON)
 libEGL_dummy1_la_LIBADD = $(EGL_DUMMY_LIBADD_COMMON)
 libEGL_dummy1_la_LDFLAGS = $(EGL_DUMMY_LDFLAGS_COMMON)
 
+endif # ENABLE_EGL

commit 152ba20ff1f4dbc8fa2e9622747bc8c65908b1a7
Author: Kyle Brenneman <kbrenneman@nvidia.com>
Date:   Fri Dec 2 14:45:37 2016 -0700

    tests: Clean up tests makefile.
    
    Split up the TESTS and check_PROGRAMS variable assignments, so that they're
    assigned next to the commands to build each test.
    
    In addition to better readability and making it easier to avoid merge
    conflicts, this will allow making some of the tests conditional based on build
    options.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 29eab01..5212a08 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,62 +37,16 @@ TESTS_ENVIRONMENT = \
 	TOP_BUILDDIR=$(top_builddir) \
 	ABS_TOP_BUILDDIR=$(abs_top_builddir)
 
-TESTS = \
-	testglxgetprocaddress.sh \
-	testglxgetprocaddress_genentry.sh \
-	testglxmcbasic.sh \
-	testglxmcloop.sh \
-	testglxmcthreads.sh \
-	testglxmclate.sh \
-	testglxmcoldlink.sh \
-	testglxgetclientstr.sh \
-	testglxqueryversion.sh \
-	testpatchentrypoints.sh \
-	testpatchentrypoints_gldispatch.sh \
-	testegldisplay.sh \
-	testegldevice.sh \
-	testeglgetprocaddress.sh \
-	testeglmakecurrent.sh \
-	testeglerror.sh \
-	testegldebug.sh
+TESTS =
+check_PROGRAMS =
 
 EXTRA_DIST = $(TESTS) \
 	glxenv.sh \
 	eglenv.sh \
 	json
 
-check_PROGRAMS = \
-	testglxgetprocaddress \
-	testglxmakecurrent \
-	testglxmakecurrent_oldlink \
-	testglxgetclientstr \
-	testglxqueryversion \
-	testpatchentrypoints \
-	testpatchentrypoints_gldispatch \
-	testegldisplay \
-	testegldevice \
-	testeglgetprocaddress \
-	testeglmakecurrent \
-	testeglerror \
-	testegldebug
-
 # The *_oldlink variant tests that linking against legacy libGL.so works
 
-TESTGLXMAKECURRENT_SOURCES_COMMON = \
-	testglxmakecurrent.c \
-	test_utils.c
-
-testglxmakecurrent_SOURCES = \
-	$(TESTGLXMAKECURRENT_SOURCES_COMMON)
-
-testglxmakecurrent_oldlink_SOURCES = \
-	$(TESTGLXMAKECURRENT_SOURCES_COMMON)
-
-testglxmakecurrent_oldlink_LDADD = -lX11 -ldl
-testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/GL/libGL.la
-testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libglvnd_pthread.la
-testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libtrace.la
-
 # Disable annoying "unused" errors
 AM_CFLAGS =                                  \
 	-Wno-error=unused-variable               \
@@ -102,24 +56,70 @@ AM_CFLAGS =                                  \
 	-I$(top_srcdir)/src/util/glvnd_pthread
 
 
-testglxgetprocaddress_LDADD = -lX11
-testglxgetprocaddress_LDADD += $(top_builddir)/src/GLX/libGLX.la
+TESTS += testpatchentrypoints_gldispatch.sh
+check_PROGRAMS += testpatchentrypoints_gldispatch
+testpatchentrypoints_gldispatch_SOURCES = \
+	testpatchentrypoints_gldispatch.c
+testpatchentrypoints_gldispatch_CFLAGS = \
+	-I$(top_srcdir)/include \
+	-I$(top_srcdir)/src/GLdispatch
+testpatchentrypoints_gldispatch_LDADD = $(top_builddir)/src/GLdispatch/libGLdispatch.la
+testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
+testpatchentrypoints_gldispatch_LDADD += dummy/libpatchentrypoints.la
+testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/util/libutils_misc.la
+
+
+TESTS += testglxmcbasic.sh
+TESTS += testglxmcloop.sh
+TESTS += testglxmcthreads.sh
+TESTS += testglxmclate.sh
+TESTS += testglxmcoldlink.sh
+
+TESTGLXMAKECURRENT_SOURCES_COMMON = \
+	testglxmakecurrent.c \
+	test_utils.c
 
+check_PROGRAMS += testglxmakecurrent
+testglxmakecurrent_SOURCES = $(TESTGLXMAKECURRENT_SOURCES_COMMON)
 testglxmakecurrent_LDADD = -lX11 -ldl
 testglxmakecurrent_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testglxmakecurrent_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testglxmakecurrent_LDADD += $(top_builddir)/src/util/libglvnd_pthread.la
 testglxmakecurrent_LDADD += $(top_builddir)/src/util/libtrace.la
 
+
+check_PROGRAMS += testglxmakecurrent_oldlink
+testglxmakecurrent_oldlink_SOURCES = $(TESTGLXMAKECURRENT_SOURCES_COMMON)
+testglxmakecurrent_oldlink_LDADD = -lX11 -ldl
+testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/GL/libGL.la
+testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libglvnd_pthread.la
+testglxmakecurrent_oldlink_LDADD += $(top_builddir)/src/util/libtrace.la
+
+
+TESTS += testglxgetprocaddress.sh
+TESTS += testglxgetprocaddress_genentry.sh
+check_PROGRAMS += testglxgetprocaddress
+testglxgetprocaddress_LDADD = -lX11
+testglxgetprocaddress_LDADD += $(top_builddir)/src/GLX/libGLX.la
+
+
+TESTS += testglxgetclientstr.sh
+check_PROGRAMS += testglxgetclientstr
 testglxgetclientstr_LDADD = -lX11
 testglxgetclientstr_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testglxgetclientstr_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testglxgetclientstr_LDADD += $(top_builddir)/src/util/libtrace.la
 
+
+TESTS += testglxqueryversion.sh
+check_PROGRAMS += testglxqueryversion
 testglxqueryversion_LDADD = -lX11
 testglxqueryversion_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testglxqueryversion_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
+
+TESTS += testpatchentrypoints.sh
+check_PROGRAMS += testpatchentrypoints
 testpatchentrypoints_SOURCES = \
 	testpatchentrypoints.c \
 	test_utils.c
@@ -129,43 +129,47 @@ testpatchentrypoints_LDADD += $(top_builddir)/src/GLX/libGLX.la
 testpatchentrypoints_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 testpatchentrypoints_LDADD += $(top_builddir)/src/util/libtrace.la
 
-testpatchentrypoints_gldispatch_SOURCES = \
-	testpatchentrypoints_gldispatch.c
-testpatchentrypoints_gldispatch_CFLAGS = \
-	-I$(top_srcdir)/include \
-	-I$(top_srcdir)/src/GLdispatch
-testpatchentrypoints_gldispatch_LDADD = $(top_builddir)/src/GLdispatch/libGLdispatch.la
-testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
-testpatchentrypoints_gldispatch_LDADD += dummy/libpatchentrypoints.la
-testpatchentrypoints_gldispatch_LDADD += $(top_builddir)/src/util/libutils_misc.la
 
+TESTS += testegldisplay.sh
+check_PROGRAMS += testegldisplay
 testegldisplay_SOURCES = \
 	testegldisplay.c \
 	egl_test_utils.c
 testegldisplay_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
+TESTS += testegldevice.sh
+check_PROGRAMS += testegldevice
 testegldevice_SOURCES = \
 	testegldevice.c \
 	egl_test_utils.c
 testegldevice_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
+TESTS += testeglgetprocaddress.sh
+check_PROGRAMS += testeglgetprocaddress
 testeglgetprocaddress_SOURCES = \
 	testeglgetprocaddress.c \
 	egl_test_utils.c
 testeglgetprocaddress_LDADD = $(top_builddir)/src/EGL/libEGL.la
 
+TESTS += testeglmakecurrent.sh
+check_PROGRAMS += testeglmakecurrent
 testeglmakecurrent_SOURCES = \
 	testeglmakecurrent.c \
 	egl_test_utils.c
 testeglmakecurrent_LDADD = $(top_builddir)/src/EGL/libEGL.la
 testeglmakecurrent_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
+TESTS += testeglerror.sh
+check_PROGRAMS += testeglerror
 testeglerror_SOURCES = \
 	testeglerror.c \
 	egl_test_utils.c
 testeglerror_LDADD = $(top_builddir)/src/EGL/libEGL.la
 testeglerror_LDADD += $(top_builddir)/src/OpenGL/libOpenGL.la
 
+
+TESTS += testegldebug.sh
+check_PROGRAMS += testegldebug
 testegldebug_SOURCES = \
 	testegldebug.c \
 	egl_test_utils.c
diff --git a/tests/dummy/Makefile.am b/tests/dummy/Makefile.am
index 639dd37..881ce9f 100644
--- a/tests/dummy/Makefile.am
+++ b/tests/dummy/Makefile.am
@@ -3,12 +3,9 @@ noinst_HEADERS = \
 	GLX_dummy.h \
 	EGL_dummy.h
 
-check_LTLIBRARIES = \
-	libpatchentrypoints.la \
-	libGLX_dummy.la \
-	libEGL_dummy0.la \
-	libEGL_dummy1.la
+check_LTLIBRARIES =
  
+check_LTLIBRARIES += libpatchentrypoints.la
 libpatchentrypoints_la_CFLAGS = \
 	-I$(top_srcdir)/src/GLdispatch \
 	-I$(top_srcdir)/src/util       \
@@ -16,6 +13,7 @@ libpatchentrypoints_la_CFLAGS = \
 libpatchentrypoints_la_SOURCES = \
 	patchentrypoints.c
 
+check_LTLIBRARIES += libGLX_dummy.la
 libGLX_dummy_la_CFLAGS = \
 	-I$(top_srcdir)/src/GLX        \
 	-I$(top_srcdir)/src/GLdispatch \
@@ -42,6 +40,7 @@ EGL_DUMMY_LDFLAGS_COMMON = \
 	-shared \
 	-rpath /nowhere
 
+check_LTLIBRARIES += libEGL_dummy0.la
 libEGL_dummy0_la_CFLAGS = \
 	$(EGL_DUMMY_CFLAGS_COMMON) \
 	-D DUMMY_VENDOR_NAME=\"dummy0\"
@@ -49,6 +48,7 @@ libEGL_dummy0_la_SOURCES = $(EGL_DUMMY_SOURCES_COMMON)
 libEGL_dummy0_la_LIBADD = $(EGL_DUMMY_LIBADD_COMMON)
 libEGL_dummy0_la_LDFLAGS = $(EGL_DUMMY_LDFLAGS_COMMON)
 
+check_LTLIBRARIES += libEGL_dummy1.la
 libEGL_dummy1_la_CFLAGS = \
 	$(EGL_DUMMY_CFLAGS_COMMON) \
 	-D DUMMY_VENDOR_NAME=\"dummy1\"

commit 2febabe709d7792836c8b1a3dab264efaf11aa86
Author: Kyle Brenneman <kbrenneman@nvidia.com>
Date:   Wed Nov 9 16:51:12 2016 -0700

    GLdispatch: Remove the __GLdispatchProcEntry list.
    
    Remove the __GLdispatchProcEntry struct and list, and remove the generation
    counter for the dispatch tables and stubs.
    
    Generated stubs are just added to the end of the table, so instead of a
    generation counter, it's sufficient to just keep track of the number of entries
    that we've populated in each table.
    
    FixupDispatchTable now just populates any new table entries, starting after
    whatever the last populated index was. It also now fetches the function names
    from GLAPI instead of using its own list.
    
    Removed CreateGLAPITable. FixupDispatchTable will allocate the table if
    necessary. Since it doesn't need to treat static and dynamic stubs differently,
    initializing a new empty table is no different than updating an existing table.
    
    Also added a check for a calloc failure in __glDispatchCreateTable and
    FixupDispatchTable, which will now propogate that error up to the caller.

diff --git a/src/GLdispatch/GLdispatch.c b/src/GLdispatch/GLdispatch.c
index 2d952d4..09fc75d 100644
--- a/src/GLdispatch/GLdispatch.c
+++ b/src/GLdispatch/GLdispatch.c
@@ -70,22 +70,6 @@ typedef struct __GLdispatchThreadStatePrivateRec {
     __GLdispatchTable *dispatch;
 } __GLdispatchThreadStatePrivate;
 
-typedef struct __GLdispatchProcEntryRec {
-    char *procName;
-
-    // Cached offset of this dispatch entry, retrieved from
-    // _glapi_get_proc_offset()
-    int offset;
-
-    // The generation in which this dispatch entry was defined.
-    // Used to determine whether a given dispatch table needs to
-    // be fixed up with the right function address at this offset.
-    int generation;
-
-    // List handle
-    struct glvnd_list entry;
-} __GLdispatchProcEntry;
-
 /*
  * List of valid extension procs which have been assigned prototypes. At make
  * current time, if the new context's generation is out-of-date, we iterate
@@ -96,17 +80,6 @@ typedef struct __GLdispatchProcEntryRec {
 static struct glvnd_list extProcList;
 
 /*
- * Monotonically increasing integer describing the most up-to-date "generation"
- * of the dispatch table. Used to determine if a given table needs fixup.
- * Accesses to this need to be protected by the dispatch lock.
- *
- * Note: wrapping is theoretically an issue here, but shouldn't happen in
- * practice as it requires calling GetProcAddress() on 2^31-1 unique functions.
- * We'll run out of dispatch stubs long before then.
- */
-static int latestGeneration;
-
-/*
  * Dispatch stub list for entrypoint rewriting.
  */
 static struct glvnd_list dispatchStubList;
@@ -257,59 +230,42 @@ static void DispatchCurrentUnref(__GLdispatchTable *dispatch)
  * Fix up a dispatch table. Calls to this function must be protected by the
  * dispatch lock.
  */
-static void FixupDispatchTable(__GLdispatchTable *dispatch)
+static GLboolean FixupDispatchTable(__GLdispatchTable *dispatch)
 {
     DBG_PRINTF(20, "dispatch=%p\n", dispatch);
     CheckDispatchLocked();
 
-    __GLdispatchProcEntry *curProc;
-    void *procAddr;
-    void **tbl = (void **)dispatch->table;
+    void **tbl;
+    int count = _glapi_get_stub_count();
+    int i;
 
-    /*
-     * For each proc in the extProcList, compare its gen# against that of
-     * the context. If greater, then fix up the dispatch table to contain
-     * the right entrypoint.
-     * XXX optimization: could we assume that the list is sorted by generation
-     * number and hence early out once we reach gen# <= the context's?
-     */
-    glvnd_list_for_each_entry(curProc, &extProcList, entry) {
-        if (curProc->generation > dispatch->generation) {
-            assert(curProc->offset != -1);
-            assert(curProc->procName);
-
-            procAddr = (void*)(*dispatch->getProcAddress)(
-                curProc->procName,
-                dispatch->getProcAddressParam);
-
-            tbl[curProc->offset] = procAddr ? procAddr : (void *)noop_func;
-            DBG_PRINTF(20, "extProc procName=%s, addr=%p, noop=%p\n",
-                       curProc->procName, procAddr, noop_func);
+    if (dispatch->table == NULL) {
+        dispatch->table = (struct _glapi_table *)
+            calloc(1, _glapi_get_dispatch_table_size() * sizeof(void *));
+        if (dispatch->table == NULL) {
+            return GL_FALSE;
         }
     }
 
-    dispatch->generation = latestGeneration;
-}
+    tbl = (void **)dispatch->table;
+    for (i=dispatch->stubsPopulated; i<count; i++) {
+        const char *name = _glapi_get_proc_name(i);
+        void *procAddr;
 
-static __GLdispatchProcEntry *FindProcInList(const char *procName,
-                                             struct glvnd_list *list)
-{
-    DBG_PRINTF(20, "%s\n", procName);
-    __GLdispatchProcEntry *curProc;
-    CheckDispatchLocked();
-    glvnd_list_for_each_entry(curProc, list, entry) {
-        if (!strcmp(curProc->procName, procName)) {
-            DBG_PRINTF(20, "yes\n");
-            return curProc;
-        }
+        assert(name != NULL);
+
+        procAddr = (void*)(*dispatch->getProcAddress)(
+            name, dispatch->getProcAddressParam);
+        tbl[i] = procAddr ? procAddr : (void *)noop_func;
     }
+    dispatch->stubsPopulated = count;
 
-    DBG_PRINTF(20, "no\n");
-    return NULL;
+    return GL_TRUE;
 }
 
 PUBLIC __GLdispatchProc __glDispatchGetProcAddress(const char *procName)
 {
+    int prevCount;
     _glapi_proc addr;
 
     /*
@@ -317,33 +273,21 @@ PUBLIC __GLdispatchProc __glDispatchGetProcAddress(const char *procName)
      * prevent races when retrieving the entrypoint stub.
      */
     LockDispatch();
-
+    prevCount = _glapi_get_stub_count();
     addr = _glapi_get_proc_address(procName);
+    if (addr != NULL && prevCount != _glapi_get_stub_count()) {
+        __GLdispatchTable *curDispatch;
 
-    DBG_PRINTF(20, "addr=%p\n", addr);
-    if (addr) {
-        if (!FindProcInList(procName, &extProcList))
-        {
-            __GLdispatchTable *curDispatch;
-            __GLdispatchProcEntry *pEntry = malloc(sizeof(*pEntry));
-            pEntry->procName = strdup(procName);
-            pEntry->offset = _glapi_get_proc_offset(procName);
-            assert(pEntry->offset >= 0);
-
-            /*
-             * Bump the latestGeneration, then assign it to this proc.
-             */
-            pEntry->generation = ++latestGeneration;
-
-            glvnd_list_add(&pEntry->entry, &extProcList);
-
-            /*
-             * Fixup any current dispatch tables to contain the right pointer
-             * to this proc.
-             */
-            glvnd_list_for_each_entry(curDispatch, &currentDispatchList, entry) {
-                FixupDispatchTable(curDispatch);
-            }
+        /*
+         * Fixup any current dispatch tables to contain the right pointer
+         * to this proc.
+         */
+        glvnd_list_for_each_entry(curDispatch, &currentDispatchList, entry) {
+            // Sanity check: Every current dispatch table must have already
+            // been allocated. That's important because it means
+            // FixupDispatchTable can't fail.
+            assert(curDispatch->table != NULL);
+            FixupDispatchTable(curDispatch);
         }
     }
     UnlockDispatch();
@@ -354,11 +298,10 @@ PUBLIC __GLdispatchProc __glDispatchGetProcAddress(const char *procName)
 PUBLIC __GLdispatchTable *__glDispatchCreateTable(
         __GLgetProcAddressCallback getProcAddress, void *param)
 {
-    __GLdispatchTable *dispatch = malloc(sizeof(__GLdispatchTable));
-
-    dispatch->generation = 0;
-    dispatch->currentThreads = 0;
-    dispatch->table = NULL;
+    __GLdispatchTable *dispatch = calloc(1, sizeof(__GLdispatchTable));
+    if (dispatch == NULL) {
+        return NULL;
+    }
 
     dispatch->getProcAddress = getProcAddress;
     dispatch->getProcAddressParam = param;
@@ -380,31 +323,6 @@ PUBLIC void __glDispatchDestroyTable(__GLdispatchTable *dispatch)
     UnlockDispatch();
 }
 
-static void CreateGLAPITable(__GLdispatchTable *dispatch)
-{
-    int entries = (int) _glapi_get_dispatch_table_size();
-    void **table;
-    int i;
-
-    CheckDispatchLocked();
-
-    table = (void **) calloc(1, entries * sizeof(void *));
-    for (i=0; i<entries; i++) {
-        const char *name = _glapi_get_proc_name(i);
-        void *func;
-
-        if (name == NULL) {
-            // We found the last static or dynamic stub in the table.
-            break;
-        }
-
-        func = dispatch->getProcAddress(name, dispatch->getProcAddressParam);
-        table[i] = func ? func : (void *) noop_func;
-    }
-    dispatch->table = (struct _glapi_table *) table;
-    dispatch->generation = latestGeneration;
-}
-
 static int CurrentEntrypointsSafeToUse(int vendorID)
 {
     CheckDispatchLocked();
@@ -666,15 +584,10 @@ PUBLIC GLboolean __glDispatchMakeCurrent(__GLdispatchThreadState *threadState,
         return GL_FALSE;
     }
 
-    if (!dispatch->table ||
-        (dispatch->generation < latestGeneration)) {
-
-        // Lazily create the dispatch table if we haven't already
-        if (!dispatch->table) {
-            CreateGLAPITable(dispatch);
-        }
-
-        FixupDispatchTable(dispatch);
+    if (!FixupDispatchTable(dispatch)) {
+        UnlockDispatch();
+        free(priv);
+        return GL_FALSE;
     }
 
     DispatchCurrentRef(dispatch);
@@ -813,20 +726,9 @@ void __glDispatchFini(void)
     clientRefcount--;
 
     if (clientRefcount == 0) {
-        __GLdispatchProcEntry *curProc, *tmpProc;
-
         /* This frees the dispatchStubList */
         UnregisterAllStubCallbacks();
 
-        /*
-         * Clear out the getProcAddress lists.
-         */
-        glvnd_list_for_each_entry_safe(curProc, tmpProc, &extProcList, entry) {
-            glvnd_list_del(&curProc->entry);
-            free(curProc->procName);
-            free(curProc);
-        }
-
         __glvndPthreadFuncs.key_delete(threadContextKey);
 
         // Clean up GLAPI thread state
diff --git a/src/GLdispatch/GLdispatchPrivate.h b/src/GLdispatch/GLdispatchPrivate.h
index aca8de7..b0e1bb3 100644
--- a/src/GLdispatch/GLdispatchPrivate.h
+++ b/src/GLdispatch/GLdispatchPrivate.h
@@ -44,8 +44,11 @@ struct __GLdispatchTableRec {
     /*! Number of threads this dispatch is current on */
     int currentThreads;
 
-    /*! Generation number for tracking whether this needs fixup */
-    int generation;
+    /*!
+     * The number of dispatch table entries that have been populated. This is
+     * used to update the table after generating new dispatch stubs.
+     */
+    int stubsPopulated;
 
     /*! Saved vendor library callbacks */
     __GLgetProcAddressCallback getProcAddress;
diff --git a/src/GLdispatch/vnd-glapi/glapi.h b/src/GLdispatch/vnd-glapi/glapi.h
index 13da528..5dc16e1 100644
--- a/src/GLdispatch/vnd-glapi/glapi.h
+++ b/src/GLdispatch/vnd-glapi/glapi.h
@@ -158,6 +158,13 @@ const char *
 _glapi_get_proc_name(unsigned int offset);
 
 /**
+ * Returns the total number of defined stubs. This count only includes dynamic
+ * stubs that have been generated, so it will always be less than or equal to
+ * the size of the dispatch table.
+ */
+int _glapi_get_stub_count(void);
+
+/**
  * Functions used for patching entrypoints. These functions are exported from
  * an entrypoint library such as libGL.so or libOpenGL.so, and used in
  * libGLdispatch.
diff --git a/src/GLdispatch/vnd-glapi/mapi_glapi.c b/src/GLdispatch/vnd-glapi/mapi_glapi.c
index e07c8c5..07ecb5c 100644
--- a/src/GLdispatch/vnd-glapi/mapi_glapi.c
+++ b/src/GLdispatch/vnd-glapi/mapi_glapi.c
@@ -130,3 +130,9 @@ _glapi_get_proc_name(unsigned int offset)
    return stub ? stub_get_name(stub) : NULL;
 }
 
+
+int _glapi_get_stub_count(void)
+{
+    return stub_get_count();
+}
+
diff --git a/src/GLdispatch/vnd-glapi/stub.c b/src/GLdispatch/vnd-glapi/stub.c
index 46d5bba..e5490b5 100644
--- a/src/GLdispatch/vnd-glapi/stub.c
+++ b/src/GLdispatch/vnd-glapi/stub.c
@@ -201,6 +201,11 @@ stub_get_name(const struct mapi_stub *stub)
    return stub->name;
 }
 
+int stub_get_count(void)
+{
+    return ARRAY_SIZE(public_stubs) + num_dynamic_stubs;
+}
+
 #endif // !defined(STATIC_DISPATCH_ONLY)
 
 /**
diff --git a/src/GLdispatch/vnd-glapi/stub.h b/src/GLdispatch/vnd-glapi/stub.h
index c5624e4..97211a7 100644
--- a/src/GLdispatch/vnd-glapi/stub.h
+++ b/src/GLdispatch/vnd-glapi/stub.h
@@ -60,6 +60,8 @@ stub_get_slot(const struct mapi_stub *stub);
 
 mapi_func
 stub_get_addr(const struct mapi_stub *stub);
+
+int stub_get_count(void);
 #endif // !defined(STATIC_DISPATCH_ONLY)
 
 /**

commit 839c97a41041b123506772738fa971d5f0b9442f
Author: Kyle Brenneman <kbrenneman@nvidia.com>
Date:   Wed Nov 9 15:33:21 2016 -0700

    GLdispatch: Remove _glapi_init_table_from_callback.
    
    Removed _glapi_init_table_from_callback, and the script that generates it.
    Instead, libGLdispatch.so just iterates over the stub list to find the name for
    each function.
    
    Also removed the struct definition for _glapi_table, since it's only used in
    _glapi_init_table_from_callback. Everything else just treats it as an array
    of pointers.
    
    Changed the public_stubs array so that it includes the full name of each
    function, including the "gl" prefix, so that it can pass that name to the
    vendor's getProcAddress callback.
    
    Changed stub_find_by_slot to use an array lookup instead of a linear search.

diff --git a/src/GLdispatch/GLdispatch.c b/src/GLdispatch/GLdispatch.c
index cf4254e..2d952d4 100644
--- a/src/GLdispatch/GLdispatch.c
+++ b/src/GLdispatch/GLdispatch.c
@@ -380,23 +380,29 @@ PUBLIC void __glDispatchDestroyTable(__GLdispatchTable *dispatch)
     UnlockDispatch();
 }
 
-static struct _glapi_table
-*CreateGLAPITable(__GLgetProcAddressCallback getProcAddress, void *param)
+static void CreateGLAPITable(__GLdispatchTable *dispatch)
 {
-    size_t entries = _glapi_get_dispatch_table_size();
-    struct _glapi_table *table = (struct _glapi_table *)
-        calloc(1, entries * sizeof(void *));
+    int entries = (int) _glapi_get_dispatch_table_size();
+    void **table;
+    int i;
 
     CheckDispatchLocked();
 
-    if (table) {
-        _glapi_init_table_from_callback(table,
-                                        entries,
-                                        getProcAddress,
-                                        param);
-    }
+    table = (void **) calloc(1, entries * sizeof(void *));
+    for (i=0; i<entries; i++) {
+        const char *name = _glapi_get_proc_name(i);
+        void *func;
+
+        if (name == NULL) {
+            // We found the last static or dynamic stub in the table.
+            break;
+        }
 
-    return table;
+        func = dispatch->getProcAddress(name, dispatch->getProcAddressParam);
+        table[i] = func ? func : (void *) noop_func;
+    }
+    dispatch->table = (struct _glapi_table *) table;
+    dispatch->generation = latestGeneration;
 }
 
 static int CurrentEntrypointsSafeToUse(int vendorID)
@@ -665,8 +671,7 @@ PUBLIC GLboolean __glDispatchMakeCurrent(__GLdispatchThreadState *threadState,
 
         // Lazily create the dispatch table if we haven't already
         if (!dispatch->table) {
-            dispatch->table = CreateGLAPITable(dispatch->getProcAddress,
-                    dispatch->getProcAddressParam);
+            CreateGLAPITable(dispatch);
         }
 
         FixupDispatchTable(dispatch);
diff --git a/src/GLdispatch/vnd-glapi/Makefile.am b/src/GLdispatch/vnd-glapi/Makefile.am
index 42a638e..1c95e53 100644
--- a/src/GLdispatch/vnd-glapi/Makefile.am
+++ b/src/GLdispatch/vnd-glapi/Makefile.am
@@ -23,8 +23,7 @@ libglapi_la_SOURCES = \
 	mapi_glapi.c \
 	stub.c \
 	table.c \
-	u_execmem.c \
-	g_glapi_inittable.c
+	u_execmem.c
 
 # Select the appropriate file for looking up the current dispatch table.
 if GLDISPATCH_USE_TLS
@@ -40,13 +39,7 @@ include $(top_srcdir)/src/generate/glvnd_gen.mk
 glapi_mapi_tmp.h : $(glapi_gen_mapi_deps)
 	$(call glapi_gen_mapi, gldispatch)
 


Reply to: