mesa: Import libtxc_dxtn sources
[mesa.git] / src / mesa / main / blend.c
index 9ca04c1db29ffb83a5a73a9c0e59426dc7d38732..01721ab615d443677a79516acee39d3ee098abda 100644 (file)
@@ -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 <modeRGB> or <modeAlpha>
+       *     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 <modeRGB> or <modeAlpha>
-    *     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);
 }
 
 
@@ -848,12 +850,37 @@ _mesa_AlphaFunc( GLenum func, GLclampf ref )
 }
 
 
-static void
-logic_op(struct gl_context *ctx, GLenum opcode)
+static ALWAYS_INLINE void
+logic_op(struct gl_context *ctx, GLenum opcode, bool no_error)
 {
    if (ctx->Color.LogicOp == opcode)
       return;
 
+   if (!no_error) {
+      switch (opcode) {
+         case GL_CLEAR:
+         case GL_SET:
+         case GL_COPY:
+         case GL_COPY_INVERTED:
+         case GL_NOOP:
+         case GL_INVERT:
+         case GL_AND:
+         case GL_NAND:
+         case GL_OR:
+         case GL_NOR:
+         case GL_XOR:
+         case GL_EQUIV:
+         case GL_AND_REVERSE:
+         case GL_AND_INVERTED:
+         case GL_OR_REVERSE:
+         case GL_OR_INVERTED:
+            break;
+         default:
+            _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
+            return;
+      }
+   }
+
    FLUSH_VERTICES(ctx, ctx->DriverFlags.NewLogicOp ? 0 : _NEW_COLOR);
    ctx->NewDriverState |= ctx->DriverFlags.NewLogicOp;
    ctx->Color.LogicOp = opcode;
@@ -881,30 +908,7 @@ _mesa_LogicOp( GLenum opcode )
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glLogicOp(%s)\n", _mesa_enum_to_string(opcode));
 
-   switch (opcode) {
-      case GL_CLEAR:
-      case GL_SET:
-      case GL_COPY:
-      case GL_COPY_INVERTED:
-      case GL_NOOP:
-      case GL_INVERT:
-      case GL_AND:
-      case GL_NAND:
-      case GL_OR:
-      case GL_NOR:
-      case GL_XOR:
-      case GL_EQUIV:
-      case GL_AND_REVERSE:
-      case GL_AND_INVERTED:
-      case GL_OR_REVERSE:
-      case GL_OR_INVERTED:
-        break;
-      default:
-         _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
-        return;
-   }
-
-   logic_op(ctx, opcode);
+   logic_op(ctx, opcode, false);
 }
 
 
@@ -912,7 +916,7 @@ void GLAPIENTRY
 _mesa_LogicOp_no_error(GLenum opcode)
 {
    GET_CURRENT_CONTEXT(ctx);
-   logic_op(ctx, opcode);
+   logic_op(ctx, opcode, true);
 }
 
 
@@ -986,18 +990,18 @@ _mesa_ColorMask( GLboolean red, GLboolean green,
  * For GL_EXT_draw_buffers2 and GL3
  */
 void GLAPIENTRY
-_mesa_ColorMaski( GLuint buf, GLboolean red, GLboolean green,
-                        GLboolean blue, GLboolean alpha )
+_mesa_ColorMaski(GLuint buf, GLboolean red, GLboolean green,
+                 GLboolean blue, GLboolean alpha)
 {
    GLubyte tmp[4];
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n",
+      _mesa_debug(ctx, "glColorMaski %u %d %d %d %d\n",
                   buf, red, green, blue, alpha);
 
    if (buf >= ctx->Const.MaxDrawBuffers) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf);
+      _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaski(buf=%u)", buf);
       return;
    }