special case blend optmizations (Jeremy Fitzhardinge)

This commit is contained in:
Brian Paul 2001-12-13 16:14:26 +00:00
parent c3209d45ad
commit 59235bd5da
1 changed files with 54 additions and 6 deletions

View File

@ -1,8 +1,8 @@
/* $Id: s_blend.c,v 1.9 2001/07/16 20:45:55 brianp Exp $ */
/* $Id: s_blend.c,v 1.10 2001/12/13 16:14:26 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
* Version: 4.1
*
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
*
@ -46,6 +46,48 @@
#endif
/*
* Special case for glBlendFunc(GL_ZERO, GL_ONE)
*/
static void _BLENDAPI
blend_noop( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
int i;
ASSERT(ctx->Color.BlendEquation==GL_FUNC_ADD_EXT);
ASSERT(ctx->Color.BlendSrcRGB==GL_ZERO);
ASSERT(ctx->Color.BlendDstRGB==GL_ONE);
(void) ctx;
for (i = 0; i < n; i++) {
if (mask[i]) {
rgba[i][RCOMP] = dest[i][RCOMP];
rgba[i][GCOMP] = dest[i][GCOMP];
rgba[i][BCOMP] = dest[i][BCOMP];
rgba[i][ACOMP] = dest[i][ACOMP];
}
}
}
/*
* Special case for glBlendFunc(GL_ONE, GL_ZERO)
*/
static void _BLENDAPI
blend_replace( GLcontext *ctx, GLuint n, const GLubyte mask[],
GLchan rgba[][4], CONST GLchan dest[][4] )
{
ASSERT(ctx->Color.BlendEquation==GL_FUNC_ADD_EXT);
ASSERT(ctx->Color.BlendSrcRGB==GL_ONE);
ASSERT(ctx->Color.BlendDstRGB==GL_ZERO);
(void) ctx;
(void) n;
(void) mask;
(void) rgba;
(void) dest;
}
/*
* Common transparency blending mode.
*/
@ -611,6 +653,12 @@ void _swrast_choose_blend_func( GLcontext *ctx )
else if (eq==GL_MAX_EXT) {
SWRAST_CONTEXT(ctx)->BlendFunc = blend_max;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB == GL_ZERO && dstRGB == GL_ONE) {
SWRAST_CONTEXT(ctx)->BlendFunc = blend_noop;
}
else if (eq==GL_FUNC_ADD_EXT && srcRGB == GL_ONE && dstRGB == GL_ZERO) {
SWRAST_CONTEXT(ctx)->BlendFunc = blend_replace;
}
else {
SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
}