diff options
author | Brian Paul <[email protected]> | 2001-12-13 16:14:17 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2001-12-13 16:14:17 +0000 |
commit | 9012185ae8cf8e12d858e9161a5e41d3542e24c8 (patch) | |
tree | a68cb3b34b590bf4acd80525e31f1d5144287854 /src/mesa | |
parent | 2edf8519322ccc476d0ed8fb98df1c1ff996e541 (diff) |
special case blend optmizations (Jeremy Fitzhardinge)
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/swrast/s_blend.c | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index 02f40730179..fbd244a7f40 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -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.9.2.1 2001/12/13 16:14:17 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.0.1 * * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * @@ -25,7 +25,6 @@ */ - #include "glheader.h" #include "context.h" #include "macros.h" @@ -47,6 +46,48 @@ /* + * 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. */ static void _BLENDAPI @@ -341,7 +382,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], default: /* this should never happen */ _mesa_problem(ctx, "Bad blend source RGB factor in do_blend"); - return; + return; } /* Source Alpha factor */ @@ -611,6 +652,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; } |