drivers: don't include texformat.h
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_state.c
index 818a9bc23f4321960118a10a18a179182e23f2af..cf2712720f39705fec81f4cfe5ec17bd0c93ccc4 100644 (file)
@@ -23,7 +23,6 @@
  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
 
 /*
  * New fixes:
  *
  */
 
-#include "mtypes.h"
-#include "colormac.h"
-#include "texformat.h"
-#include "texstore.h"
-#include "teximage.h"
+#include "main/mtypes.h"
+#include "main/colormac.h"
+#include "main/texstore.h"
+#include "main/teximage.h"
 
 #include "swrast/swrast.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
 #include "tnl/tnl.h"
 #include "tnl/t_pipeline.h"
 #include "swrast_setup/swrast_setup.h"
@@ -189,12 +187,12 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
         break;
       case GL_DST_COLOR:
          if (isNapalm) {
-           srcRGB = GR_BLEND_SAME_COLOR_EXT;
+           dstRGB = GR_BLEND_SAME_COLOR_EXT;
            break;
          }
       case GL_ONE_MINUS_DST_COLOR:
          if (isNapalm) {
-           srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
+           dstRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
            break;
          }
       default:
@@ -376,7 +374,7 @@ static void tdfxUpdateZMode( GLcontext *ctx )
       mask = FXFALSE;        /* zbuffer is not touched */
    }
 
-   fxMesa->Depth.Clear = (FxU32) (ctx->DepthMaxF * ctx->Depth.Clear);
+   fxMesa->Depth.Clear = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear);
 
    if ( fxMesa->Depth.Bias != bias ) {
       fxMesa->Depth.Bias = bias;
@@ -460,11 +458,11 @@ static void tdfxUpdateStencil( GLcontext *ctx )
    }
 
    if (fxMesa->haveHwStencil) {
-      if (ctx->Stencil.Enabled) {
+      if (ctx->Stencil._Enabled) {
          fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER;
-         fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0];
-         fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0];
-         fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0];
+         fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0] & 0xff;
+         fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0] & 0xff;
+         fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0] & 0xff;
          fxMesa->Stencil.FailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[0]);
          fxMesa->Stencil.ZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[0]);
          fxMesa->Stencil.ZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[0]);
@@ -475,8 +473,9 @@ static void tdfxUpdateStencil( GLcontext *ctx )
 }
 
 
-static void tdfxDDStencilFunc( GLcontext *ctx, GLenum func,
-                              GLint ref, GLuint mask )
+static void
+tdfxDDStencilFuncSeparate( GLcontext *ctx, GLenum face, GLenum func,
+                           GLint ref, GLuint mask )
 {
    tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
 
@@ -484,7 +483,8 @@ static void tdfxDDStencilFunc( GLcontext *ctx, GLenum func,
    fxMesa->new_state |= TDFX_NEW_STENCIL;
 }
 
-static void tdfxDDStencilMask( GLcontext *ctx, GLuint mask )
+static void
+tdfxDDStencilMaskSeparate( GLcontext *ctx, GLenum face, GLuint mask )
 {
    tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
 
@@ -492,8 +492,9 @@ static void tdfxDDStencilMask( GLcontext *ctx, GLuint mask )
    fxMesa->new_state |= TDFX_NEW_STENCIL;
 }
 
-static void tdfxDDStencilOp( GLcontext *ctx, GLenum sfail,
-                            GLenum zfail, GLenum zpass )
+static void
+tdfxDDStencilOpSeparate( GLcontext *ctx, GLenum face, GLenum sfail,
+                         GLenum zfail, GLenum zpass )
 {
    tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
 
@@ -1030,21 +1031,23 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
 
    FLUSH_BATCH( fxMesa );
 
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->Color._DrawDestMask[0] ) {
-   case DD_FRONT_LEFT_BIT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {
+      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
       fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
       fxMesa->new_state |= TDFX_NEW_RENDER;
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
-   case DD_BACK_LEFT_BIT:
+   case BUFFER_BACK_LEFT:
       fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
       fxMesa->new_state |= TDFX_NEW_RENDER;
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
-   case 0:
+   case -1:
       FX_grColorMaskv( ctx, false4 );
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
@@ -1052,11 +1055,6 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
       break;
    }
-
-   /* We want to update the s/w rast state too so that tdfxDDSetBuffer()
-    * gets called.
-    */
-   _swrast_DrawBuffer(ctx, mode);
 }
 
 
@@ -1236,7 +1234,7 @@ static void tdfxDDInvalidateState( GLcontext *ctx, GLuint new_state )
 {
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
-   _ac_InvalidateState( ctx, new_state );
+   _vbo_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
    TDFX_CONTEXT(ctx)->new_gl_state |= new_state;
 }
@@ -1402,19 +1400,15 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
 
    ctx->Driver.UpdateState             = tdfxDDInvalidateState;
 
-
-   /* State notification callbacks:
-    */
    ctx->Driver.ClearColor              = tdfxDDClearColor;
    ctx->Driver.DrawBuffer              = tdfxDDDrawBuffer;
    ctx->Driver.ReadBuffer              = tdfxDDReadBuffer;
 
-   ctx->Driver.ColorMask               = tdfxDDColorMask;
-
    ctx->Driver.AlphaFunc               = tdfxDDAlphaFunc;
    ctx->Driver.BlendEquationSeparate   = tdfxDDBlendEquationSeparate;
    ctx->Driver.BlendFuncSeparate       = tdfxDDBlendFuncSeparate;
    ctx->Driver.ClearDepth              = tdfxDDClearDepth;
+   ctx->Driver.ColorMask               = tdfxDDColorMask;
    ctx->Driver.CullFace                        = tdfxDDCullFace;
    ctx->Driver.FrontFace               = tdfxDDFrontFace;
    ctx->Driver.DepthFunc               = tdfxDDDepthFunc;
@@ -1430,17 +1424,10 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
    ctx->Driver.ShadeModel              = tdfxDDShadeModel;
 
    if ( fxMesa->haveHwStencil ) {
-      ctx->Driver.StencilFunc          = tdfxDDStencilFunc;
-      ctx->Driver.StencilMask          = tdfxDDStencilMask;
-      ctx->Driver.StencilOp            = tdfxDDStencilOp;
+      ctx->Driver.StencilFuncSeparate  = tdfxDDStencilFuncSeparate;
+      ctx->Driver.StencilMaskSeparate  = tdfxDDStencilMaskSeparate;
+      ctx->Driver.StencilOpSeparate    = tdfxDDStencilOpSeparate;
    }
 
    ctx->Driver.Viewport                        = tdfxDDViewport;
-
-   /* Swrast hooks for imaging extensions:
-    */
-   ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
-   ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
-   ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
-   ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
 }