From 4141fab9ed41705a2bfba731906b9a23c4676944 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 19 Jul 2017 09:51:37 +0200 Subject: [PATCH] mesa: add blend_equation_separate() helper Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/blend.c | 67 +++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 8fb2d692a34..2c13f190049 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -605,19 +605,14 @@ _mesa_BlendEquationiARB(GLuint buf, GLenum mode) } -void GLAPIENTRY -_mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) +static void +blend_equation_separate(struct gl_context *ctx, GLenum modeRGB, GLenum modeA, + bool no_error) { - GET_CURRENT_CONTEXT(ctx); const unsigned numBuffers = num_buffers(ctx); unsigned buf; bool changed = false; - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glBlendEquationSeparateEXT(%s %s)\n", - _mesa_enum_to_string(modeRGB), - _mesa_enum_to_string(modeA)); - if (ctx->Color._BlendEquationPerBuffer) { /* Check all per-buffer states */ for (buf = 0; buf < numBuffers; buf++) { @@ -627,8 +622,7 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) break; } } - } - else { + } else { /* only need to check 0th per-buffer state */ if (ctx->Color.Blend[0].EquationRGB != modeRGB || ctx->Color.Blend[0].EquationA != modeA) { @@ -639,26 +633,29 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) if (!changed) return; - if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBlendEquationSeparateEXT not supported by driver"); - return; - } + if (!no_error) { + if ((modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBlendEquationSeparateEXT not supported by driver"); + 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, "glBlendEquationSeparateEXT(modeRGB)"); - 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, + "glBlendEquationSeparateEXT(modeRGB)"); + return; + } - if (!legal_simple_blend_equation(ctx, modeA)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)"); - return; + if (!legal_simple_blend_equation(ctx, modeA)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)"); + return; + } } _mesa_flush_vertices_for_blend_state(ctx); @@ -675,6 +672,20 @@ _mesa_BlendEquationSeparate( GLenum modeRGB, GLenum modeA ) } +void GLAPIENTRY +_mesa_BlendEquationSeparate(GLenum modeRGB, GLenum modeA) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glBlendEquationSeparateEXT(%s %s)\n", + _mesa_enum_to_string(modeRGB), + _mesa_enum_to_string(modeA)); + + blend_equation_separate(ctx, modeRGB, modeA, false); +} + + static void blend_equation_separatei(struct gl_context *ctx, GLuint buf, GLenum modeRGB, GLenum modeA) -- 2.30.2