diff options
author | Brian Paul <[email protected]> | 2015-10-14 09:41:11 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-10-15 07:21:07 -0600 |
commit | 2dfedf105d07e9a1f65f9bc76369cb33edf59cc9 (patch) | |
tree | 354f22c94915cfa3a0c258966665f3f58ffb6d26 | |
parent | 6fd29e6c31e14e7b0f3c530798a1fc983eee17af (diff) |
mesa: optimize no-change check in _mesa_BlendEquation()
Same story as preceeding change to _mesa_BlendFuncSeparate().
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/mesa/main/blend.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 98d28581d26..01b69194814 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -345,33 +345,44 @@ void GLAPIENTRY _mesa_BlendEquation( GLenum mode ) { GLuint buf, numBuffers; - GLboolean changed; + bool changed = false; GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glBlendEquation(%s)\n", _mesa_enum_to_string(mode)); - if (!legal_blend_equation(ctx, mode)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation"); - 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 != mode || - ctx->Color.Blend[buf].EquationA != mode) { - changed = GL_TRUE; - break; + if (ctx->Color._BlendEquationPerBuffer) { + /* Check all per-buffer states */ + for (buf = 0; buf < numBuffers; buf++) { + if (ctx->Color.Blend[buf].EquationRGB != mode || + ctx->Color.Blend[buf].EquationA != mode) { + changed = true; + break; + } + } + } + else { + /* only need to check 0th per-buffer state */ + if (ctx->Color.Blend[0].EquationRGB != mode || + ctx->Color.Blend[0].EquationA != mode) { + changed = true; } } + if (!changed) return; + if (!legal_blend_equation(ctx, mode)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation"); + return; + } + FLUSH_VERTICES(ctx, _NEW_COLOR); + for (buf = 0; buf < numBuffers; buf++) { ctx->Color.Blend[buf].EquationRGB = mode; ctx->Color.Blend[buf].EquationA = mode; |