mesa: add blend_equation_separate() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 19 Jul 2017 07:51:37 +0000 (09:51 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 31 Jul 2017 11:53:39 +0000 (13:53 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/blend.c

index 8fb2d692a34f3607e5dd107fb17b9f2b3bb5c768..2c13f1900495452410e3b1d35133799991bda776 100644 (file)
@@ -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)