Remove CVS keywords.
[mesa.git] / src / mesa / drivers / dri / ffb / ffb_state.c
index ac753b922a13ed0df07c8ed190a0f20741e40c81..ee0fe4e0dbe73ed1362c0b6e71a030d676cb0994 100644 (file)
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v 1.5 2002/10/30 12:51:27 alanh Exp $
+/* 
  *
  * GLX Hardware Device Driver for Sun Creator/Creator3D
  * Copyright (C) 2000, 2001 David S. Miller
  *    David S. Miller <davem@redhat.com>
  */
 
-#include "mtypes.h"
-#include "colormac.h"
-#include "mm.h"
+#include "main/mtypes.h"
+#include "main/colormac.h"
+#include "main/mm.h"
+#include "main/extensions.h"
+#include "main/enums.h"
+
+#include "vbo/vbo.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+
 #include "ffb_dd.h"
 #include "ffb_span.h"
 #include "ffb_depth.h"
 #include "ffb_tris.h"
 #include "ffb_state.h"
 #include "ffb_lock.h"
-#include "extensions.h"
-#include "enums.h"
-
-#include "swrast/swrast.h"
-#include "array_cache/acache.h"
-#include "tnl/tnl.h"
-#include "swrast_setup/swrast_setup.h"
-
-#include "tnl/t_pipeline.h"
 
 #undef STATE_TRACE
 
@@ -93,23 +93,31 @@ static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
        }
 }
 
-static void ffbDDBlendEquation(GLcontext *ctx, GLenum mode)
+static void ffbDDBlendEquationSeparate(GLcontext *ctx, 
+                                      GLenum modeRGB, GLenum modeA)
 {
 
 #ifdef STATE_TRACE
-       fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", _mesa_lookup_enum_by_nr(mode));
+       fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", 
+               _mesa_lookup_enum_by_nr(modeRGB));
 #endif
-       FALLBACK( ctx, (mode != GL_FUNC_ADD_EXT), FFB_BADATTR_BLENDEQN);
+       assert( modeRGB == modeA );
+       FALLBACK( ctx, (modeRGB != GL_FUNC_ADD), FFB_BADATTR_BLENDEQN);
 }
 
-static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+                                  GLenum dfactorRGB, GLenum sfactorA,
+                                  GLenum dfactorA)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        unsigned int blendc = 1 << 4;
 
 #ifdef STATE_TRACE
-       fprintf(stderr, "ffbDDBlendFunc: sfactor(%s) dfactor(%s)\n",
-               _mesa_lookup_enum_by_nr(sfactor), _mesa_lookup_enum_by_nr(dfactor));
+       fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n",
+               _mesa_lookup_enum_by_nr(sfactorRGB),
+               _mesa_lookup_enum_by_nr(dfactorRGB),
+               _mesa_lookup_enum_by_nr(sfactorA),
+               _mesa_lookup_enum_by_nr(dfactorA));
 #endif
        switch (ctx->Color.BlendSrcRGB) {
        case GL_ZERO:
@@ -179,21 +187,6 @@ static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
        }
 }
 
-static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
-                                  GLenum dfactorRGB, GLenum sfactorA,
-                                  GLenum dfactorA)
-{
-#ifdef STATE_TRACE
-       fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n",
-               _mesa_lookup_enum_by_nr(sfactorRGB),
-               _mesa_lookup_enum_by_nr(dfactorRGB),
-               _mesa_lookup_enum_by_nr(sfactorA),
-               _mesa_lookup_enum_by_nr(dfactorA));
-#endif
-
-       ffbDDBlendFunc(ctx, sfactorRGB, dfactorRGB);
-}
-
 static void ffbDDDepthFunc(GLcontext *ctx, GLenum func)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
@@ -272,7 +265,9 @@ static void ffbDDDepthMask(GLcontext *ctx, GLboolean flag)
        }
 }
 
-static void ffbDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
+static void
+ffbDDStencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
+                         GLint ref, GLuint mask)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        unsigned int stencil, stencilctl, consty;
@@ -316,7 +311,8 @@ static void ffbDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask
        }
 }
 
-static void ffbDDStencilMask(GLcontext *ctx, GLuint mask)
+static void
+ffbDDStencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
 
@@ -327,7 +323,9 @@ static void ffbDDStencilMask(GLcontext *ctx, GLuint mask)
        }
 }
 
-static void ffbDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass)
+static void
+ffbDDStencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
+                       GLenum zfail, GLenum zpass)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        unsigned int stencilctl;
@@ -476,21 +474,21 @@ static void ffbDDDrawBuffer(GLcontext *ctx, GLenum buffer)
 #endif
        fbc &= ~(FFB_FBC_WB_AB | FFB_FBC_RB_MASK);
        switch (buffer) {
-       case FRONT_LEFT_BIT:
+       case GL_FRONT:
                if (fmesa->back_buffer == 0)
                        fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
                else
                        fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
                break;
 
-       case BACK_LEFT_BIT:
+       case GL_BACK:
                if (fmesa->back_buffer == 0)
                        fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
                else
                        fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
                break;
 
-       case BACK_LEFT_BIT | FRONT_LEFT_BIT:
+       case GL_FRONT_AND_BACK:
                fbc |= FFB_FBC_WB_AB;
                break;
 
@@ -514,6 +512,13 @@ static void ffbDDReadBuffer(GLcontext *ctx, GLenum buffer)
 /*
  * Specifies buffer for sw fallbacks (spans)
  */
+#if 000
+/* XXX
+ * This function is obsolete.  It's not clear how this really effected
+ * span reading/writing above.  The span functions should use the
+ * incoming driRenderbuffer (gl_renderbuffer) pointer to determine how
+ * to read from the specified bufer.
+ */
 static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                           GLuint bufferBit)
 {
@@ -526,14 +531,14 @@ static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
 #endif
        fbc &= ~(FFB_FBC_RB_MASK);
        switch (bufferBit) {
-       case FRONT_LEFT_BIT:
+       case BUFFER_BIT_FRONT_LEFT:
                if (fmesa->back_buffer == 0)
                        fbc |= FFB_FBC_RB_B;
                else
                        fbc |= FFB_FBC_RB_A;
                break;
 
-       case BACK_LEFT_BIT:
+       case BUFFER_BIT_BACK_LEFT:
                if (fmesa->back_buffer == 0)
                        fbc |= FFB_FBC_RB_A;
                else
@@ -541,6 +546,7 @@ static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                break;
 
        default:
+               _mesa_problem(ctx, "Unexpected buffer in ffbDDSetBuffer()");
                return;
        };
 
@@ -549,6 +555,8 @@ static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
                FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
        }
 }
+#endif
+
 
 static void ffbDDClearColor(GLcontext *ctx, const GLfloat color[4])
 {
@@ -595,6 +603,8 @@ static void ffbDDColorMask(GLcontext *ctx,
                new_pmask |= 0x0000ff00;
        if (b)
                new_pmask |= 0x00ff0000;
+       if (a)
+               new_pmask |= 0xff000000;
 
        if (fmesa->pmask != new_pmask) {
                fmesa->pmask = new_pmask;
@@ -817,7 +827,7 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
                if (fmesa->ppc != tmp) {
                        fmesa->ppc = tmp;
                        FFB_MAKE_DIRTY(fmesa, FFB_STATE_PPC, 1);
-                       ffbDDBlendFunc(ctx, 0, 0);
+                       ffbDDBlendFuncSeparate(ctx, 0, 0, 0, 0 );
                }
                break;
 
@@ -852,12 +862,13 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
 
                tmp = fmesa->fbc & ~FFB_FBC_YE_MASK;
                if (state) {
-                       ffbDDStencilFunc(ctx,
+                       ffbDDStencilFuncSeparate(ctx, GL_FRONT,
                                         ctx->Stencil.Function[0],
                                         ctx->Stencil.Ref[0],
                                         ctx->Stencil.ValueMask[0]);
-                       ffbDDStencilMask(ctx, ctx->Stencil.WriteMask[0]);
-                       ffbDDStencilOp(ctx,
+                       ffbDDStencilMaskSeparate(ctx, GL_FRONT,
+                                                 ctx->Stencil.WriteMask[0]);
+                       ffbDDStencilOpSeparate(ctx, GL_FRONT,
                                       ctx->Stencil.FailFunc[0],
                                       ctx->Stencil.ZFailFunc[0],
                                       ctx->Stencil.ZPassFunc[0]);
@@ -1023,7 +1034,7 @@ static void ffbDDUpdateState(GLcontext *ctx, GLuint newstate)
 
        _swrast_InvalidateState( ctx, newstate );
        _swsetup_InvalidateState( ctx, newstate );
-       _ac_InvalidateState( ctx, newstate );
+       _vbo_InvalidateState( ctx, newstate );
        _tnl_InvalidateState( ctx, newstate );
 
        if (newstate & _NEW_TEXTURE)
@@ -1062,8 +1073,7 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
 
        ctx->Driver.Enable = ffbDDEnable;
        ctx->Driver.AlphaFunc = ffbDDAlphaFunc;
-       ctx->Driver.BlendEquation = ffbDDBlendEquation;
-       ctx->Driver.BlendFunc = ffbDDBlendFunc;
+       ctx->Driver.BlendEquationSeparate = ffbDDBlendEquationSeparate;
        ctx->Driver.BlendFuncSeparate = ffbDDBlendFuncSeparate;
        ctx->Driver.DepthFunc = ffbDDDepthFunc;
        ctx->Driver.DepthMask = ffbDDDepthMask;
@@ -1077,9 +1087,9 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
        ctx->Driver.DepthRange = ffbDDDepthRange;
 
        if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
-               ctx->Driver.StencilFunc = ffbDDStencilFunc;
-               ctx->Driver.StencilMask = ffbDDStencilMask;
-               ctx->Driver.StencilOp = ffbDDStencilOp;
+               ctx->Driver.StencilFuncSeparate = ffbDDStencilFuncSeparate;
+               ctx->Driver.StencilMaskSeparate = ffbDDStencilMaskSeparate;
+               ctx->Driver.StencilOpSeparate = ffbDDStencilOpSeparate;
        }
 
        ctx->Driver.DrawBuffer = ffbDDDrawBuffer;
@@ -1093,14 +1103,6 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
        ctx->Driver.ClearIndex = 0;
        ctx->Driver.IndexMask = 0;
         */
-
-       {
-               struct swrast_device_driver *swdd = 
-                       _swrast_GetDeviceDriverReference(ctx);
-               swdd->SetBuffer = ffbDDSetBuffer;
-       }
-   
-
 }
 
 void ffbDDInitContextHwState(GLcontext *ctx)