[Mesa-dev] [PATCH 044/101] mesa: add blend_equation_separate() helper

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Jul 21 17:39:53 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 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 8fb2d692a3..2c13f19004 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)
-- 
2.13.3



More information about the mesa-dev mailing list