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 2bc7de00e9674b2e7b825411b9b8199a6330ba10..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"
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
+#include "drivers/common/driverfuncs.h"
+
+const char __driConfigOptions[] = { 0 };
+const GLuint __driNConfigOptions = 0;
 
 /*
  * Enable/Disable the extensions for this context.
@@ -113,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;
@@ -207,6 +221,8 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
       ctx->Const.MaxTextureLevels = 9;
    }
    ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2;
+   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+   ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
 
    /* No wide points.
     */
@@ -242,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 );
@@ -491,7 +506,7 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
       _mesa_destroy_context(fxMesa->glCtx);
 
       /* free the tdfx context */
-      XFree( fxMesa );
+      FREE( fxMesa );
    }
 }