Merge remote branch 'nouveau/gallium-0.1' into nouveau-gallium-0.2
[mesa.git] / src / mesa / drivers / dri / gamma / gamma_context.c
index f7db2adea373408b52d3fd1631baa7666dc43fbd..b1dcbfcdcfaa150b7d76f1e57d4e1a2c04801b55 100644 (file)
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
 
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
+#include "drivers/common/driverfuncs.h"
+
 #include "context.h"
 #include "simple_list.h"
 #include "imports.h"
 #include "matrix.h"
 #include "extensions.h"
 #if defined(USE_X86_ASM)
-#include "X86/common_x86_asm.h"
+#include "x86/common_x86_asm.h"
 #endif
 #include "simple_list.h"
 #include "mm.h"
@@ -48,9 +50,9 @@
 #include "gamma_vb.h"
 #include "gamma_tris.h"
 
-extern const struct gl_pipeline_stage _gamma_render_stage;
+extern const struct tnl_pipeline_stage _gamma_render_stage;
 
-static const struct gl_pipeline_stage *gamma_pipeline[] = {
+static const struct tnl_pipeline_stage *gamma_pipeline[] = {
    &_tnl_vertex_transform_stage,
    &_tnl_normal_transform_stage,
    &_tnl_lighting_stage,
@@ -74,10 +76,18 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
    gammaContextPtr gmesa;
    gammaScreenPtr gammascrn;
    GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
-                                                sizeof(XF86DRISAREARec));
+                                                sizeof(drm_sarea_t));
+   struct dd_function_table functions;
 
    gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
-   if ( !gmesa ) return GL_FALSE;
+   if (!gmesa)
+      return GL_FALSE;
+
+   /* Init default driver functions then plug in our gamma-specific functions
+    * (the texture functions are especially important)
+    */
+   _mesa_init_driver_functions( &functions );
+   gammaDDInitTextureFuncs( &functions );
 
    /* Allocate the Mesa context */
    if (sharedContextPrivate)
@@ -85,7 +95,8 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
    else
       shareCtx = NULL;
 
-   gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) gmesa, GL_TRUE);
+   gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+                                       &functions, (void *) gmesa);
    if (!gmesa->glCtx) {
       FREE(gmesa);
       return GL_FALSE;
@@ -104,8 +115,10 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
 
    ctx = gmesa->glCtx;
 
-   ctx->Const.MaxTextureLevels = 13;  /* 4K by 4K?  Is that right? */
+   ctx->Const.MaxTextureLevels = GAMMA_TEX_MAXLEVELS;
    ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
+   ctx->Const.MaxTextureImageUnits = 1;
+   ctx->Const.MaxTextureCoordUnits = 1;
 
    ctx->Const.MinLineWidth = 0.0;
    ctx->Const.MaxLineWidth = 255.0;
@@ -134,7 +147,7 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
    /* Initialize the software rasterizer and helper modules.
     */
    _swrast_CreateContext( ctx );
-   _ac_CreateContext( ctx );
+   _vbo_CreateContext( ctx );
    _tnl_CreateContext( ctx );
    _swsetup_CreateContext( ctx );
 
@@ -143,20 +156,24 @@ GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
    _tnl_destroy_pipeline( ctx );
    _tnl_install_pipeline( ctx, gamma_pipeline );
 
-   /* Configure swrast to match hardware characteristics:
+   /* Configure swrast & TNL to match hardware characteristics:
     */
    _swrast_allow_pixel_fog( ctx, GL_FALSE );
    _swrast_allow_vertex_fog( ctx, GL_TRUE );
+   _tnl_allow_pixel_fog( ctx, GL_FALSE );
+   _tnl_allow_vertex_fog( ctx, GL_TRUE );
 
    gammaInitVB( ctx );
    gammaDDInitExtensions( ctx );
+   /* XXX these should really go right after _mesa_init_driver_functions() */
    gammaDDInitDriverFuncs( ctx );
    gammaDDInitStateFuncs( ctx );
    gammaDDInitSpanFuncs( ctx );
-   gammaDDInitTextureFuncs( ctx );
    gammaDDInitTriFuncs( ctx );
    gammaDDInitState( gmesa );
 
+   gammaInitTextureObjects( ctx );
+
    driContextPriv->driverPrivate = (void *)gmesa;
 
    GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,