Add support for GL_EXT_stencil_wrap, from hearing that the windows drivers did
[mesa.git] / src / mesa / drivers / dri / r128 / r128_context.c
index 7bb324473f7f11413e29697d3c9d496650642ae8..73bd3bebd68193a097301cf8edb723d12e3a5a7b 100644 (file)
@@ -56,7 +56,6 @@ 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"
@@ -67,17 +66,29 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 int R128_DEBUG = 0;
 #endif
 
-static const char * const card_extensions[] =
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_secondary_color
+#include "extension_helper.h"
+
+const struct dri_extension card_extensions[] =
 {
-   "GL_ARB_multisample",
-   "GL_ARB_multitexture",
-   "GL_ARB_texture_compression",
-   "GL_ARB_texture_env_add",
-   "GL_ARB_texture_mirrored_repeat",
-   "GL_EXT_texture_edge_clamp",
-   "GL_MESA_ycbcr_texture",
-   "GL_SGIS_generate_mipmap",
-   NULL
+    { "GL_ARB_multisample",                GL_ARB_multisample_functions },
+    { "GL_ARB_multitexture",               NULL },
+    { "GL_ARB_texture_compression",        GL_ARB_texture_compression_functions },
+    { "GL_ARB_texture_env_add",            NULL },
+    { "GL_ARB_texture_mirrored_repeat",    NULL },
+    { "GL_EXT_blend_subtract",             GL_EXT_blend_minmax_functions },
+    { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },
+    { "GL_EXT_texture_edge_clamp",         NULL },
+    { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
+    { "GL_EXT_stencil_wrap",               NULL },
+    { "GL_MESA_ycbcr_texture",             NULL },
+    { "GL_NV_blend_square",                NULL },
+    { "GL_SGIS_generate_mipmap",           NULL },
+    { NULL,                                NULL }
 };
 
 static const struct dri_debug_control debug_control[] =
@@ -88,6 +99,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 }
 };
 
@@ -144,7 +156,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    driParseConfigFiles (&rmesa->optionCache, &r128scrn->optionCache,
                         r128scrn->driScreen->myNum, "r128");
 
-   rmesa->sarea = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
+   rmesa->sarea = (drm_r128_sarea_t *)((char *)sPriv->pSAREA +
                                     r128scrn->sarea_priv_offset);
 
    rmesa->CurrentTexObj[0] = NULL;
@@ -159,9 +171,9 @@ 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 );
 
@@ -178,6 +190,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    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
@@ -230,25 +243,22 @@ 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 );
    r128DDInitStateFuncs( ctx );
    r128DDInitSpanFuncs( ctx );
    r128DDInitState( rmesa );
 
-   driInitTextureObjects( ctx, & rmesa->swapped,
-                         DRI_TEXMGR_DO_TEXTURE_1D
-                         | DRI_TEXMGR_DO_TEXTURE_2D );
-
    rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
        ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
 
@@ -259,6 +269,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;
 }
 
@@ -280,8 +295,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);
@@ -334,19 +347,13 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
       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;