summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/glide
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/glide
parentd3c145b98a6ef51d1239b8a47f199d245e6f1fd3 (diff)
updated Clear function for new mask bits
Diffstat (limited to 'src/mesa/drivers/glide')
-rw-r--r--src/mesa/drivers/glide/fxdd.c107
1 files changed, 55 insertions, 52 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;
}