The first patch (against the Mesa tree) fixes tdfx_screen.c to use the new interface. The second patch (against the DRI tree) fixes the Imakefilery to use the new interface and link against the common objects.
Without these two tdfx is completely broken. With them, it works as well as it did before driinterface was merged (which for me means textured apps are hosed but glxgears works fine). That's next on my chopping block. I tested this on 16-bit and 24-bit depths. Comments are welcome. I don't particularly like how this duplicates loops in *_dri.c and *_screen.c. I'd like to see a shared visual config table defined in a header somewhere so we don't have to touch multiple places, but I suspect that'd get ugly quick.
Index: src/mesa/drivers/dri/tdfx/tdfx_screen.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c,v retrieving revision 1.2 diff -u -r1.2 tdfx_screen.c --- src/mesa/drivers/dri/tdfx/tdfx_screen.c 8 Dec 2003 17:14:47 -0000 1.2 +++ src/mesa/drivers/dri/tdfx/tdfx_screen.c 16 Mar 2004 01:37:04 -0000 @@ -316,6 +316,129 @@ .SwapBuffersMSC = NULL }; +#ifdef USE_NEW_INTERFACE +/* + * new interface code, derived from radeon_screen.c + * XXX this may still be wrong + */ +static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; + +static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits, + unsigned depth_bits, + unsigned stencil_bits, + GLboolean have_back_buffer) +{ + __GLcontextModes *modes; + __GLcontextModes *m; + unsigned num_modes; + unsigned vis[2] = { GLX_TRUE_COLOR, GLX_DIRECT_COLOR }; + unsigned deep = (depth_bits > 17); + unsigned i, db, depth, accum, stencil; + + /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy + * enough to add support. Basically, if a context is created with an + * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping + * will never be used. + */ + + num_modes = (depth_bits == 16) ? 32 : 16; + + modes = (*create_context_modes)(num_modes, sizeof(__GLcontextModes)); + m = modes; + + for (i = 0; i <= 1; i++) { + for (db = 0; db <= 1; db++) { + for (depth = 0; depth <= 1; depth++) { + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= !deep; stencil++) { + if (deep) stencil = depth; + m->redBits = deep ? 8 : 5; + m->greenBits = deep ? 8 : 6; + m->blueBits = deep ? 8 : 5; + m->alphaBits = deep ? 8 : 0; + m->redMask = deep ?0xFF000000 :0x0000F800; + m->greenMask = deep ?0x00FF0000 :0x000007E0; + m->blueMask = deep ?0x0000FF00 :0x0000001F; + m->alphaMask = deep ? 0x000000FF : 0; + m->rgbBits = m->redBits + m->greenBits + + m->blueBits + m->alphaBits; + m->accumRedBits = accum ? 16 : 0; + m->accumGreenBits = accum ? 16 : 0; + m->accumBlueBits = accum ? 16 : 0; + m->accumAlphaBits = accum ? 16 : 0; + m->stencilBits = stencil ? 8 : 0; + m->depthBits = deep + ? (depth ? 24 : 0) + : (depth ? 0 : depth_bits); + m->visualType = i ? GLX_TRUE_COLOR + : GLX_DIRECT_COLOR; + m->renderType = GLX_RGBA_BIT; + m->drawableType = GLX_WINDOW_BIT; + m->rgbMode = GL_TRUE; + m->doubleBufferMode = db ? GL_TRUE : GL_FALSE; + if (db) + m->swapMethod = GLX_SWAP_UNDEFINED_OML; + m->visualRating = ((stencil && !deep) || accum) + ? GLX_SLOW_CONFIG + : GLX_NONE; + m = m->next; + if (deep) stencil = 0; + } + } + } + } + } + + return modes; +} + +/** + * This is the bootstrap function for the driver. libGL supplies all of the + * requisite information about the system, and the driver initializes itself. + * This routine also fills in the linked list pointed to by \c driver_modes + * with the \c __GLcontextModes that the driver can support for windows or + * pbuffers. + * + * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on + * failure. + */ +void * __driCreateNewScreen( Display *dpy, int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + __GLcontextModes ** driver_modes ) +{ + __DRIscreenPrivate *psp; + + psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + ddx_version, dri_version, drm_version, + frame_buffer, pSAREA, fd, + internal_api_version, &tdfxAPI); + + create_context_modes = (PFNGLXCREATECONTEXTMODES) + glXGetProcAddress((const GLubyte *)"__glXCreateContextModes"); + + if (create_context_modes != NULL) { + /* divined from tdfx_dri.c, sketchy */ + TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv; + int bpp = (dri_priv->cpp > 2) ? 24 : 16; + + /* XXX i wish it was like this */ + /* bpp = dri_priv->bpp */ + + *driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24, + (bpp == 16) ? 0 : 8, + (dri_priv->backOffset!=dri_priv->depthOffset)); + } + + return (void *)psp; +} +#endif /* USE_NEW_INTERFACE */ + /* * This is the bootstrap function for the driver.
Index: xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile,v retrieving revision 1.4 diff -u -r1.4 Imakefile --- xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile 10 Dec 2003 01:45:57 -0000 1.4 +++ xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile 16 Mar 2004 01:38:58 -0000 @@ -48,7 +48,7 @@ SRCS = $(TDFXSRCS) OBJS = $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \ - $(MESA_ASM_OBJS) $(TDFXOBJS) + $(MESA_ASM_OBJS) $(TDFXOBJS) $(COMMONOBJS) REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB) $(XONLYLIB) ExpatLibrary Index: xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc =================================================================== RCS file: /cvs/dri/xc/xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc,v retrieving revision 1.2 diff -u -r1.2 Imakefile.inc --- xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc 9 Dec 2003 15:33:36 -0000 1.2 +++ xc/lib/GL/mesa/drivers/dri/tdfx/Imakefile.inc 16 Mar 2004 01:38:58 -0000 @@ -16,7 +16,7 @@ #endif #if BuildXF86DRI - DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder + DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder -DUSE_NEW_INTERFACE DRI_INCLUDES = -I$(GLXLIBSRC)/dri \ -I$(XINCLUDESRC) \ -I$(GLXLIBSRC)/glx \