From 39df62551c782fb571833e26d35c53cdcdb6ab4b Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 2 Aug 2017 20:47:49 +0200 Subject: [PATCH] mesa: only check errors when the state change in glBlendEquationSeparateiARB() When this GL call is a no-op, it should be a little faster. Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/blend.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 9ca04c1db29..af378f784da 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -694,14 +694,32 @@ _mesa_BlendEquationSeparate(GLenum modeRGB, GLenum modeA) } -static void +static ALWAYS_INLINE void blend_equation_separatei(struct gl_context *ctx, GLuint buf, GLenum modeRGB, - GLenum modeA) + GLenum modeA, bool no_error) { if (ctx->Color.Blend[buf].EquationRGB == modeRGB && ctx->Color.Blend[buf].EquationA == modeA) return; /* no change */ + if (!no_error) { + /* Only allow simple blending equations. + * The GL_KHR_blend_equation_advanced spec says: + * + * "NOTE: These enums are not accepted by the or + * parameters of BlendEquationSeparate or BlendEquationSeparatei." + */ + if (!legal_simple_blend_equation(ctx, modeRGB)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeRGB)"); + return; + } + + if (!legal_simple_blend_equation(ctx, modeA)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeA)"); + return; + } + } + _mesa_flush_vertices_for_blend_state(ctx); ctx->Color.Blend[buf].EquationRGB = modeRGB; ctx->Color.Blend[buf].EquationA = modeA; @@ -715,7 +733,7 @@ _mesa_BlendEquationSeparateiARB_no_error(GLuint buf, GLenum modeRGB, GLenum modeA) { GET_CURRENT_CONTEXT(ctx); - blend_equation_separatei(ctx, buf, modeRGB, modeA); + blend_equation_separatei(ctx, buf, modeRGB, modeA, true); } @@ -738,23 +756,7 @@ _mesa_BlendEquationSeparateiARB(GLuint buf, GLenum modeRGB, GLenum modeA) return; } - /* Only allow simple blending equations. - * The GL_KHR_blend_equation_advanced spec says: - * - * "NOTE: These enums are not accepted by the or - * parameters of BlendEquationSeparate or BlendEquationSeparatei." - */ - if (!legal_simple_blend_equation(ctx, modeRGB)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeRGB)"); - return; - } - - if (!legal_simple_blend_equation(ctx, modeA)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeA)"); - return; - } - - blend_equation_separatei(ctx, buf, modeRGB, modeA); + blend_equation_separatei(ctx, buf, modeRGB, modeA, false); } -- 2.30.2