1 /* $Id: 3dnow.c,v 1.11 2000/11/19 02:18:33 gareth Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * 3DNow! optimizations contributed by
29 * Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
37 #include "math/m_vertices.h"
38 #include "math/m_xform.h"
40 #include "tnl/t_context.h"
43 #include "math/m_debug_xform.h"
47 #define XFORM_ARGS GLvector4f *to_vec, \
48 const GLfloat m[16], \
49 const GLvector4f *from_vec, \
50 const GLubyte *mask, \
54 #define DECLARE_XFORM_GROUP( pfx, sz, masked ) \
55 extern void _ASMAPI gl_##pfx##_transform_points##sz##_general_##masked( XFORM_ARGS ); \
56 extern void _ASMAPI gl_##pfx##_transform_points##sz##_identity_##masked( XFORM_ARGS ); \
57 extern void _ASMAPI gl_##pfx##_transform_points##sz##_3d_no_rot_##masked( XFORM_ARGS ); \
58 extern void _ASMAPI gl_##pfx##_transform_points##sz##_perspective_##masked( XFORM_ARGS ); \
59 extern void _ASMAPI gl_##pfx##_transform_points##sz##_2d_##masked( XFORM_ARGS ); \
60 extern void _ASMAPI gl_##pfx##_transform_points##sz##_2d_no_rot_##masked( XFORM_ARGS ); \
61 extern void _ASMAPI gl_##pfx##_transform_points##sz##_3d_##masked( XFORM_ARGS );
64 #define ASSIGN_XFORM_GROUP( pfx, cma, sz, masked ) \
65 gl_transform_tab[cma][sz][MATRIX_GENERAL] = \
66 gl_##pfx##_transform_points##sz##_general_##masked; \
67 gl_transform_tab[cma][sz][MATRIX_IDENTITY] = \
68 gl_##pfx##_transform_points##sz##_identity_##masked; \
69 gl_transform_tab[cma][sz][MATRIX_3D_NO_ROT] = \
70 gl_##pfx##_transform_points##sz##_3d_no_rot_##masked; \
71 gl_transform_tab[cma][sz][MATRIX_PERSPECTIVE] = \
72 gl_##pfx##_transform_points##sz##_perspective_##masked; \
73 gl_transform_tab[cma][sz][MATRIX_2D] = \
74 gl_##pfx##_transform_points##sz##_2d_##masked; \
75 gl_transform_tab[cma][sz][MATRIX_2D_NO_ROT] = \
76 gl_##pfx##_transform_points##sz##_2d_no_rot_##masked; \
77 gl_transform_tab[cma][sz][MATRIX_3D] = \
78 gl_##pfx##_transform_points##sz##_3d_##masked;
82 #define NORM_ARGS const GLmatrix *mat, \
84 const GLvector3f *in, \
85 const GLfloat *lengths, \
86 const GLubyte mask[], \
90 #define DECLARE_NORM_GROUP( pfx, masked ) \
91 extern void _ASMAPI gl_##pfx##_rescale_normals_##masked( NORM_ARGS ); \
92 extern void _ASMAPI gl_##pfx##_normalize_normals_##masked( NORM_ARGS ); \
93 extern void _ASMAPI gl_##pfx##_transform_normals_##masked( NORM_ARGS ); \
94 extern void _ASMAPI gl_##pfx##_transform_normals_no_rot_##masked( NORM_ARGS ); \
95 extern void _ASMAPI gl_##pfx##_transform_rescale_normals_##masked( NORM_ARGS ); \
96 extern void _ASMAPI gl_##pfx##_transform_rescale_normals_no_rot_##masked( NORM_ARGS ); \
97 extern void _ASMAPI gl_##pfx##_transform_normalize_normals_##masked( NORM_ARGS ); \
98 extern void _ASMAPI gl_##pfx##_transform_normalize_normals_no_rot_##masked( NORM_ARGS );
101 #define ASSIGN_NORM_GROUP( pfx, cma, masked ) \
102 gl_normal_tab[NORM_RESCALE][cma] = \
103 gl_##pfx##_rescale_normals_##masked; \
104 gl_normal_tab[NORM_NORMALIZE][cma] = \
105 gl_##pfx##_normalize_normals_##masked; \
106 gl_normal_tab[NORM_TRANSFORM][cma] = \
107 gl_##pfx##_transform_normals_##masked; \
108 gl_normal_tab[NORM_TRANSFORM_NO_ROT][cma] = \
109 gl_##pfx##_transform_normals_no_rot_##masked; \
110 gl_normal_tab[NORM_TRANSFORM | NORM_RESCALE][cma] = \
111 gl_##pfx##_transform_rescale_normals_##masked; \
112 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE][cma] = \
113 gl_##pfx##_transform_rescale_normals_no_rot_##masked; \
114 gl_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE][cma] = \
115 gl_##pfx##_transform_normalize_normals_##masked; \
116 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE][cma] = \
117 gl_##pfx##_transform_normalize_normals_no_rot_##masked;
121 DECLARE_XFORM_GROUP( 3dnow
, 1, raw
)
122 DECLARE_XFORM_GROUP( 3dnow
, 2, raw
)
123 DECLARE_XFORM_GROUP( 3dnow
, 3, raw
)
124 DECLARE_XFORM_GROUP( 3dnow
, 4, raw
)
126 DECLARE_XFORM_GROUP( 3dnow
, 1, masked
)
127 DECLARE_XFORM_GROUP( 3dnow
, 2, masked
)
128 DECLARE_XFORM_GROUP( 3dnow
, 3, masked
)
129 DECLARE_XFORM_GROUP( 3dnow
, 4, masked
)
131 DECLARE_NORM_GROUP( 3dnow
, raw
)
132 /*DECLARE_NORM_GROUP( 3dnow, masked )*/
135 extern void _ASMAPI
gl_v16_3dnow_general_xform( GLfloat
*first_vert
,
141 extern void _ASMAPI
gl_3dnow_project_vertices( GLfloat
*first
,
146 extern void _ASMAPI
gl_3dnow_project_clipped_vertices( GLfloat
*first
,
150 const GLubyte
*clipmask
);
154 void gl_init_3dnow_transform_asm( void )
157 ASSIGN_XFORM_GROUP( 3dnow
, 0, 1, raw
);
158 ASSIGN_XFORM_GROUP( 3dnow
, 0, 2, raw
);
159 ASSIGN_XFORM_GROUP( 3dnow
, 0, 3, raw
);
160 ASSIGN_XFORM_GROUP( 3dnow
, 0, 4, raw
);
162 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 1, masked
);
163 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 2, masked
);
164 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 3, masked
);
165 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 4, masked
);
167 ASSIGN_NORM_GROUP( 3dnow
, 0, raw
);
168 /* ASSIGN_NORM_GROUP( 3dnow, CULL_MASK_ACTIVE, masked ); */
171 gl_test_all_transform_functions( "3DNow!" );
172 gl_test_all_normal_transform_functions( "3DNow!" );
177 void gl_init_3dnow_vertex_asm( void )
180 gl_xform_points3_v16_general
= gl_v16_3dnow_general_xform
;
181 gl_project_v16
= gl_3dnow_project_vertices
;
182 gl_project_clipped_v16
= gl_3dnow_project_clipped_vertices
;
185 gl_test_all_vertex_functions( "3DNow!" );