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

Samuel Pitoiset hakzsam at kemper.freedesktop.org
Mon Jul 31 17:14:39 UTC 2017


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

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Mon Jul 31 14:07:06 2017 +0200

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

When this GL call is a no-op, it should be a little faster in
the errors path only.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/mesa/main/polygon.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index f447993072..a924b84980 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -50,12 +50,18 @@
  * change, flushes the vertices and notifies the driver via
  * the dd_function_table::CullFace callback.
  */
-static void
-cull_face(struct gl_context *ctx, GLenum mode)
+static ALWAYS_INLINE void
+cull_face(struct gl_context *ctx, GLenum mode, bool no_error)
 {
    if (ctx->Polygon.CullFaceMode == mode)
       return;
 
+   if (!no_error &&
+       mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glCullFace");
+      return;
+   }
+
    FLUSH_VERTICES(ctx, ctx->DriverFlags.NewPolygonState ? 0 : _NEW_POLYGON);
    ctx->NewDriverState |= ctx->DriverFlags.NewPolygonState;
    ctx->Polygon.CullFaceMode = mode;
@@ -69,7 +75,7 @@ void GLAPIENTRY
 _mesa_CullFace_no_error(GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
-   cull_face(ctx, mode);
+   cull_face(ctx, mode, true);
 }
 
 
@@ -81,12 +87,7 @@ _mesa_CullFace(GLenum mode)
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glCullFace %s\n", _mesa_enum_to_string(mode));
 
-   if (mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glCullFace");
-      return;
-   }
-
-   cull_face(ctx, mode);
+   cull_face(ctx, mode, false);
 }
 
 




More information about the mesa-commit mailing list