Use SecondaryColorPtr, not ColorPtr[1] (the latter is NULL).
[mesa.git] / src / mesa / drivers / dri / sis / sis_state.c
index 8ff067f56d74922c0ecf602de0ffaf23b24b9187..b269d694b0f4ae43f726e4e53dc0dbd66e76ccea 100644 (file)
@@ -39,6 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "sis_tex.h"
 
 #include "context.h"
+#include "buffers.h"
 #include "enums.h"
 #include "colormac.h"
 #include "swrast/swrast.h"
@@ -98,18 +99,18 @@ sisDDAlphaFunc( GLcontext * ctx, GLenum func, GLfloat ref )
 }
 
 static void
-sisDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
+sisDDBlendFuncSeparate( GLcontext *ctx, 
+                       GLenum sfactorRGB, GLenum dfactorRGB,
+                       GLenum sfactorA,   GLenum dfactorA )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
 
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
 
-   /* TODO: in ICD, if no blend, it will reset these value */
-   /* blending enable */
-   current->hwDstSrcBlend = 0x10000;   /* Default destination alpha */
+   current->hwDstSrcBlend = 0;
 
-   switch (dfactor)
+   switch (dfactorRGB)
    {
    case GL_ZERO:
       current->hwDstSrcBlend |= SiS_D_ZERO;
@@ -129,15 +130,24 @@ sisDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
    case GL_ONE_MINUS_SRC_ALPHA:
       current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA;
       break;
+   case GL_DST_COLOR:
+      current->hwDstSrcBlend |= SiS_D_DST_COLOR;
+      break;
+   case GL_ONE_MINUS_DST_COLOR:
+      current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_COLOR;
+      break;
    case GL_DST_ALPHA:
       current->hwDstSrcBlend |= SiS_D_DST_ALPHA;
       break;
    case GL_ONE_MINUS_DST_ALPHA:
       current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA;
       break;
+   default:
+      fprintf(stderr, "Unknown dst blend function 0x%x\n", dfactorRGB);
+      break;
    }
 
-   switch (sfactor)
+   switch (sfactorRGB)
    {
    case GL_ZERO:
       current->hwDstSrcBlend |= SiS_S_ZERO;
@@ -145,27 +155,36 @@ sisDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
    case GL_ONE:
       current->hwDstSrcBlend |= SiS_S_ONE;
       break;
+   case GL_SRC_COLOR:
+      current->hwDstSrcBlend |= SiS_S_SRC_COLOR;
+      break;
+   case GL_ONE_MINUS_SRC_COLOR:
+      current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_COLOR;
+      break;
    case GL_SRC_ALPHA:
       current->hwDstSrcBlend |= SiS_S_SRC_ALPHA;
       break;
    case GL_ONE_MINUS_SRC_ALPHA:
       current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA;
       break;
-   case GL_DST_ALPHA:
-      current->hwDstSrcBlend |= SiS_S_DST_ALPHA;
-      break;
-   case GL_ONE_MINUS_DST_ALPHA:
-      current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA;
-      break;
    case GL_DST_COLOR:
       current->hwDstSrcBlend |= SiS_S_DST_COLOR;
       break;
    case GL_ONE_MINUS_DST_COLOR:
       current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR;
       break;
+   case GL_DST_ALPHA:
+      current->hwDstSrcBlend |= SiS_S_DST_ALPHA;
+      break;
+   case GL_ONE_MINUS_DST_ALPHA:
+      current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA;
+      break;
    case GL_SRC_ALPHA_SATURATE:
       current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE;
       break;
+   default:
+      fprintf(stderr, "Unknown src blend function 0x%x\n", sfactorRGB);
+      break;
    }
 
    if (current->hwDstSrcBlend != prev->hwDstSrcBlend) {
@@ -418,6 +437,8 @@ static void sisDDViewport( GLcontext *ctx,
                           GLint x, GLint y,
                           GLsizei width, GLsizei height )
 {
+   /* update size of Mesa/software ancillary buffers */
+   _mesa_ResizeBuffersMESA();
    sisCalcViewport( ctx );
 }
 
@@ -439,9 +460,6 @@ sisDDLogicOpCode( GLcontext *ctx, GLenum opcode )
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
 
-   if (!ctx->Color.ColorLogicOpEnabled)
-      return;
-
    current->hwDstSet &= ~MASK_ROP2;
    switch (opcode)
    {
@@ -511,9 +529,9 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
    /*
     * _DrawDestMask is easier to cope with than <mode>.
     */
-   switch ( ctx->Color._DrawDestMask ) {
-   case FRONT_LEFT_BIT:
-   case BACK_LEFT_BIT:
+   switch ( ctx->Color._DrawDestMask[0] ) {
+   case DD_FRONT_LEFT_BIT:
+   case DD_BACK_LEFT_BIT:
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
    default:
@@ -627,51 +645,6 @@ sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state )
     }
 }
 
-/* =============================================================
- * Pixel functions
- */
-
-static void
-sisDDDrawPixels( GLcontext *ctx,
-                GLint x, GLint y, GLsizei width, GLsizei height,
-                GLenum format, GLenum type,
-                const struct gl_pixelstore_attrib *unpack,
-                const GLvoid *pixels )
-{
-   sisContextPtr smesa = SIS_CONTEXT(ctx);
-
-   LOCK_HARDWARE();
-   _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels );
-   UNLOCK_HARDWARE();
-}
-
-static void
-sisDDReadPixels( GLcontext *ctx,
-                GLint x, GLint y, GLsizei width, GLsizei height,
-                GLenum format, GLenum type,
-                const struct gl_pixelstore_attrib *pack,
-                GLvoid *pixels )
-{
-   sisContextPtr smesa = SIS_CONTEXT(ctx);
-
-   LOCK_HARDWARE();
-   _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, 
-                      pixels);
-   UNLOCK_HARDWARE();
-}
-
-static void
-sisDDBitmap( GLcontext *ctx, GLint px, GLint py,
-            GLsizei width, GLsizei height,
-            const struct gl_pixelstore_attrib *unpack,
-            const GLubyte *bitmap )
-{
-   sisContextPtr smesa = SIS_CONTEXT(ctx);
-
-   LOCK_HARDWARE();
-   _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap );
-   UNLOCK_HARDWARE();
-}
 
 /* =============================================================
  * State initialization, management
@@ -685,9 +658,6 @@ sisUpdateHWState( GLcontext *ctx )
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
 
-   if (smesa->NewGLState & _NEW_TEXTURE)
-      sisUpdateTextureState( ctx );
-
    /* enable setting 1 */
    if (current->hwCapEnable ^ prev->hwCapEnable) {
       prev->hwCapEnable = current->hwCapEnable;
@@ -820,7 +790,7 @@ void sisDDInitState( sisContextPtr smesa )
 
    smesa->clearColorPattern = 0;
 
-   smesa->AGPParseSet = MASK_PsTexture1FromB;
+   smesa->AGPParseSet = MASK_PsTexture1FromB | MASK_PsBumpTextureFromC;
    smesa->dwPrimitiveSet = OP_3D_Texture1FromB | OP_3D_TextureBumpFromC;
 
    sisUpdateZStencilPattern( smesa, 1.0, 0 );
@@ -846,15 +816,13 @@ void sisDDInitStateFuncs( GLcontext *ctx )
    ctx->Driver.ClearStencil     = sisDDClearStencil;
 
    ctx->Driver.AlphaFunc        = sisDDAlphaFunc;
-   ctx->Driver.Bitmap           = sisDDBitmap;
-   ctx->Driver.BlendFunc        = sisDDBlendFunc;
+   ctx->Driver.BlendFuncSeparate = sisDDBlendFuncSeparate;
    ctx->Driver.ColorMask        = sisDDColorMask;
    ctx->Driver.CullFace                 = sisDDCullFace;
    ctx->Driver.DepthMask        = sisDDDepthMask;
    ctx->Driver.DepthFunc        = sisDDDepthFunc;
    ctx->Driver.DepthRange       = sisDDDepthRange;
    ctx->Driver.DrawBuffer       = sisDDDrawBuffer;
-   ctx->Driver.DrawPixels       = sisDDDrawPixels;
    ctx->Driver.Enable           = sisDDEnable;
    ctx->Driver.FrontFace        = sisDDFrontFace;
    ctx->Driver.Fogfv            = sisDDFogfv;
@@ -864,16 +832,17 @@ void sisDDInitStateFuncs( GLcontext *ctx )
    ctx->Driver.PolygonMode      = NULL;
    ctx->Driver.PolygonStipple   = NULL;
    ctx->Driver.ReadBuffer       = NULL;
-   ctx->Driver.ReadPixels       = sisDDReadPixels;
    ctx->Driver.RenderMode       = NULL;
    ctx->Driver.Scissor          = sisDDScissor;
    ctx->Driver.ShadeModel       = sisDDShadeModel;
    ctx->Driver.Viewport                 = sisDDViewport;
 
-  /* Pixel path fallbacks.
-   */
-  ctx->Driver.Accum             = _swrast_Accum;
-  ctx->Driver.CopyPixels        = _swrast_CopyPixels;
+   /* Pixel path fallbacks. */
+   ctx->Driver.Accum            = _swrast_Accum;
+   ctx->Driver.Bitmap           = _swrast_Bitmap;
+   ctx->Driver.CopyPixels       = _swrast_CopyPixels;
+   ctx->Driver.DrawPixels       = _swrast_DrawPixels;
+   ctx->Driver.ReadPixels       = _swrast_ReadPixels;
 
   /* Swrast hooks for imaging extensions:
    */