Turn off VBO's.
[mesa.git] / src / mesa / drivers / dri / r128 / r128_context.c
index f7f6d7141d2868a7287ae450d3d5d4448e4283cb..587cd0496b6616b93dde03c4ef81eabd3ca47eae 100644 (file)
@@ -47,6 +47,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 
+#include "drivers/common/driverfuncs.h"
+
 #include "r128_context.h"
 #include "r128_ioctl.h"
 #include "r128_dd.h"
@@ -54,11 +56,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r128_span.h"
 #include "r128_tex.h"
 #include "r128_tris.h"
-#include "r128_vb.h"
 
 #include "vblank.h"
 #include "utils.h"
 #include "texmem.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
 
 #ifndef R128_DEBUG
 int R128_DEBUG = 0;
@@ -66,14 +68,16 @@ int R128_DEBUG = 0;
 
 static const char * const card_extensions[] =
 {
+   "GL_ARB_multisample",
    "GL_ARB_multitexture",
+   "GL_ARB_texture_compression",
    "GL_ARB_texture_env_add",
    "GL_ARB_texture_mirrored_repeat",
+   "GL_EXT_blend_subtract",
    "GL_EXT_texture_edge_clamp",
-   "GL_EXT_texture_env_add",
-   "GL_IBM_texture_mirrored_repeat",
+   "GL_MESA_ycbcr_texture",
+   "GL_NV_blend_square",
    "GL_SGIS_generate_mipmap",
-   "GL_SGIS_texture_edge_clamp",
    NULL
 };
 
@@ -85,6 +89,7 @@ static const struct dri_debug_control debug_control[] =
     { "2d",    DEBUG_VERBOSE_2D },
     { "sync",  DEBUG_ALWAYS_SYNC },
     { "api",   DEBUG_VERBOSE_API },
+    { "fall",  DEBUG_VERBOSE_FALL },
     { NULL,    0 }
 };
 
@@ -96,6 +101,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
 {
    GLcontext *ctx, *shareCtx;
    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+   struct dd_function_table functions;
    r128ContextPtr rmesa;
    r128ScreenPtr r128scrn;
    int i;
@@ -105,12 +111,21 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    if ( !rmesa )
       return GL_FALSE;
 
+   /* Init default driver functions then plug in our Radeon-specific functions
+    * (the texture functions are especially important)
+    */
+   _mesa_init_driver_functions( &functions );
+   r128InitDriverFuncs( &functions );
+   r128InitIoctlFuncs( &functions );
+   r128InitTextureFuncs( &functions );
+
    /* Allocate the Mesa context */
    if (sharedContextPrivate)
       shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx;
    else 
       shareCtx = NULL;
-   rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE);
+   rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+                                       &functions, (void *) rmesa);
    if (!rmesa->glCtx) {
       FREE(rmesa);
       return GL_FALSE;
@@ -127,7 +142,11 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
 
    r128scrn = rmesa->r128Screen = (r128ScreenPtr)(sPriv->private);
 
-   rmesa->sarea = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
+   /* Parse configuration files */
+   driParseConfigFiles (&rmesa->optionCache, &r128scrn->optionCache,
+                        r128scrn->driScreen->myNum, "r128");
+
+   rmesa->sarea = (drm_r128_sarea_t *)((char *)sPriv->pSAREA +
                                     r128scrn->sarea_priv_offset);
 
    rmesa->CurrentTexObj[0] = NULL;
@@ -142,20 +161,26 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
            r128scrn->texSize[i],
            12,
            R128_NR_TEX_REGIONS,
-           rmesa->sarea->texList[i],
-           & rmesa->sarea->texAge[i],
-           & rmesa->swapped,
+           (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
+           &rmesa->sarea->tex_age[i],
+           &rmesa->swapped,
            sizeof( r128TexObj ),
            (destroy_texture_object_t *) r128DestroyTexObj );
 
       driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
                                        & rmesa->c_textureSwaps );
    }
+   rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
+                                          "texture_depth");
+   if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+      rmesa->texture_depth = ( r128scrn->cpp == 4 ) ?
+        DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
 
 
    rmesa->RenderIndex = -1;            /* Impossible value */
    rmesa->vert_buf = NULL;
    rmesa->num_verts = 0;
+   rmesa->tnl_state = ~0;
 
    /* Set the maximum texture size small enough that we can guarentee that
     * all texture units can bind a maximal texture and have them both in
@@ -163,6 +188,8 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
     */
 
    ctx->Const.MaxTextureUnits = 2;
+   ctx->Const.MaxTextureImageUnits = 2;
+   ctx->Const.MaxTextureCoordUnits = 2;
 
    driCalculateMaxTextureLevels( rmesa->texture_heaps,
                                 rmesa->nr_heaps,
@@ -191,7 +218,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    ctx->Const.LineWidthGranularity = 1.0;
 
 #if ENABLE_PERF_BOXES
-   rmesa->boxes = (getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL);
+   rmesa->boxes = driQueryOptionb(&rmesa->optionCache, "performance_boxes");
 #endif
 
    /* Initialize the software rasterizer and helper modules.
@@ -206,28 +233,24 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
 /*     _tnl_destroy_pipeline( ctx ); */
 /*     _tnl_install_pipeline( ctx, r128_pipeline ); */
 
-   /* Configure swrast to match hardware characteristics:
+   /* Configure swrast and T&L 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 );
 
    driInitExtensions( ctx, card_extensions, GL_TRUE );
    if (sPriv->drmMinor >= 4)
       _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
 
-   r128InitVB( ctx );
    r128InitTriFuncs( ctx );
-   r128DDInitDriverFuncs( ctx );
-   r128DDInitIoctlFuncs( ctx );
    r128DDInitStateFuncs( ctx );
    r128DDInitSpanFuncs( ctx );
-   r128DDInitTextureFuncs( ctx );
    r128DDInitState( rmesa );
 
-   rmesa->do_irqs = (rmesa->r128Screen->irq && !getenv("R128_NO_IRQS"));
-
-   rmesa->vblank_flags = (rmesa->do_irqs)
-       ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ;
+   rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
+       ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
 
    driContextPriv->driverPrivate = (void *)rmesa;
 
@@ -236,6 +259,11 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
                                     debug_control );
 #endif
 
+   if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+      fprintf(stderr, "disabling 3D acceleration\n");
+      FALLBACK(rmesa, R128_FALLBACK_DISABLE, 1);
+   }
+
    return GL_TRUE;
 }
 
@@ -257,8 +285,6 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
       _ac_DestroyContext( rmesa->glCtx );
       _swrast_DestroyContext( rmesa->glCtx );
 
-      r128FreeVB( rmesa->glCtx );
-
       /* free the Mesa context */
       rmesa->glCtx->DriverCtx = NULL;
       _mesa_destroy_context(rmesa->glCtx);
@@ -269,14 +295,17 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv  )
           */
          int i;
 
-        assert( is_empty_list( & rmesa->swapped ) );
-
          for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
            driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
            rmesa->texture_heaps[ i ] = NULL;
          }
+
+        assert( is_empty_list( & rmesa->swapped ) );
       }
 
+      /* free the option cache */
+      driDestroyOptionCache (&rmesa->optionCache);
+
       FREE( rmesa );
    }
 
@@ -305,21 +334,16 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
         newR128Ctx->dirty = R128_UPLOAD_ALL;
       }
 
+      driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
       newR128Ctx->driDrawable = driDrawPriv;
 
-      _mesa_make_current2( newR128Ctx->glCtx,
-                           (GLframebuffer *) driDrawPriv->driverPrivate,
-                           (GLframebuffer *) driReadPriv->driverPrivate );
-
+      _mesa_make_current( newR128Ctx->glCtx,
+                          (GLframebuffer *) driDrawPriv->driverPrivate,
+                          (GLframebuffer *) driReadPriv->driverPrivate );
 
       newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
-
-      if ( !newR128Ctx->glCtx->Viewport.Width ) {
-        _mesa_set_viewport(newR128Ctx->glCtx, 0, 0,
-                            driDrawPriv->w, driDrawPriv->h);
-      }
    } else {
-      _mesa_make_current( 0, 0 );
+      _mesa_make_current( NULL, NULL, NULL );
    }
 
    return GL_TRUE;