i965: Remove BRW_WM_LOCK dirty bit, introduced to work around lack of relocs.
[mesa.git] / src / mesa / drivers / glide / fxapi.c
index 0474de9016ae42225de7334cc3979b59a4f9cc58..b7708fd636a2504dd781068a5724edd79f070d30 100644 (file)
 #include "fxdrv.h"
 
 #include "drivers/common/driverfuncs.h"
+#include "main/framebuffer.h"
 
 #ifndef TDFX_DEBUG
-int TDFX_DEBUG = (0 
+int TDFX_DEBUG = (0
 /*               | VERBOSE_VARRAY */
 /*               | VERBOSE_TEXTURE */
 /*               | VERBOSE_IMMEDIATE */
@@ -356,11 +357,7 @@ fxMesaCreateContext(GLuint win,
  }
 
  grSstSelect(glbCurrentBoard);
- /*grEnable(GR_OPENGL_MODE_EXT);*/ /* ZZZ: trick to make GL happy.
-                                  Glide3 will unmap memory for card when grSstWinClose is called.
-                                  This also forces the SLI band height to be 32 (above 1024x768) or 16
-                                  and disables the splash screen due to y-origin swapping.
-                                  Note: We only want the former. */
+ /*grEnable(GR_OPENGL_MODE_EXT);*/ /* [koolsmoky] */
  voodoo = &glbHWConfig.SSTs[glbCurrentBoard];
 
  fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext);
@@ -386,21 +383,14 @@ fxMesaCreateContext(GLuint win,
                       Glide->txMipQuantize &&
                       Glide->txPalToNcc && !getenv("MESA_FX_IGNORE_TEXUS2");
 
- /*
-  * Pixel tables are used during pixel read-back
-  * Either initialize them for RGB or BGR order;
-  * However, 32bit capable cards have the right order.
-  * As a consequence, 32bit read-back is not swizzled!
-  * Also determine if we need vertex snapping.
-  */
- /* number of SLI units and AA Samples per chip */
+ /* Determine if we need vertex swapping, RGB order and SLI/AA */
  sliaa = 0;
  switch (fxMesa->type) {
         case GR_SSTTYPE_VOODOO:
         case GR_SSTTYPE_SST96:
         case GR_SSTTYPE_Banshee:
              fxMesa->bgrOrder = GL_TRUE;
-             fxMesa->snapVertices = GL_TRUE;
+             fxMesa->snapVertices = (getenv("MESA_FX_NOSNAP") == NULL);
              break;
         case GR_SSTTYPE_Voodoo2:
              fxMesa->bgrOrder = GL_TRUE;
@@ -408,6 +398,7 @@ fxMesaCreateContext(GLuint win,
              break;
         case GR_SSTTYPE_Voodoo4:
         case GR_SSTTYPE_Voodoo5:
+             /* number of SLI units and AA Samples per chip */
              if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) {
                 sliaa = atoi(str);
              }
@@ -417,7 +408,7 @@ fxMesaCreateContext(GLuint win,
              fxMesa->snapVertices = GL_FALSE;
              break;
  }
- /* ZZZ TO DO: Add the old SLI/AA settings for Napalm. */
+ /* XXX todo - Add the old SLI/AA settings for Napalm. */
  switch(voodoo->numChips) {
  case 4: /* 4 chips */
    switch(sliaa) {
@@ -506,6 +497,8 @@ fxMesaCreateContext(GLuint win,
          pixFmt = GR_PIXFMT_RGB_565;
      }
      break;
+   case 24:
+     fxMesa->colDepth = 32;
    case 32:
      redBits   = 8;
      greenBits = 8;
@@ -530,8 +523,6 @@ fxMesaCreateContext(GLuint win,
      goto errorhandler;
  }
 
- /* ZZZ TODO: check if there is enough fbRam */
-
  /* Tips:
   * 1. we don't bother setting/checking AUX for stencil, because we'll decide
   *    later whether we have HW stencil, based on depth buffer (thus AUX is
@@ -571,8 +562,8 @@ fxMesaCreateContext(GLuint win,
 
  if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPPENDINGCOUNT"))) {
     fxMesa->maxPendingSwapBuffers = atoi(str);
-    if (fxMesa->maxPendingSwapBuffers > 3) {
-       fxMesa->maxPendingSwapBuffers = 3;
+    if (fxMesa->maxPendingSwapBuffers > 6) {
+       fxMesa->maxPendingSwapBuffers = 6;
     } else if (fxMesa->maxPendingSwapBuffers < 0) {
        fxMesa->maxPendingSwapBuffers = 0;
     }
@@ -648,7 +639,7 @@ fxMesaCreateContext(GLuint win,
                       fxMesa->snapVertices ? "" : "no ");
    }
 
-  sprintf(fxMesa->rendererString, "Mesa %s v0.61 %s%s",
+  sprintf(fxMesa->rendererString, "Mesa %s v0.63 %s%s",
           grGetString(GR_RENDERER),
           grGetString(GR_HARDWARE),
           ((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : "");
@@ -688,11 +679,17 @@ fxMesaCreateContext(GLuint win,
    }
 
 
-   fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis,
+   fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis);
+#if 0
+/* XXX this is a complete mess :(
+ *     _mesa_add_soft_renderbuffers
+ *     driNewRenderbuffer
+ */
                                               GL_FALSE,        /* no software depth */
                                               stencilSize && !fxMesa->haveHwStencil,
                                               fxMesa->glVis->accumRedBits > 0,
                                               alphaSize && !fxMesa->haveHwAlpha);
+#endif
    if (!fxMesa->glBuffer) {
       str = "_mesa_create_framebuffer";
       goto errorhandler;
@@ -703,7 +700,7 @@ fxMesaCreateContext(GLuint win,
    /* install signal handlers */
 #if defined(__linux__)
    /* Only install if environment var. is not set. */
-   if (fxMesa->glCtx->CatchSignals && !getenv("MESA_FX_NO_SIGNALS")) {
+   if (!getenv("MESA_FX_NO_SIGNALS")) {
       signal(SIGINT, cleangraphics_handler);
       signal(SIGHUP, cleangraphics_handler);
       signal(SIGPIPE, cleangraphics_handler);
@@ -731,7 +728,7 @@ errorhandler:
        FREE(fxMesa->fogTable);
     }
     if (fxMesa->glBuffer) {
-       _mesa_destroy_framebuffer(fxMesa->glBuffer);
+       _mesa_unreference_framebuffer(&fxMesa->glBuffer);
     }
     if (fxMesa->glVis) {
        _mesa_destroy_visual(fxMesa->glVis);
@@ -822,21 +819,17 @@ fxMesaDestroyContext(fxMesaContext fxMesa)
               (unsigned) st.pixelsOut);
    }
 
-   /* [dBorca]
-    * close the hardware first, so we can debug
-    * atexit problems (memory leaks, etc).
-    * NB: fxDDDestroyFxMesaContext must be called
-    * before _mesa_destroy_context; which must be
-    * called before fxTMClose!
+   /* close the hardware first,
+    * so we can debug atexit problems (memory leaks, etc).
     */
    grSstWinClose(fxMesa->glideContext);
    fxCloseHardware();
 
-   fxDDDestroyFxMesaContext(fxMesa);
+   fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */
    _mesa_destroy_visual(fxMesa->glVis);
    _mesa_destroy_context(fxMesa->glCtx);
-   _mesa_destroy_framebuffer(fxMesa->glBuffer);
-   fxTMClose(fxMesa);
+   _mesa_unreference_framebuffer(&fxMesa->glBuffer);
+   fxTMClose(fxMesa); /* must be after _mesa_destroy_context */
 
    FREE(fxMesa);
 
@@ -852,7 +845,7 @@ void GLAPIENTRY
 fxMesaMakeCurrent(fxMesaContext fxMesa)
 {
    if (!fxMesa) {
-      _mesa_make_current(NULL, NULL);
+      _mesa_make_current(NULL, NULL, NULL);
       fxMesaCurrentCtx = NULL;
 
       if (TDFX_DEBUG & VERBOSE_DRIVER) {
@@ -884,13 +877,9 @@ fxMesaMakeCurrent(fxMesaContext fxMesa)
    grSstSelect(fxMesa->board);
    grGlideSetState((GrState *) fxMesa->state);
 
-   _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer);
+   _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer, fxMesa->glBuffer);
 
    fxSetupDDPointers(fxMesa->glCtx);
-
-   /* The first time we call MakeCurrent we set the initial viewport size */
-   if (fxMesa->glCtx->Viewport.Width == 0)
-      _mesa_set_viewport(fxMesa->glCtx, 0, 0, fxMesa->width, fxMesa->height);
 }