aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/matrix.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2017-06-02 15:59:24 -0700
committerMarge Bot <[email protected]>2020-05-14 15:35:43 +0000
commitc731f2ab63d001d47995e3f5e0e8f5c74d5a2e55 (patch)
treec569660618a54c98e47ca08fd9cf236d66a4e5a8 /src/mesa/main/matrix.c
parentb5a8d0319b8fe14bb9f970fdca1decf6dbc9e603 (diff)
mesa: Add matrix utility functions to load matrices
These are basically DSA versions of glLoadIdentity() and glLoadMatrix() that are available for internal Mesa use. text data bss dec hex filename 12243574 1344936 1290748 14879258 e30a1a before/lib64/dri/i965_dri.so 12243486 1344936 1290748 14879170 e309c2 after/lib64/dri/i965_dri.so Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/856>
Diffstat (limited to 'src/mesa/main/matrix.c')
-rw-r--r--src/mesa/main/matrix.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index eba3e8b3317..ade8e0b96a4 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -436,16 +436,16 @@ _mesa_MatrixPopEXT( GLenum matrixMode )
}
-static void
-matrix_load_identity(struct gl_matrix_stack* stack)
+void
+_mesa_load_identity_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack)
{
- GET_CURRENT_CONTEXT(ctx);
-
FLUSH_VERTICES(ctx, 0);
_math_matrix_set_identity(stack->Top);
ctx->NewState |= stack->DirtyFlag;
}
+
+
/**
* Replace the current matrix with the identity matrix.
*
@@ -463,7 +463,7 @@ _mesa_LoadIdentity( void )
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glLoadIdentity()\n");
- matrix_load_identity(ctx->CurrentStack);
+ _mesa_load_identity_matrix(ctx, ctx->CurrentStack);
}
@@ -476,14 +476,26 @@ _mesa_MatrixLoadIdentityEXT( GLenum matrixMode )
if (!stack)
return;
- matrix_load_identity(stack);
+ _mesa_load_identity_matrix(ctx, stack);
+}
+
+
+void
+_mesa_load_matrix(struct gl_context *ctx, struct gl_matrix_stack *stack,
+ const GLfloat *m)
+{
+ if (memcmp(m, stack->Top->m, 16 * sizeof(GLfloat)) != 0) {
+ FLUSH_VERTICES(ctx, 0);
+ _math_matrix_loadf(stack->Top, m);
+ ctx->NewState |= stack->DirtyFlag;
+ }
}
static void
-matrix_load(struct gl_matrix_stack *stack, const GLfloat *m, const char* caller)
+matrix_load(struct gl_context *ctx, struct gl_matrix_stack *stack,
+ const GLfloat *m, const char* caller)
{
- GET_CURRENT_CONTEXT(ctx);
if (!m) return;
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx,
@@ -494,11 +506,7 @@ matrix_load(struct gl_matrix_stack *stack, const GLfloat *m, const char* caller)
m[2], m[6], m[10], m[14],
m[3], m[7], m[11], m[15]);
- if (memcmp(m, stack->Top->m, 16 * sizeof(GLfloat)) != 0) {
- FLUSH_VERTICES(ctx, 0);
- _math_matrix_loadf( stack->Top, m );
- ctx->NewState |= stack->DirtyFlag;
- }
+ _mesa_load_matrix(ctx, stack, m);
}
@@ -517,7 +525,7 @@ void GLAPIENTRY
_mesa_LoadMatrixf( const GLfloat *m )
{
GET_CURRENT_CONTEXT(ctx);
- matrix_load(ctx->CurrentStack, m, "glLoadMatrix");
+ matrix_load(ctx, ctx->CurrentStack, m, "glLoadMatrix");
}
@@ -538,7 +546,7 @@ _mesa_MatrixLoadfEXT( GLenum matrixMode, const GLfloat *m )
if (!stack)
return;
- matrix_load(stack, m, "glMatrixLoadfEXT");
+ matrix_load(ctx, stack, m, "glMatrixLoadfEXT");
}