Mesa (master): mesa: only check errors when the state change in glLogicOp( )

Samuel Pitoiset hakzsam at kemper.freedesktop.org
Thu Aug 3 08:56:48 UTC 2017


Module: Mesa
Branch: master
Commit: 8e103371ed270b7493da9fe06901809248dd53f6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e103371ed270b7493da9fe06901809248dd53f6

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed Aug  2 20:47:50 2017 +0200

mesa: only check errors when the state change in glLogicOp()

When this GL call is a no-op, it should be a little faster.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/mesa/main/blend.c | 56 ++++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index af378f784d..5c496d9970 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -850,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;
@@ -883,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);
 }
 
 
@@ -914,7 +916,7 @@ void GLAPIENTRY
 _mesa_LogicOp_no_error(GLenum opcode)
 {
    GET_CURRENT_CONTEXT(ctx);
-   logic_op(ctx, opcode);
+   logic_op(ctx, opcode, true);
 }
 
 




More information about the mesa-commit mailing list