On the way to getting stencil working.
[mesa.git] / src / mesa / drivers / dri / sis / sis_context.c
index c49db5fe34bcca7dbcb97174c7bdaa58c2715842..3b23b7df4e55f26daa2c35d1ccf33e64ea02c9cb 100644 (file)
@@ -41,7 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "sis_stencil.h"
 #include "sis_tex.h"
 #include "sis_tris.h"
-#include "sis_vb.h"
+#include "sis_alloc.h"
 
 #include "imports.h"
 #include "matrix.h"
@@ -65,6 +65,7 @@ static const char * const card_extensions[] =
 {
    "GL_ARB_multitexture",
    "GL_EXT_texture_lod_bias",
+   "GL_NV_blend_square",
    NULL
 };
 
@@ -199,18 +200,29 @@ sisCreateContext( const __GLcontextModes *glVisual,
    smesa->AGPBase = sisScreen->agp.map;
    smesa->AGPAddr = sisScreen->agp.handle;
 
-   /* set AGP command buffer */
-   if (smesa->AGPSize != 0 && sisScreen->AGPCmdBufSize != 0 &&
+   /* Create AGP command buffer */
+   if (smesa->AGPSize != 0 && 
       !driQueryOptionb(&smesa->optionCache, "agp_disable"))
-   {   
-      smesa->AGPCmdBufBase = smesa->AGPBase + sisScreen->AGPCmdBufOffset;
-      smesa->AGPCmdBufAddr = smesa->AGPAddr + sisScreen->AGPCmdBufOffset;
-      smesa->AGPCmdBufSize = sisScreen->AGPCmdBufSize;
-
-      smesa->pAGPCmdBufNext = (GLint *)&(smesa->sarea->AGPCmdBufNext);
-      smesa->AGPCmdModeEnabled = GL_TRUE;
-   } else {
-      smesa->AGPCmdModeEnabled = GL_FALSE;
+   {
+      smesa->vb = sisAllocAGP(smesa, 64 * 1024, &smesa->vb_agp_handle);
+      if (smesa->vb != NULL) {
+        smesa->using_agp = GL_TRUE;
+        smesa->vb_cur = smesa->vb;
+        smesa->vb_last = smesa->vb;
+        smesa->vb_end = smesa->vb + 64 * 1024;
+        smesa->vb_agp_offset = ((long)smesa->vb - (long)smesa->AGPBase +
+           (long)smesa->AGPAddr);
+      }
+   }
+   if (!smesa->using_agp) {
+      smesa->vb = malloc(64 * 1024);
+      if (smesa->vb == NULL) {
+        FREE(smesa);
+        return GL_FALSE;
+      }
+      smesa->vb_cur = smesa->vb;
+      smesa->vb_last = smesa->vb;
+      smesa->vb_end = smesa->vb + 64 * 1024;
    }
 
    smesa->GlobalFlag = 0L;
@@ -232,7 +244,6 @@ sisCreateContext( const __GLcontextModes *glVisual,
    /* XXX these should really go right after _mesa_init_driver_functions() */
    sisDDInitStateFuncs( ctx );
    sisDDInitState( smesa );    /* Initializes smesa->zFormat, important */
-   sisInitVB( ctx );
    sisInitTriFuncs( ctx );
    sisDDInitSpanFuncs( ctx );
    sisDDInitStencilFuncs( ctx );
@@ -264,6 +275,9 @@ sisDestroyContext ( __DRIcontextPrivate *driContextPriv )
       _ac_DestroyContext( smesa->glCtx );
       _swrast_DestroyContext( smesa->glCtx );
 
+      if (smesa->using_agp)
+        sisFreeAGP(smesa, smesa->vb_agp_handle);
+
       /* free the Mesa context */
       /* XXX: Is the next line needed?  The DriverCtx (smesa) reference is
        * needed for sisDDDeleteTexture, since it needs to call the FB/AGP free
@@ -298,11 +312,6 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
 
       sisUpdateBufferSize( newSisCtx );
       sisUpdateClipping( newSisCtx->glCtx );
-
-      if ( newSisCtx->glCtx->Viewport.Width == 0 ) {
-         _mesa_set_viewport(newSisCtx->glCtx, 0, 0,
-                            driDrawPriv->w, driDrawPriv->h);
-      }
    } else {
       _mesa_make_current( 0, 0 );
    }