diff options
author | Samuel Pitoiset <[email protected]> | 2017-07-19 09:51:37 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-07-31 13:53:39 +0200 |
commit | 4141fab9ed41705a2bfba731906b9a23c4676944 (patch) | |
tree | a5b87fd6e0ad8a4d12bf4848c3124d617a4dd658 | |
parent | 6f6c5a1ad7c952d6411d0a327b6f83f67d7388b0 (diff) |
mesa: add blend_equation_separate() helper
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r-- | src/mesa/main/blend.c | 67 |
1 files 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 <modeRGB> or <modeAlpha> - * 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 <modeRGB> or <modeAlpha> + * 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) |