diff --git a/GL/Makefile.am b/GL/Makefile.am index df9f533..97bb399 100644 --- a/GL/Makefile.am +++ b/GL/Makefile.am @@ -5,7 +5,7 @@ if BUILD_DARWIN DARWIN_SUBDIRS = apple endif -SUBDIRS = glx mesa $(DARWIN_SUBDIRS) +SUBDIRS = glx $(DARWIN_SUBDIRS) WINDOWS_EXTRAS = \ windows/ChangeLog \ diff --git a/GL/glx/.gitignore b/GL/glx/.gitignore index 5cf6f0a..617b362 100644 --- a/GL/glx/.gitignore +++ b/GL/glx/.gitignore @@ -3,3 +3,4 @@ glcontextmodes.c glcontextmodes.h glapi.c glthread.c +glxglcore.c diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am index cd1130d..4e886d1 100644 --- a/GL/glx/Makefile.am +++ b/GL/glx/Makefile.am @@ -46,7 +46,8 @@ libglx_la_SOURCES = \ glxdrawable.h \ glxext.c \ glxext.h \ - glxvisuals.c \ + glxglcore.c \ + glxvisuals.c \ glxscreens.c \ glxscreens.h \ glxserver.h \ @@ -79,3 +80,6 @@ libglx_la_SOURCES = \ swap_interval.c \ unpack.h \ xfont.c + +glxglcore.c: + ln -s $(top_srcdir)/GL/mesa/X/xf86glx.c $@ diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c index 6fffdeb..32c80ee 100644 --- a/GL/mesa/X/xf86glx.c +++ b/GL/mesa/X/xf86glx.c @@ -36,8 +36,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #endif +#include #include +#define _NEED_GLCORE_IF #include #include #include @@ -45,11 +47,26 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include -#include "xmesaP.h" #include "glcontextmodes.h" #include "os.h" +static __GLcoreModule *glcore = NULL; + +#define XMesaCreateVisual (*glcore->XMesaCreateVisual) +#define XMesaDestroyVisual (*glcore->XMesaDestroyVisual) +#define XMesaCreateContext (*glcore->XMesaCreateContext) +#define XMesaDestroyContext (*glcore->XMesaDestroyContext) +#define XMesaCopyContext (*glcore->XMesaCopyContext) +#define XMesaForceCurrent (*glcore->XMesaForceCurrent) +#define XMesaLoseCurrent (*glcore->XMesaLoseCurrent) +#define XMesaCreateWindowBuffer (*glcore->XMesaCreateWindowBuffer) +#define XMesaCreatePixmapBuffer (*glcore->XMesaCreatePixmapBuffer) +#define XMesaDestroyBuffer (*glcore->XMesaDestroyBuffer) +#define XMesaMakeCurrent2 (*glcore->XMesaMakeCurrent2) +#define XMesaSwapBuffers (*glcore->XMesaSwapBuffers) +#define XMesaResizeBuffers (*glcore->XMesaResizeBuffers) + typedef struct __GLXMESAscreen __GLXMESAscreen; typedef struct __GLXMESAcontext __GLXMESAcontext; typedef struct __GLXMESAdrawable __GLXMESAdrawable; @@ -57,8 +74,9 @@ typedef struct __GLXMESAdrawable __GLXMESAdrawable; struct __GLXMESAscreen { __GLXscreen base; int index; - int num_vis; + int num_vis; XMesaVisual *xm_vis; + void *driver; }; struct __GLXMESAcontext { @@ -266,6 +284,8 @@ __glXMesaScreenDestroy(__GLXscreen *screen) xfree(mesaScreen->xm_vis); + dlclose(mesaScreen->driver); + __glXScreenDestroy(screen); xfree(screen); @@ -372,29 +392,62 @@ static void init_screen_visuals(__GLXMESAscreen *screen) screen->xm_vis = pXMesaVisual; } +static const char dri_driver_path[] = DRI_DRIVER_PATH; + static __GLXscreen * __glXMesaScreenProbe(ScreenPtr pScreen) { __GLXMESAscreen *screen; + char filename[128]; screen = xalloc(sizeof *screen); if (screen == NULL) return NULL; - __glXScreenInit(&screen->base, pScreen); - screen->base.destroy = __glXMesaScreenDestroy; screen->base.createContext = __glXMesaScreenCreateContext; screen->base.createDrawable = __glXMesaScreenCreateDrawable; screen->base.pScreen = pScreen; + snprintf(filename, sizeof filename, "%s/%s.so", + dri_driver_path, "libGLcore"); + + screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); + if (screen->driver == NULL) { + LogMessage(X_ERROR, "GLX error: dlopen of %s failed (%s)\n", + filename, dlerror()); + goto handle_error; + } + + glcore = dlsym(screen->driver, "glcore"); + if (glcore == NULL) { + LogMessage(X_ERROR, "GLX error: dlsym for %s failed (%s)\n", + "glcore", dlerror()); + goto handle_error; + } + + __glXScreenInit(&screen->base, pScreen); + /* * Find the GLX visuals that are supported by this screen and create * XMesa's visuals. */ init_screen_visuals(screen); + LogMessage(X_INFO, "GLX: Loaded and initialized %s\n", filename); + return &screen->base; + +handle_error: + + if (screen->driver) + dlclose(screen->driver); + + xfree(screen); + + FatalError("GLX: could not load software renderer\n"); + + return NULL; } __GLXprovider __glXMesaProvider = { diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh index 7d1e06e..90351a5 100755 --- a/GL/symlink-mesa.sh +++ b/GL/symlink-mesa.sh @@ -262,7 +262,6 @@ run() { # $1 what to do # $2 explanation - ACTION=$1 EXPLANATION=$2 run_module mesa ACTION=$1 EXPLANATION=$2 run_module glx } diff --git a/configure.ac b/configure.ac index 282003d..c517820 100644 --- a/configure.ac +++ b/configure.ac @@ -453,9 +453,6 @@ AC_ARG_WITH(os-vendor, AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name o AC_ARG_WITH(builderstring, AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]), [ BUILDERSTRING="$withval" ] [ ]) -AC_ARG_WITH(mesa-source, AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]), - [ MESA_SOURCE="$withval" ], - [ MESA_SOURCE="" ]) AC_ARG_WITH(fontdir, AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]), [ FONTDIR="$withval" ], [ FONTDIR="${libdir}/X11/fonts" ]) @@ -494,6 +491,20 @@ AC_ARG_ENABLE(null-root-cursor, AS_HELP_STRING([--enable-null-root-cursor], [Use [NULL_ROOT_CURSOR=$enableval], [NULL_ROOT_CURSOR=no]) +dnl GLX build options +AC_ARG_WITH(mesa-source, AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]), + [ MESA_SOURCE="$withval" ], + [ MESA_SOURCE="" ]) +AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), + [AIGLX=$enableval], + [AIGLX=yes]) +AC_ARG_ENABLE(glx-pthreads, AS_HELP_STRING([--enable-glx-pthreads], [Build GLX with PTHREADS support (default: auto)]), + [GLX_PTHREADS=$enableval], + [GLX_PTHREADS=auto]) +AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), + [GLX_USE_TLS=$enableval], + [GLX_USE_TLS=no]) + dnl Extensions. AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes]) AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes]) @@ -508,8 +519,6 @@ AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build Scr AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto]) AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto]) AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes]) -AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), [AIGLX=$enableval], [AIGLX=yes]) -AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no]) AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval]) AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes]) AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto]) @@ -696,7 +705,7 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then PKG_CHECK_MODULES([GL], [glproto >= 1.4.8]) AC_SUBST(XLIB_CFLAGS) AC_DEFINE(GLXEXT, 1, [Build GLX extension]) - GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la' + GLX_LIBS='$(top_builddir)/GL/glx/libglx.la' test -d GL || mkdir GL case $host_os in solaris*) @@ -720,6 +729,18 @@ else fi AM_CONDITIONAL(AIGLX, test "x$AIGLX" = xyes) +if test "x$GLX_PTHREADS" = xauto -a "x$GLX" = xyes; then + GLX_PTHREADS=no + if test "x$DRI" = xyes; then + GLX_PTHREADS=yes + fi +fi + +if test "x$GLX_PTHREADS" = xyes -a "x$GLX" = xyes; then + GLX_DEFINES="-DPTHREADS" + GLX_LIBS="$GLX_LIBS -lpthread" +fi + if test "x$GLX_USE_TLS" = xyes -a "x$AIGLX" = xyes; then GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS" GLX_LIBS="$GLX_LIBS -lpthread" @@ -1953,18 +1974,6 @@ Makefile GL/Makefile GL/apple/Makefile GL/glx/Makefile -GL/mesa/Makefile -GL/mesa/glapi/Makefile -GL/mesa/main/Makefile -GL/mesa/math/Makefile -GL/mesa/shader/Makefile -GL/mesa/shader/grammar/Makefile -GL/mesa/shader/slang/Makefile -GL/mesa/swrast/Makefile -GL/mesa/swrast_setup/Makefile -GL/mesa/tnl/Makefile -GL/mesa/vbo/Makefile -GL/mesa/X/Makefile include/Makefile composite/Makefile damageext/Makefile diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am index 11e576f..66d892f 100644 --- a/hw/xfree86/dixmods/Makefile.am +++ b/hw/xfree86/dixmods/Makefile.am @@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la SUBDIRS = extmod if GLX -GLXMODS = libglx.la libGLcore.la +GLXMODS = libglx.la endif if XTRAP @@ -50,10 +50,6 @@ INCLUDES = @XORG_INCS@ \ -I$(top_srcdir)/miext/shadow \ -I$(top_srcdir)/GL/glx -libGLcore_la_LDFLAGS = -avoid-version -libGLcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la -libGLcore_la_SOURCES = GLcoremodule.c - libdbe_la_LDFLAGS = -avoid-version libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la libdbe_la_SOURCES = dbemodule.c diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c index 5384f43..ec90e59 100644 --- a/hw/xfree86/dixmods/glxmodule.c +++ b/hw/xfree86/dixmods/glxmodule.c @@ -42,13 +42,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "micmap.h" #include "globals.h" -typedef struct __GLXscreen __GLXscreen; typedef struct __GLXprovider __GLXprovider; -struct __GLXprovider { - __GLXscreen *(*screenProbe)(ScreenPtr pScreen); - const char *name; - __GLXprovider *next; -}; +extern __GLXprovider __glXMesaProvider; extern void GlxPushProvider(__GLXprovider *provider); extern void GlxExtensionInit(void); @@ -88,33 +83,6 @@ _X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL }; static pointer glxModule; -static __GLXscreen * -__glXMesaProxyScreenProbe(ScreenPtr pScreen) -{ - pointer GLcore; - static __GLXprovider *provider; - - if (provider == NULL) { - GLcore = LoadSubModule(glxModule, "GLcore", NULL, NULL, NULL, NULL, - NULL, NULL); - if (GLcore == NULL) - return NULL; - - provider = LoaderSymbol("__glXMesaProvider"); - if (provider == NULL) - return NULL; - } - - return provider->screenProbe(pScreen); -} - -static __GLXprovider __glXMesaProxyProvider = { - __glXMesaProxyScreenProbe, - "MESA-PROXY", - NULL -}; - - static pointer glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) { @@ -129,7 +97,7 @@ glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) setupDone = TRUE; glxModule = module; - GlxPushProvider(&__glXMesaProxyProvider); + GlxPushProvider(&__glXMesaProvider); xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", xf86Info.aiglx ? "enabled" : "disabled");