diff options
author | Eric Anholt <[email protected]> | 2019-06-20 10:18:41 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2019-07-01 11:12:15 -0700 |
commit | 52a39a332fec1e5a8d686558b9a71e42bcfcbb0f (patch) | |
tree | 188067a80775d690eed12d88827bb69d521ca2dc /src/mesa/math | |
parent | 1738b38ce8ef5fec6146225306bd70690a269afa (diff) |
mesa: Replace gen_matypes with a simple header for V4F/mat layout.
We can greatly simplify our builds by just hardcoding GLvector4f and
GLmatrix's layouts.
Reviewed-by: Matt Turner <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/mesa/math')
-rw-r--r-- | src/mesa/math/m_matrix.c | 5 | ||||
-rw-r--r-- | src/mesa/math/m_vector.c | 7 | ||||
-rw-r--r-- | src/mesa/math/m_vector.h | 11 | ||||
-rw-r--r-- | src/mesa/math/m_vector_asm.h | 57 |
4 files changed, 71 insertions, 9 deletions
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 57a49533de2..6f91dbd1915 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -39,6 +39,8 @@ #include "main/glheader.h" #include "main/imports.h" #include "main/macros.h" +#define MATH_ASM_PTR_SIZE sizeof(void *) +#include "math/m_vector_asm.h" #include "m_matrix.h" @@ -1137,6 +1139,9 @@ _math_matrix_viewport(GLmatrix *m, const float scale[3], void _math_matrix_set_identity( GLmatrix *mat ) { + STATIC_ASSERT(MATRIX_M == offsetof(GLmatrix, m)); + STATIC_ASSERT(MATRIX_INV == offsetof(GLmatrix, inv)); + memcpy( mat->m, Identity, sizeof(Identity) ); memcpy( mat->inv, Identity, sizeof(Identity) ); diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c index 831f953d655..0f7c52a4ff1 100644 --- a/src/mesa/math/m_vector.c +++ b/src/mesa/math/m_vector.c @@ -79,6 +79,13 @@ static const GLubyte size_bits[5] = { void _mesa_vector4f_init( GLvector4f *v, GLbitfield flags, GLfloat (*storage)[4] ) { + STATIC_ASSERT(V4F_DATA == offsetof(GLvector4f, data)); + STATIC_ASSERT(V4F_START == offsetof(GLvector4f, start)); + STATIC_ASSERT(V4F_COUNT == offsetof(GLvector4f, count)); + STATIC_ASSERT(V4F_STRIDE == offsetof(GLvector4f, stride)); + STATIC_ASSERT(V4F_SIZE == offsetof(GLvector4f, size)); + STATIC_ASSERT(V4F_FLAGS == offsetof(GLvector4f, flags)); + v->stride = 4 * sizeof(GLfloat); v->size = 2; /* may change: 2-4 for vertices and 1-4 for texcoords */ v->data = storage; diff --git a/src/mesa/math/m_vector.h b/src/mesa/math/m_vector.h index 5bd76b8987d..2065324556b 100644 --- a/src/mesa/math/m_vector.h +++ b/src/mesa/math/m_vector.h @@ -31,21 +31,14 @@ #define _M_VECTOR_H_ #include "main/glheader.h" +#define MATH_ASM_PTR_SIZE sizeof(void *) +#include "math/m_vector_asm.h" - -#define VEC_DIRTY_0 0x1 -#define VEC_DIRTY_1 0x2 -#define VEC_DIRTY_2 0x4 -#define VEC_DIRTY_3 0x8 #define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/ #define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */ #define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */ -#define VEC_SIZE_1 VEC_DIRTY_0 -#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1) -#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2) -#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3) diff --git a/src/mesa/math/m_vector_asm.h b/src/mesa/math/m_vector_asm.h new file mode 100644 index 00000000000..60cf1ec8fd1 --- /dev/null +++ b/src/mesa/math/m_vector_asm.h @@ -0,0 +1,57 @@ +/* + * Copyright © 2019 Google LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef _M_VECTOR_ASM_H_ +#define _M_VECTOR_ASM_H_ + +/* This file is a set of defines usable by the old FF TNL assembly code for + * referencing GLvector4f and GLmatrix structs. + */ + +#define VEC_DIRTY_0 0x1 +#define VEC_DIRTY_1 0x2 +#define VEC_DIRTY_2 0x4 +#define VEC_DIRTY_3 0x8 + +#define VEC_SIZE_1 VEC_DIRTY_0 +#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1) +#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2) +#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3) + +/* If you add a new field, please add it to the STATIC_ASSERTs in + * _mesa_vector4f_init(). + */ +#define V4F_DATA 0 +#define V4F_START (V4F_DATA + MATH_ASM_PTR_SIZE) +#define V4F_COUNT (V4F_START + MATH_ASM_PTR_SIZE) +#define V4F_STRIDE (V4F_COUNT + 4) +#define V4F_SIZE (V4F_STRIDE + 4) +#define V4F_FLAGS (V4F_SIZE + 4) + +/* If you add a new field, please add it to the STATIC_ASSERTs in + * _math_matrix_set_identity(). + */ +#define MATRIX_M 0 +#define MATRIX_INV (MATRIX_M + MATH_ASM_PTR_SIZE) + +#endif /* _M_VECTOR_ASM_H */ |