summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2000-01-06 09:28:38 +0000
committerBrian Paul <[email protected]>2000-01-06 09:28:38 +0000
commitdd020f13a6d520b46aefd4453dae6b6edcc427f6 (patch)
treec0c782f7fbdf6085dd63679c9cc8b9b7c82be6d4 /src/mesa/drivers
parentd3c145b98a6ef51d1239b8a47f199d245e6f1fd3 (diff)
updated Clear function for new mask bits
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/glide/fxdd.c107
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c16
-rw-r--r--src/mesa/drivers/x11/xmesaP.h10
3 files changed, 77 insertions, 56 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index af73a4d35d3..0605ff4c476 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -172,73 +172,76 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
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;
}
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 5284c8c132b..ceedaf68c1a 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $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
@@ -558,7 +558,16 @@ static GLbitfield clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
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 */
@@ -631,7 +640,8 @@ static GLbitfield clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
}
}
}
- return mask & (~GL_COLOR_BUFFER_BIT);
+ /* have Mesa clear all other buffers */
+ return mask & (~DD_FRONT_LEFT_BIT);
}
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 532e288d584..147bb5f747a 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,4 +1,4 @@
-/* $Id: xmesaP.h,v 1.4 1999/11/25 17:38:12 brianp Exp $ */
+/* $Id: xmesaP.h,v 1.5 2000/01/06 09:28:58 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -65,6 +65,10 @@ typedef struct {
} bgr_t;
+/* Function pointer for clearing color buffers */
+typedef void (*clear_func)( GLcontext *ctx,
+ GLboolean all, GLint x, GLint y,
+ GLint width, GLint height );
/*
@@ -234,6 +238,10 @@ struct xmesa_buffer {
fxMesaContext FXctx;
#endif
+ /* functions for clearing the front and back color buffers */
+ clear_func front_clear_func;
+ clear_func back_clear_func;
+
struct xmesa_buffer *Next; /* Linked list pointer: */
};