From 0b00a158ad49b495bd5e6558e7eb0dd06b9ba7f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 23 Aug 2022 00:12:59 -0400 Subject: [PATCH] mesa: use memcmp instead of floating-point comparisons in glMultMatrixf This is faster. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/matrix.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index ca30ede..ac23e70 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -561,13 +561,17 @@ _mesa_MatrixLoadfEXT( GLenum matrixMode, const GLfloat *m ) static void matrix_mult(struct gl_matrix_stack *stack, const GLfloat *m, const char* caller) { + static float identity[16] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, + }; + GET_CURRENT_CONTEXT(ctx); - if (!m || - (m[0] == 1 && m[1] == 0 && m[2] == 0 && m[3] == 0 && - m[4] == 0 && m[5] == 1 && m[6] == 0 && m[7] == 0 && - m[8] == 0 && m[9] == 0 && m[10] == 1 && m[11] == 0 && - m[12] == 0 && m[13] == 0 && m[14] == 0 && m[15] == 1)) + if (!m || !memcmp(m, identity, sizeof(identity))) return; + if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", -- 2.7.4