[Mesa-dev] [PATCH 05/12] mesa: Add matrix utility functions to load matrices
Ian Romanick
idr at freedesktop.org
Mon Jun 26 23:22:38 UTC 2017
From: Ian Romanick <ian.d.romanick at intel.com>
These are basically DSA versions of glLoadIdentity() and glLoadMatrix().
text data bss dec hex filename
7155026 256860 37332 7449218 71aa82 32-bit i965_dri.so before
7155246 256860 37332 7449438 71ab5e 32-bit i965_dri.so after
6788499 328056 50704 7167259 6d5d1b 64-bit i965_dri.so before
6788683 328056 50704 7167443 6d5dd3 64-bit i965_dri.so after
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/main/matrix.c | 32 +++++++++++++++++++++++---------
src/mesa/main/matrix.h | 8 ++++++++
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 83f081e..29a047d 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -308,6 +308,16 @@ _mesa_PopMatrix( void )
}
+void
+_mesa_load_identity_matrix(struct gl_context *ctx, struct gl_matrix_stack *s)
+{
+ FLUSH_VERTICES(ctx, 0);
+
+ _math_matrix_set_identity(s->Top);
+ ctx->NewState |= s->DirtyFlag;
+}
+
+
/**
* Replace the current matrix with the identity matrix.
*
@@ -322,16 +332,24 @@ _mesa_LoadIdentity( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VERTICES(ctx, 0);
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glLoadIdentity()\n");
- _math_matrix_set_identity( ctx->CurrentStack->Top );
- ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+ _mesa_load_identity_matrix(ctx, ctx->CurrentStack);
}
+void
+_mesa_load_matrix(struct gl_context *ctx, struct gl_matrix_stack *s,
+ const GLfloat *m)
+{
+ if (memcmp(m, s->Top->m, 16 * sizeof(GLfloat)) != 0) {
+ FLUSH_VERTICES(ctx, 0);
+ _math_matrix_loadf(s->Top, m);
+ ctx->NewState |= s->DirtyFlag;
+ }
+}
+
/**
* Replace the current matrix with a given matrix.
*
@@ -356,11 +374,7 @@ _mesa_LoadMatrixf( const GLfloat *m )
m[2], m[6], m[10], m[14],
m[3], m[7], m[11], m[15]);
- if (memcmp(m, ctx->CurrentStack->Top->m, 16 * sizeof(GLfloat)) != 0) {
- FLUSH_VERTICES(ctx, 0);
- _math_matrix_loadf( ctx->CurrentStack->Top, m );
- ctx->NewState |= ctx->CurrentStack->DirtyFlag;
- }
+ _mesa_load_matrix(ctx, ctx->CurrentStack, m);
}
diff --git a/src/mesa/main/matrix.h b/src/mesa/main/matrix.h
index 8eee67c..33d7767 100644
--- a/src/mesa/main/matrix.h
+++ b/src/mesa/main/matrix.h
@@ -31,6 +31,14 @@
#include "glheader.h"
struct gl_context;
+struct gl_matrix_stack;
+
+extern void
+_mesa_load_identity_matrix(struct gl_context *ctx, struct gl_matrix_stack *s);
+
+extern void
+_mesa_load_matrix(struct gl_context *ctx, struct gl_matrix_stack *s,
+ const GLfloat *m);
extern void GLAPIENTRY
_mesa_Frustum( GLdouble left, GLdouble right,
--
2.9.4
More information about the mesa-dev
mailing list