GLint x, GLint y, GLint width, GLint height )
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLbitfield newmask;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT);
+ GLbitfield newMask = mask & ~(DD_STENCIL_BIT | DD_ACCUM_BIT);
+
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n",x,y,width,height);
}
- switch(mask & (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)) {
- case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT):
- /* clear color and depth buffer */
+ if (mask == (DD_BACK_LEFT_BIT | DD_DEPTH_BIT)
+ && colorMask == 0xffffffff) {
+ /* common case: clear back color buffer and depth buffer */
+ FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
+ (FxU16)(ctx->Depth.Clear*0xffff));
+ return 0;
+ }
- if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
- (FxU16)(ctx->Depth.Clear*0xffff));
- }
- if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
+ /* depth masking */
+ if (newMask & DD_DEPTH_BIT) {
+ FX_grDepthMask(FXTRUE);
+ CLEAR_BITS(newMask, DD_DEPTH_BIT);
+ }
+ else {
+ FX_grDepthMask(FXFALSE);
+ }
+
+ if (colorMask != 0xffffffff) {
+ /* do masked color clear in software */
+ softwareMask |= (newMask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
+ CLEAR_BITS(newMask, (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
+ }
+
+ if (newMask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+ if (newMask & DD_FRONT_LEFT_BIT) {
FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
- (FxU16)(ctx->Depth.Clear*0xffff));
+ (FxU16)(ctx->Depth.Clear*0xffff));
}
- newmask=mask & (~(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT));
- break;
- case (GL_COLOR_BUFFER_BIT):
- /* clear color buffer */
-
- if(ctx->Color.ColorMask) {
- FX_grDepthMask(FXFALSE);
-
- if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {
- FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
- }
- if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) {
- FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0);
- }
-
- if(ctx->Depth.Mask) {
- FX_grDepthMask(FXTRUE);
- }
+ if (newMask & DD_BACK_LEFT_BIT) {
+ FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
+ (FxU16)(ctx->Depth.Clear*0xffff));
}
- newmask=mask & (~(GL_COLOR_BUFFER_BIT));
- break;
- case (GL_DEPTH_BUFFER_BIT):
- /* clear depth buffer */
-
- if(ctx->Depth.Mask) {
- FX_grColorMask(FXFALSE,FXFALSE);
- FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
- (FxU16)(ctx->Depth.Clear*0xffff));
+ CLEAR_BITS(newMask, (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
+ }
+ else if (mask & DD_DEPTH_BIT) {
+ /* clear depth but not color */
+ FX_grColorMask(FXFALSE,FXFALSE);
+ FX_grBufferClear(fxMesa->clearC, fxMesa->clearA,
+ (FxU16)(ctx->Depth.Clear*0xffff));
+ FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
+ ctx->Color.ColorMask[GCOMP] ||
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
+ }
- FX_grColorMask(ctx->Color.ColorMask[RCOMP] ||
- ctx->Color.ColorMask[GCOMP] ||
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer);
+ /* Restore depth mask state */
+ if (mask & DD_DEPTH_BIT) {
+ if (ctx->Depth.Mask) {
+ FX_grDepthMask(FXTRUE);
+ }
+ else {
+ FX_grDepthMask(FXFALSE);
}
-
- newmask=mask & (~(GL_DEPTH_BUFFER_BIT));
- break;
- default:
- newmask=mask;
- break;
}
-
- return newmask;
+
+ return newMask | softwareMask;
}
-/* $Id: osmesa.c,v 1.6 1999/12/17 12:23:25 brianp Exp $ */
+/* $Id: osmesa.c,v 1.7 2000/01/06 09:28:38 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLint x, GLint y, GLint width, GLint height )
{
OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx;
- if (mask & GL_COLOR_BUFFER_BIT) {
+ const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+
+ /* we can't handle color or index masking */
+ if (*colorMask != 0xffffffff || ctx->Color.IndexMask != 0xffffffff)
+ return mask;
+
+ /* sanity check - we only have a front-left buffer */
+ ASSERT((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT)) == 0);
+
+ if (mask & DD_FRONT_LEFT_BIT) {
if (osmesa->format==OSMESA_COLOR_INDEX) {
if (all) {
/* Clear whole CI buffer */
}
}
}
- return mask & (~GL_COLOR_BUFFER_BIT);
+ /* have Mesa clear all other buffers */
+ return mask & (~DD_FRONT_LEFT_BIT);
}