diff options
author | Brian Paul <[email protected]> | 2015-10-14 09:45:36 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-10-15 07:21:07 -0600 |
commit | 34de3c4c1635a42c884da3321fc35ef07be34a6e (patch) | |
tree | a21eae19ee73955bf39c60307ade060c8c51c4b6 /src/mesa/main | |
parent | 2dfedf105d07e9a1f65f9bc76369cb33edf59cc9 (diff) |
mesa: optimize no-change check in _mesa_BlendEquationSeparate()
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/blend.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 01b69194814..14742d0bb6a 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -432,7 +432,7 @@ void GLAPIENTRY _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) { GLuint buf, numBuffers; - GLboolean changed; + bool changed = false; GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) @@ -440,6 +440,30 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) _mesa_enum_to_string(modeRGB), _mesa_enum_to_string(modeA)); + numBuffers = ctx->Extensions.ARB_draw_buffers_blend + ? ctx->Const.MaxDrawBuffers : 1; + + if (ctx->Color._BlendEquationPerBuffer) { + /* Check all per-buffer states */ + for (buf = 0; buf < numBuffers; buf++) { + if (ctx->Color.Blend[buf].EquationRGB != modeRGB || + ctx->Color.Blend[buf].EquationA != modeA) { + changed = true; + break; + } + } + } + else { + /* only need to check 0th per-buffer state */ + if (ctx->Color.Blend[0].EquationRGB != modeRGB || + ctx->Color.Blend[0].EquationA != modeA) { + changed = true; + } + } + + if (!changed) + return; + if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) { _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendEquationSeparateEXT not supported by driver"); @@ -456,21 +480,8 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) return; } - numBuffers = ctx->Extensions.ARB_draw_buffers_blend - ? ctx->Const.MaxDrawBuffers : 1; - - changed = GL_FALSE; - for (buf = 0; buf < numBuffers; buf++) { - if (ctx->Color.Blend[buf].EquationRGB != modeRGB || - ctx->Color.Blend[buf].EquationA != modeA) { - changed = GL_TRUE; - break; - } - } - if (!changed) - return; - FLUSH_VERTICES(ctx, _NEW_COLOR); + for (buf = 0; buf < numBuffers; buf++) { ctx->Color.Blend[buf].EquationRGB = modeRGB; ctx->Color.Blend[buf].EquationA = modeA; |