Revert "Always build shared glapi"
authorMatt Turner <mattst88@gmail.com>
Tue, 24 Jan 2012 16:34:42 +0000 (11:34 -0500)
committerMatt Turner <mattst88@gmail.com>
Tue, 24 Jan 2012 16:34:42 +0000 (11:34 -0500)
This reverts commit adefee50d954151f76150af80207081ae3c247d9.

Shared glapi was never tested with --enable-xlib-glx and turns out
to cause a lot of problems.

Conflicts:

configure.ac

15 files changed:
configs/autoconf.in
configure.ac
src/egl/drivers/dri2/Android.mk
src/egl/drivers/dri2/Makefile
src/egl/drivers/dri2/egl_dri2.c
src/gallium/targets/egl-static/Makefile
src/gallium/targets/libgl-xlib/Makefile
src/glx/Makefile
src/glx/SConscript
src/glx/glxcmds.c
src/glx/indirect.c
src/glx/indirect.h
src/mapi/glapi/Makefile
src/mapi/glapi/gen/glX_proto_send.py
src/mesa/drivers/x11/Makefile

index 55886ea889583795a198d38585d414f1aac98f16..38fe3179f04cf562490b9a58a47661c49b54ffeb 100644 (file)
@@ -15,6 +15,7 @@ ASM_FLAGS = @ASM_FLAGS@
 PIC_FLAGS = @PIC_FLAGS@
 DEFINES = @DEFINES@
 API_DEFINES = @API_DEFINES@
+SHARED_GLAPI = @SHARED_GLAPI@
 CFLAGS_NOVISIBILITY = @CPPFLAGS@ @CFLAGS@ \
        $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
 CXXFLAGS_NOVISIBILITY = @CPPFLAGS@ @CXXFLAGS@ \
index f68a54fe5ad0f7f40341afd0c3d6b48b6fe08ba4..18a40fceade5d267a02f4f3747587e0122cfc774 100644 (file)
@@ -703,6 +703,18 @@ if test "x$enable_gles2" = xyes; then
 fi
 AC_SUBST([API_DEFINES])
 
+AC_ARG_ENABLE([shared-glapi],
+    [AS_HELP_STRING([--enable-shared-glapi],
+        [EXPERIMENTAL.  Enable shared glapi for OpenGL @<:@default=no@:>@])],
+    [enable_shared_glapi="$enableval"],
+    [enable_shared_glapi=no])
+
+SHARED_GLAPI="0"
+if test "x$enable_shared_glapi" = xyes; then
+    SHARED_GLAPI="1"
+fi
+AC_SUBST([SHARED_GLAPI])
+
 dnl
 dnl Driver configuration. Options are xlib, dri and osmesa right now.
 dnl More later: fbdev, ...
@@ -788,7 +800,7 @@ dnl Driver specific build directories
 dnl
 
 dnl this variable will be prepended to SRC_DIRS and is not exported
-CORE_DIRS="mapi/shared-glapi"
+CORE_DIRS=""
 
 SRC_DIRS=""
 GLU_DIRS="sgi"
@@ -798,6 +810,13 @@ GALLIUM_WINSYS_DIRS="sw"
 GALLIUM_DRIVERS_DIRS="galahad trace rbug noop identity"
 GALLIUM_STATE_TRACKERS_DIRS=""
 
+# build shared-glapi if enabled for OpenGL or if OpenGL ES is enabled
+case "x$enable_shared_glapi$enable_gles1$enable_gles2" in
+x*yes*)
+    CORE_DIRS="$CORE_DIRS mapi/shared-glapi"
+    ;;
+esac
+
 # build glapi if OpenGL is enabled
 if test "x$enable_opengl" = xyes; then
     CORE_DIRS="$CORE_DIRS mapi/glapi"
@@ -1365,6 +1384,13 @@ if test "x$enable_gbm" = xyes; then
 
     PKG_CHECK_MODULES([LIBUDEV], [libudev], [],
                       AC_MSG_ERROR([gbm needs udev]))
+
+    if test "x$enable_dri" = xyes; then
+        GBM_BACKEND_DIRS="$GBM_BACKEND_DIRS dri"
+        if test "$SHARED_GLAPI" -eq 0; then
+            AC_MSG_ERROR([gbm_dri requires --enable-shared-glapi])
+        fi
+    fi
 fi
 GBM_PC_REQ_PRIV="libudev"
 GBM_PC_LIB_PRIV="$DLOPEN_LIBS"
index b120c95212760f56fe868c30be3f083581a3a46f..5c506f83ab2b1e3f51136e5187a69a572cdee891 100644 (file)
@@ -34,6 +34,7 @@ LOCAL_SRC_FILES := \
 LOCAL_CFLAGS := \
        -D_EGL_MAIN=_eglBuiltInDriverDRI2 \
        -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\" \
+       -DHAVE_SHARED_GLAPI \
        -DHAVE_ANDROID_PLATFORM
 
 LOCAL_C_INCLUDES := \
index 5780510dca17819b7fba14f7f26744ddf6277cbe..d2b1f4f077a546aab657e147aaff5bf2a632d0cb 100644 (file)
@@ -21,6 +21,10 @@ EGL_LIBS = $(LIBUDEV_LIBS) $(DLOPEN_LIBS) $(LIBDRM_LIB)
 EGL_CFLAGS = -D_EGL_MAIN=_eglBuiltInDriverDRI2
 EGL_BUILTIN = true
 
+ifeq ($(SHARED_GLAPI),1)
+EGL_CFLAGS += -DHAVE_SHARED_GLAPI
+endif
+
 ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
 EGL_SOURCES += platform_x11.c
 EGL_INCLUDES += -DHAVE_X11_PLATFORM $(XCB_DRI2_CFLAGS)
index a320f351655649422ee38d17426d1d87978d5030..80b2e38d9d3a2e881f53a15c5a643668f441c0d5 100644 (file)
@@ -1362,10 +1362,18 @@ static EGLBoolean
 dri2_load(_EGLDriver *drv)
 {
    struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
+#ifdef HAVE_SHARED_GLAPI
 #ifdef HAVE_ANDROID_PLATFORM
    const char *libname = "libglapi.so";
 #else
    const char *libname = "libglapi.so.0";
+#endif
+#else
+   /*
+    * Both libGL.so and libglapi.so are glapi providers.  There is no way to
+    * tell which one to load.
+    */
+   const char *libname = NULL;
 #endif
    void *handle;
 
index 9e8777402cb2c369e04b3a0cde4e850a162fd92f..79a098af448dbbfb322e23d0ab97ba6765f400d2 100644 (file)
@@ -8,6 +8,7 @@
 #   EGL_PLATFORMS       - platforms to support
 #   EGL_CLIENT_APIS     - state trackers to support
 #   GALLIUM_WINSYS_DIRS - pipe drivers to support
+#   SHARED_GLAPI        - st/mesa can be statically linked or not
 #
 
 TOP = ../../../..
@@ -69,8 +70,14 @@ endif
 # st/mesa
 ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
 egl_CPPFLAGS += -I$(TOP)/src/mesa $(API_DEFINES)
+# make st/mesa built-in when there is a single glapi provider
+ifeq ($(SHARED_GLAPI),1)
 egl_LIBS += $(TOP)/src/mesa/libmesagallium.a
 egl_SYS += -lm -lpthread $(DLOPEN_LIBS) -l$(GLAPI_LIB)
+else
+egl_CPPFLAGS += -D_EGL_EXTERNAL_GL=1
+OUTPUTS += st_GL
+endif # SHARED_GLAPI
 endif
 
 # st/vega
index 479e08559850fdca87d2894ec30366416bafa0b7..867b2da323b300c9ebda7a84b20cc0998bcb2245 100644 (file)
@@ -58,7 +58,9 @@ GL_LIB_DEPS += $(LLVM_LIBS)
 LDFLAGS += $(LLVM_LDFLAGS)
 endif
 
+ifeq ($(SHARED_GLAPI),1)
 GL_LIB_DEPS := -L$(TOP)/$(LIB_DIR) -l$(GLAPI_LIB) $(GL_LIB_DEPS)
+endif
 
 
 .SUFFIXES : .cpp
index b86bd73be34c823777d81f61d29e6abb24f80ab3..f702f952ce7561dc6ee6f0e5dabbad37177f7f83 100644 (file)
@@ -49,7 +49,10 @@ SOURCES = \
          applegl_glx.c
 
 
+ifeq ($(SHARED_GLAPI),1)
 GL_LIB_DEPS := -L$(TOP)/$(LIB_DIR) -l$(GLAPI_LIB) $(GL_LIB_DEPS)
+EXTRA_DEFINES += -DGLX_SHARED_GLAPI
+endif
 
 # override GLAPI_LIB
 GLAPI_LIB = $(TOP)/src/mapi/glapi/libglapi.a
index d08ae9e2c504ce84510e383e865c319cb99865ea..17a5690ee863cb3d0ea5d4292ddda0be9dda3852 100644 (file)
@@ -31,6 +31,9 @@ if env['HAVE_XF86VIDMODE']:
     env.Append(CPPDEFINES = ['XF86VIDMODE'])
     env.PkgUseModules('XF86VIDMODE')
 
+if False: # XXX: SHARED_GLAPI
+    env.Append(CPPDEFINES = ['GLX_SHARED_GLAPI'])
+
 sources = [
     'clientattrib.c',
     'clientinfo.c',
index 35f98a3aca2a25e9aba994accac7ddc8957701ab..37c09336749c1adfb27d9bb035a5723be534ef88 100644 (file)
@@ -2647,7 +2647,9 @@ _X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
    f = (gl_function) get_glx_proc_address((const char *) procName);
    if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
        && (procName[2] != 'X')) {
+#ifdef GLX_SHARED_GLAPI
       f = (gl_function) __indirect_get_proc_address((const char *) procName);
+#endif
       if (!f)
          f = (gl_function) _glapi_get_proc_address((const char *) procName);
       if (!f) {
index b8e14add410e50ad0a6cf5f7ae39a7d44094b798..a6b0c0d6dac772ed2329bc35bf2315e9a49f990f 100644 (file)
@@ -10672,6 +10672,8 @@ __indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment,
 }
 
 
+#ifdef GLX_SHARED_GLAPI
+
 static const struct proc_pair {
     const char *name;
     _glapi_proc proc;
@@ -10727,6 +10729,8 @@ __indirect_get_proc_address(const char *name)
     return (pair) ? pair->proc : NULL;
 }
 
+#endif /* GLX_SHARED_GLAPI */
+
 
 #undef FASTCALL
 #undef NOINLINE
index f76201b64f113de762d3d76753d72ab779dd5a17..b1fee9fc1a01a7e6e8de2212777a3fdc9078210f 100644 (file)
@@ -711,7 +711,10 @@ extern _X_HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer);
 extern _X_HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
 extern _X_HIDDEN void __indirect_glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
 extern _X_HIDDEN void __indirect_glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+
+#ifdef GLX_SHARED_GLAPI
 extern _X_HIDDEN void (*__indirect_get_proc_address(const char *name))(void);
+#endif
 
 #  undef FASTCALL
 #  undef NOINLINE
index 37b178eee39769099e86f482a17fd52bd2112503..bb4ed6585d9df62aabfb8ab4803934ae27373847 100644 (file)
@@ -15,6 +15,7 @@ glapi_CPPFLAGS := \
        -I$(TOP)/src/mapi \
        -I$(TOP)/src/mesa
 
+ifeq ($(SHARED_GLAPI),1)
 glapi_CPPFLAGS += \
        -DMAPI_MODE_BRIDGE \
        -DMAPI_ABI_HEADER=\"glapi/glapi_mapi_tmp.h\"
@@ -23,6 +24,14 @@ glapi_SOURCES := $(addprefix $(MAPI)/, $(MAPI_BRIDGE_SOURCES))
 glapi_GLAPI_OBJECTS :=
 glapi_ASM_OBJECTS :=
 glapi_MAPI_OBJECTS := $(MAPI_BRIDGE_SOURCES:.c=.o)
+else
+glapi_CPPFLAGS += -DMAPI_MODE_UTIL
+glapi_SOURCES := $(GLAPI_SOURCES) $(addprefix $(MAPI)/, $(MAPI_UTIL_SOURCES))
+
+glapi_GLAPI_OBJECTS := $(GLAPI_SOURCES:.c=.o)
+glapi_ASM_OBJECTS := $(GLAPI_ASM_SOURCES:.S=.o)
+glapi_MAPI_OBJECTS := $(MAPI_UTIL_SOURCES:.c=.o)
+endif # SHARED_GLAPI
 
 glapi_OBJECTS := \
        $(glapi_GLAPI_OBJECTS) \
@@ -50,10 +59,14 @@ clean:
        -rm -f lib$(TARGET).a
        -rm -f depend depend.bak
 
+ifeq ($(SHARED_GLAPI),1)
 # workaround a bug in makedepend
 makedepend_CPPFLAGS := \
        $(filter-out -DMAPI_ABI_HEADER=%, $(glapi_CPPFLAGS))
 $(glapi_OBJECTS): glapi_mapi_tmp.h
+else
+makedepend_CPPFLAGS := $(glapi_CPPFLAGS)
+endif
 
 depend: $(glapi_SOURCES)
        @ echo "running $(MKDEP)"
index 29bf0808bac0a8713e86ee7d963071ad55f82c15..bec0222188f28b2d82c5e0607404c2010bb107e9 100644 (file)
@@ -361,6 +361,8 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
                                        procs[n] = func.static_glx_name(n)
 
                print """
+#ifdef GLX_SHARED_GLAPI
+
 static const struct proc_pair
 {
    const char *name;
@@ -394,6 +396,8 @@ __indirect_get_proc_address(const char *name)
 
    return (pair) ? pair->proc : NULL;
 }
+
+#endif /* GLX_SHARED_GLAPI */
 """
                return
 
@@ -1047,7 +1051,9 @@ extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
                                        break
 
                print ''
+               print '#ifdef GLX_SHARED_GLAPI'
                print 'extern _X_HIDDEN void (*__indirect_get_proc_address(const char *name))(void);'
+               print '#endif'
 
 
 def show_usage():
index acb6f082956c087f795ccf5bf19747f09435e9ee..412fbfe1aee00d2094e3deef1101f96948efbbe1 100644 (file)
@@ -44,7 +44,9 @@ INCLUDE_DIRS = \
 
 CORE_MESA = $(TOP)/src/mesa/libmesa.a $(TOP)/src/mapi/glapi/libglapi.a
 
+ifeq ($(SHARED_GLAPI),1)
 GL_LIB_DEPS := -L$(TOP)/$(LIB_DIR) -l$(GLAPI_LIB) $(GL_LIB_DEPS)
+endif
 
 
 .c.o: