Index: configure.ac =================================================================== RCS file: /cvs/xorg/xserver/xorg/configure.ac,v retrieving revision 1.177 diff -u -r1.177 configure.ac --- configure.ac 21 Mar 2006 22:54:38 -0000 1.177 +++ configure.ac 22 Mar 2006 16:09:46 -0000 @@ -557,7 +557,7 @@ PKG_CHECK_MODULES([GL], [glproto >= 1.4.6]) 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 $srcdir/GL/symlink-mesa.sh $MESA_SOURCE GL/ if test $? -ne 0; then Index: GL/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/GL/Makefile.am,v retrieving revision 1.6 diff -u -r1.6 Makefile.am --- GL/Makefile.am 17 Oct 2005 07:18:57 -0000 1.6 +++ GL/Makefile.am 22 Mar 2006 16:09:46 -0000 @@ -1,4 +1,4 @@ -SUBDIRS = glx mesa include +SUBDIRS = glx # someone could get really crazy someday and add support for the SI... Index: GL/glx/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/GL/glx/Makefile.am,v retrieving revision 1.13 diff -u -r1.13 Makefile.am --- GL/glx/Makefile.am 17 Mar 2006 01:47:24 -0000 1.13 +++ GL/glx/Makefile.am 22 Mar 2006 16:09:46 -0000 @@ -51,6 +51,7 @@ glxerror.h \ glxext.c \ glxext.h \ + glxsoftgl.c \ glxvisuals.c \ glxscreens.c \ glxscreens.h \ @@ -80,3 +81,6 @@ singlesize.h \ unpack.h \ xfont.c + +glxsoftgl.c: + ln -s ../mesa/X/xf86glx.c $@ Index: GL/mesa/X/xf86glx.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/GL/mesa/X/xf86glx.c,v retrieving revision 1.9 diff -u -r1.9 xf86glx.c --- GL/mesa/X/xf86glx.c 17 Mar 2006 01:47:25 -0000 1.9 +++ GL/mesa/X/xf86glx.c 22 Mar 2006 16:09:47 -0000 @@ -37,41 +37,37 @@ #include #endif +#include #include -#include -#include -#include -#include -#include -#include #include -#include + +#define _NEED_GLCORE_IF +#include +#include #include #include #include #include -#include #include -#include "context.h" -#include "xmesaP.h" -#include -#include "context.h" #include "glcontextmodes.h" #include "os.h" -/* - * This define is for the glcore.h header file. - * If you add it here, then make sure you also add it in - * ../../../glx/Imakefile. - */ -#if 0 -#define DEBUG -#include -#undef DEBUG -#else -#include -#endif +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; @@ -79,8 +75,8 @@ struct __GLXMESAscreen { __GLXscreen base; - int index; XMesaVisual *xm_vis; + void *driver; }; struct __GLXMESAcontext { @@ -229,8 +225,7 @@ __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst; __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc; - _mesa_copy_context(&src->xmesa->mesa, &dst->xmesa->mesa, mask); - return GL_TRUE; + return XMesaCopyContext(src->xmesa, dst->xmesa, mask); } static int @@ -238,7 +233,7 @@ { __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; - GlxSetRenderTables (context->xmesa->mesa.CurrentDispatch); + /* GlxSetRenderTables() for XGL moved within XMesaForceCurrent() */ return XMesaForceCurrent(context->xmesa); } @@ -300,6 +295,8 @@ xfree(mesaScreen->xm_vis); + dlclose(mesaScreen->driver); + __glXScreenDestroy(screen); xfree(screen); @@ -405,21 +402,43 @@ screen->xm_vis = pXMesaVisual; } +static const char dri_driver_path[] = DRI_DRIVER_PATH; + static __GLXscreen * __glXMesaScreenProbe(ScreenPtr pScreen) { __GLXMESAscreen *screen; + char filename[128]; + const char *err_msg; + const char *err_extra = NULL; screen = xalloc(sizeof *screen); if (screen == NULL) return NULL; - __glXScreenInit(&screen->base, pScreen); - screen->base.destroy = __glXMesaScreenDestroy; screen->base.createContext = __glXMesaScreenCreateContext; screen->base.pScreen = pScreen; + snprintf(filename, sizeof filename, "%s/%s.so", + dri_driver_path, "softgl"); + + screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); + if (screen->driver == NULL) { + err_msg = "Loading driver"; + err_extra = filename; + goto handle_error; + } + + glcore = dlsym(screen->driver, "glcore"); + if (glcore == NULL) { + err_msg = "Driver entry point lookup"; + err_extra = "glcore"; + goto handle_error; + } + + __glXScreenInit(&screen->base, pScreen); + /* * Find the GLX visuals that are supported by this screen and create * XMesa's visuals. @@ -427,6 +446,23 @@ init_screen_visuals(screen); return &screen->base; + +handle_error: + + if (screen->driver) + dlclose(screen->driver); + + xfree(screen); + + if (err_extra != NULL) + LogMessage(X_ERROR, + "GLX error: %s failed (%s)\n", err_msg, err_extra); + else + LogMessage(X_ERROR, "GLX error: %s failed\n", err_msg); + + FatalError("GLX: could not load software renderer\n"); + + return NULL; } __GLXprovider __glXMesaProvider = { Index: GL/mesa/X/xf86glx_util.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/GL/mesa/X/xf86glx_util.c,v retrieving revision 1.3 diff -u -r1.3 xf86glx_util.c --- GL/mesa/X/xf86glx_util.c 10 Feb 2006 22:00:19 -0000 1.3 +++ GL/mesa/X/xf86glx_util.c 22 Mar 2006 16:09:47 -0000 @@ -38,11 +38,8 @@ #include -#include -#include "pixmapstr.h" -#include "xf86glx_util.h" +#include "xorg_glx_util.h" #include -#include "GL/xf86glx.h" #ifdef ROUNDUP #undef ROUNDUP Index: hw/xfree86/dixmods/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/dixmods/Makefile.am,v retrieving revision 1.28 diff -u -r1.28 Makefile.am --- hw/xfree86/dixmods/Makefile.am 12 Mar 2006 17:14:03 -0000 1.28 +++ hw/xfree86/dixmods/Makefile.am 22 Mar 2006 16:09:50 -0000 @@ -3,7 +3,7 @@ SUBDIRS = extmod if GLX -GLXMODS = libglx.la libGLcore.la +GLXMODS = libglx.la endif if XTRAP @@ -39,10 +39,6 @@ -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 - libafb_la_LDFLAGS = -avoid-version libafb_la_LIBADD = $(top_builddir)/afb/libafb.la libafb_la_SOURCES = afbmodule.c Index: hw/xfree86/dixmods/glxmodule.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/dixmods/glxmodule.c,v retrieving revision 1.9 diff -u -r1.9 glxmodule.c --- hw/xfree86/dixmods/glxmodule.c 12 Mar 2006 00:11:33 -0000 1.9 +++ hw/xfree86/dixmods/glxmodule.c 22 Mar 2006 16:09:50 -0000 @@ -43,13 +43,8 @@ #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); @@ -89,33 +84,6 @@ static pointer glxModule; -static __GLXscreen * -__glXMesaProxyScreenProbe(ScreenPtr pScreen) -{ - pointer GLcore; - static __GLXprovider *provider; - - if (provider == NULL) { - GLcore = LoadSubModuleLocal(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) { @@ -130,7 +98,7 @@ setupDone = TRUE; glxModule = module; - GlxPushProvider(&__glXMesaProxyProvider); + GlxPushProvider(&__glXMesaProvider); xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", xf86Info.aiglx ? "enabled" : "disabled");