Imported the Savage DRI driver from the savage-2-0-0-branch of DRI CVS
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_context.c
index 8dba39b87073e84e975806871ce4451ffb212a1d..973aa6cff21d2d33a09d61d48504ee15a65b2c21 100644 (file)
 #include "tdfx_dd.h"
 #include "tdfx_state.h"
 #include "tdfx_vb.h"
+#include "tdfx_tex.h"
 #include "tdfx_tris.h"
 #include "tdfx_render.h"
 #include "tdfx_span.h"
 #include "tdfx_texman.h"
 #include "extensions.h"
 
-
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "array_cache/acache.h"
@@ -54,6 +54,8 @@
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
+#include "drivers/common/driverfuncs.h"
+
 const char __driConfigOptions[] = { 0 };
 const GLuint __driNConfigOptions = 0;
 
@@ -115,19 +117,29 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
    tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
    TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
                                              sizeof(XF86DRISAREARec));
+   struct dd_function_table functions;
 
    /* Allocate tdfx context */
    fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
    if (!fxMesa)
       return GL_FALSE;
 
+   /* Init default driver functions then plug in our tdfx-specific functions
+    * (the texture functions are especially important)
+    */
+   _mesa_init_driver_functions(&functions);
+   tdfxDDInitDriverFuncs(mesaVis, &functions);
+   tdfxInitTextureFuncs(&functions);
+   tdfxInitRenderFuncs(&functions);
+
    /* Allocate the Mesa context */
    if (sharedContextPrivate)
       shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
    else 
       shareCtx = NULL;
 
-   fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx, (void *) fxMesa, GL_TRUE);
+   fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+                                        &functions, (void *) fxMesa);
    if (!fxMesa->glCtx) {
       FREE(fxMesa);
       return GL_FALSE;
@@ -246,10 +258,9 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
    _swrast_allow_vertex_fog( ctx, GL_FALSE );
 
    tdfxDDInitExtensions( ctx );
-   tdfxDDInitDriverFuncs( ctx );
-   tdfxDDInitStateFuncs( ctx );
-   tdfxDDInitRenderFuncs( ctx );
+   /* XXX these should really go right after _mesa_init_driver_functions() */
    tdfxDDInitSpanFuncs( ctx ); 
+   tdfxDDInitStateFuncs( ctx );
    tdfxDDInitTriFuncs( ctx );
    tdfxInitVB( ctx );
    tdfxInitState( fxMesa );
@@ -495,7 +506,7 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
       _mesa_destroy_context(fxMesa->glCtx);
 
       /* free the tdfx context */
-      XFree( fxMesa );
+      FREE( fxMesa );
    }
 }