glthread: skip glMultMatrixf if it's identity
authorMarek Olšák <marek.olsak@amd.com>
Tue, 23 Aug 2022 04:12:09 +0000 (00:12 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 26 Sep 2022 22:58:16 +0000 (22:58 +0000)
This is common with viewperf and it helps.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18828>

src/mapi/glapi/gen/gl_API.xml
src/mesa/main/glthread_marshal.h

index fc69c15..0d2c9aa 100644 (file)
         <glx rop="179"/>
     </function>
 
-    <function name="MultMatrixf" es1="1.0" deprecated="3.1" exec="dlist">
+    <function name="MultMatrixf" es1="1.0" deprecated="3.1" exec="dlist"
+              marshal_call_before="if (_mesa_matrix_is_identity(m)) return;">
         <param name="m" type="const GLfloat *" count="16"/>
         <glx rop="180"/>
     </function>
index f390cb9..05dbb10 100644 (file)
@@ -441,6 +441,19 @@ _mesa_get_matrix_index(struct gl_context *ctx, GLenum mode)
    return M_DUMMY;
 }
 
+static inline bool
+_mesa_matrix_is_identity(const float *m)
+{
+   static float identity[16] = {
+      1, 0, 0, 0,
+      0, 1, 0, 0,
+      0, 0, 1, 0,
+      0, 0, 0, 1
+   };
+
+   return !memcmp(m, identity, sizeof(identity));
+}
+
 static inline void
 _mesa_glthread_Enable(struct gl_context *ctx, GLenum cap)
 {