1 /* $Id: 3dnow.c,v 1.8 2000/10/23 00:16:28 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>
40 #include "debug_xform.h"
44 #define XFORM_ARGS GLvector4f *to_vec, \
45 const GLfloat m[16], \
46 const GLvector4f *from_vec, \
47 const GLubyte *mask, \
51 #define DECLARE_XFORM_GROUP( pfx, sz, masked ) \
52 extern void _ASMAPI gl_##pfx##_transform_points##sz##_general_##masked( XFORM_ARGS ); \
53 extern void _ASMAPI gl_##pfx##_transform_points##sz##_identity_##masked( XFORM_ARGS ); \
54 extern void _ASMAPI gl_##pfx##_transform_points##sz##_3d_no_rot_##masked( XFORM_ARGS ); \
55 extern void _ASMAPI gl_##pfx##_transform_points##sz##_perspective_##masked( XFORM_ARGS ); \
56 extern void _ASMAPI gl_##pfx##_transform_points##sz##_2d_##masked( XFORM_ARGS ); \
57 extern void _ASMAPI gl_##pfx##_transform_points##sz##_2d_no_rot_##masked( XFORM_ARGS ); \
58 extern void _ASMAPI gl_##pfx##_transform_points##sz##_3d_##masked( XFORM_ARGS );
61 #define ASSIGN_XFORM_GROUP( pfx, cma, sz, masked ) \
62 gl_transform_tab[cma][sz][MATRIX_GENERAL] = \
63 gl_##pfx##_transform_points##sz##_general_##masked; \
64 gl_transform_tab[cma][sz][MATRIX_IDENTITY] = \
65 gl_##pfx##_transform_points##sz##_identity_##masked; \
66 gl_transform_tab[cma][sz][MATRIX_3D_NO_ROT] = \
67 gl_##pfx##_transform_points##sz##_3d_no_rot_##masked; \
68 gl_transform_tab[cma][sz][MATRIX_PERSPECTIVE] = \
69 gl_##pfx##_transform_points##sz##_perspective_##masked; \
70 gl_transform_tab[cma][sz][MATRIX_2D] = \
71 gl_##pfx##_transform_points##sz##_2d_##masked; \
72 gl_transform_tab[cma][sz][MATRIX_2D_NO_ROT] = \
73 gl_##pfx##_transform_points##sz##_2d_no_rot_##masked; \
74 gl_transform_tab[cma][sz][MATRIX_3D] = \
75 gl_##pfx##_transform_points##sz##_3d_##masked;
79 #define NORM_ARGS const GLmatrix *mat, \
81 const GLvector3f *in, \
82 const GLfloat *lengths, \
83 const GLubyte mask[], \
87 #define DECLARE_NORM_GROUP( pfx, masked ) \
88 extern void _ASMAPI gl_##pfx##_rescale_normals_##masked( NORM_ARGS ); \
89 extern void _ASMAPI gl_##pfx##_normalize_normals_##masked( NORM_ARGS ); \
90 extern void _ASMAPI gl_##pfx##_transform_normals_##masked( NORM_ARGS ); \
91 extern void _ASMAPI gl_##pfx##_transform_normals_no_rot_##masked( NORM_ARGS ); \
92 extern void _ASMAPI gl_##pfx##_transform_rescale_normals_##masked( NORM_ARGS ); \
93 extern void _ASMAPI gl_##pfx##_transform_rescale_normals_no_rot_##masked( NORM_ARGS ); \
94 extern void _ASMAPI gl_##pfx##_transform_normalize_normals_##masked( NORM_ARGS ); \
95 extern void _ASMAPI gl_##pfx##_transform_normalize_normals_no_rot_##masked( NORM_ARGS );
98 #define ASSIGN_NORM_GROUP( pfx, cma, masked ) \
99 gl_normal_tab[NORM_RESCALE][cma] = \
100 gl_##pfx##_rescale_normals_##masked; \
101 gl_normal_tab[NORM_NORMALIZE][cma] = \
102 gl_##pfx##_normalize_normals_##masked; \
103 gl_normal_tab[NORM_TRANSFORM][cma] = \
104 gl_##pfx##_transform_normals_##masked; \
105 gl_normal_tab[NORM_TRANSFORM_NO_ROT][cma] = \
106 gl_##pfx##_transform_normals_no_rot_##masked; \
107 gl_normal_tab[NORM_TRANSFORM | NORM_RESCALE][cma] = \
108 gl_##pfx##_transform_rescale_normals_##masked; \
109 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE][cma] = \
110 gl_##pfx##_transform_rescale_normals_no_rot_##masked; \
111 gl_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE][cma] = \
112 gl_##pfx##_transform_normalize_normals_##masked; \
113 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE][cma] = \
114 gl_##pfx##_transform_normalize_normals_no_rot_##masked;
118 DECLARE_XFORM_GROUP( 3dnow
, 1, raw
)
119 DECLARE_XFORM_GROUP( 3dnow
, 2, raw
)
120 DECLARE_XFORM_GROUP( 3dnow
, 3, raw
)
121 DECLARE_XFORM_GROUP( 3dnow
, 4, raw
)
123 DECLARE_XFORM_GROUP( 3dnow
, 1, masked
)
124 DECLARE_XFORM_GROUP( 3dnow
, 2, masked
)
125 DECLARE_XFORM_GROUP( 3dnow
, 3, masked
)
126 DECLARE_XFORM_GROUP( 3dnow
, 4, masked
)
128 DECLARE_NORM_GROUP( 3dnow
, raw
)
129 /*DECLARE_NORM_GROUP( 3dnow, masked )*/
132 extern void _ASMAPI
gl_v16_3dnow_general_xform( GLfloat
*first_vert
,
138 extern void _ASMAPI
gl_3dnow_project_vertices( GLfloat
*first
,
143 extern void _ASMAPI
gl_3dnow_project_clipped_vertices( GLfloat
*first
,
147 const GLubyte
*clipmask
);
151 void gl_init_3dnow_transform_asm( void )
154 ASSIGN_XFORM_GROUP( 3dnow
, 0, 1, raw
);
155 ASSIGN_XFORM_GROUP( 3dnow
, 0, 2, raw
);
156 ASSIGN_XFORM_GROUP( 3dnow
, 0, 3, raw
);
157 ASSIGN_XFORM_GROUP( 3dnow
, 0, 4, raw
);
159 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 1, masked
);
160 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 2, masked
);
161 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 3, masked
);
162 ASSIGN_XFORM_GROUP( 3dnow
, CULL_MASK_ACTIVE
, 4, masked
);
164 ASSIGN_NORM_GROUP( 3dnow
, 0, raw
);
165 /* ASSIGN_NORM_GROUP( 3dnow, CULL_MASK_ACTIVE, masked ); */
168 gl_test_all_transform_functions( "3DNow!" );
169 gl_test_all_normal_transform_functions( "3DNow!" );
174 void gl_init_3dnow_vertex_asm( void )
177 gl_xform_points3_v16_general
= gl_v16_3dnow_general_xform
;
178 gl_project_v16
= gl_3dnow_project_vertices
;
179 gl_project_clipped_v16
= gl_3dnow_project_clipped_vertices
;
182 gl_test_all_vertex_functions( "3DNow!" );