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 <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/856>
This commit is contained in:
parent
b5a8d0319b
commit
c731f2ab63
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue