fix GL_BACK color material bug
[mesa.git] / src / mesa / drivers / glide / fxdd.c
index bd571d415c3a0b3fd38b94b3554e3032d5ace10e..2705d6bc17dbe4909f3787bda7caf27fe387ff1e 100644 (file)
@@ -180,13 +180,16 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
   const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff);
   GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
 
+  /* we can't clear stencil or accum buffers */
+  mask &= ~(DD_STENCIL_BIT | DD_ACCUM_BIT);
+
   if (MESA_VERBOSE & VERBOSE_DRIVER) {
     fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
             (int) width, (int) height);
   }
 
   if (colorMask != 0xffffffff) {
-    /* do color buffer clears in software */
+    /* do masked color buffer clears in software */
     softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
     mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
   }
@@ -283,7 +286,7 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
 
 /* Set the buffer used for drawing */
 /* XXX support for separate read/draw buffers hasn't been tested */
-static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
+static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode)
 {
   fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
 
@@ -301,6 +304,10 @@ static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
     FX_grRenderBuffer(fxMesa->currentFB);
     return GL_TRUE;
   }
+  else if (mode == GL_NONE) {
+    FX_grColorMask(FXFALSE,FXFALSE);
+    return GL_TRUE;
+  }
   else {
     return GL_FALSE;
   }
@@ -532,7 +539,7 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
   else {
     fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
     GrLfbInfo_t info;
-    GLboolean result;
+    GLboolean result = GL_FALSE;
 
     BEGIN_BOARD_LOCK();
     if (grLfbLock(GR_LFB_READ_ONLY,
@@ -543,8 +550,12 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
                   &info)) {
       const GLint winX = fxMesa->x_offset;
       const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+#ifdef XF86DRI
       const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
-                            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+                          ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+#else
+      const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+#endif
       const GLushort *src = (const GLushort *) info.lfbPtr
                           + (winY - y) * srcStride + (winX + x);
       GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
@@ -630,7 +641,6 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y,
       grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
     }
     END_BOARD_LOCK();
-
     return result;
   }
 }
@@ -690,7 +700,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
           }
         }
         /* now make the GL_RENDERER string */
-        sprintf(buffer, "Mesa DRI %s 20000329", hardware);
+        sprintf(buffer, "Mesa DRI %s 20000510", hardware);
         return buffer;
       }
     case GL_VENDOR:
@@ -890,7 +900,6 @@ void fxDDInitExtensions( GLcontext *ctx )
    gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
    gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
    gl_extensions_disable(ctx, "GL_EXT_blend_color");
-   gl_extensions_disable(ctx, "GL_EXT_paletted_texture");
 
    gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0);
    
@@ -937,7 +946,7 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
   if (!ctx->Hint.AllowDrawMem)
      return GL_TRUE;           /* you'll take it and like it */
 
-  if((ctx->RasterMask & STENCIL_BIT) ||
+  if((ctx->RasterMask & (STENCIL_BIT | MULTI_DRAW_BIT)) ||
      ((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) ||
      ((ctx->Color.ColorLogicOpEnabled) && (ctx->Color.LogicOp!=GL_COPY)) ||
      (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) ||
@@ -960,8 +969,14 @@ static GLboolean fxIsInHardware(GLcontext *ctx)
     }
 
     if (ctx->Texture.ReallyEnabled & TEXTURE0_2D) {
-      if (ctx->Texture.Unit[0].EnvMode == GL_BLEND)
+      if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+         (ctx->Texture.ReallyEnabled & TEXTURE1_2D ||
+          ctx->Texture.Unit[0].EnvColor[0] != 0 ||
+          ctx->Texture.Unit[0].EnvColor[1] != 0 ||
+          ctx->Texture.Unit[0].EnvColor[2] != 0 ||
+          ctx->Texture.Unit[0].EnvColor[3] != 1)) {
         return GL_FALSE;
+      }
       if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0)
         return GL_FALSE;
     }