added dummy function to silence compiler warning
[mesa.git] / src / mesa / x86 / 3dnow.c
1 /* $Id: 3dnow.c,v 1.4 2000/06/14 21:55:11 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
28 /*
29 * 3DNow! optimizations contributed by
30 * Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
31 */
32 #if defined(USE_3DNOW_ASM) && defined(USE_X86_ASM)
33 #include "3dnow.h"
34
35 #include <limits.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <math.h>
39
40 #include "context.h"
41 #include "types.h"
42 #include "xform.h"
43 #include "vertices.h"
44
45 #ifdef DEBUG
46 #include "debug_xform.h"
47 #endif
48
49
50
51
52 #define XFORM_ARGS GLvector4f *to_vec, \
53 const GLmatrix *mat, \
54 const GLvector4f *from_vec, \
55 const GLubyte *mask, \
56 const GLubyte flag
57
58
59
60 #define DECLARE_XFORM_GROUP(pfx, v, masked) \
61 extern void _ASMAPI gl##pfx##_transform_points##v##_general_##masked(XFORM_ARGS); \
62 extern void _ASMAPI gl##pfx##_transform_points##v##_identity_##masked(XFORM_ARGS); \
63 extern void _ASMAPI gl##pfx##_transform_points##v##_3d_no_rot_##masked(XFORM_ARGS); \
64 extern void _ASMAPI gl##pfx##_transform_points##v##_perspective_##masked(XFORM_ARGS);\
65 extern void _ASMAPI gl##pfx##_transform_points##v##_2d_##masked(XFORM_ARGS); \
66 extern void _ASMAPI gl##pfx##_transform_points##v##_2d_no_rot_##masked(XFORM_ARGS); \
67 extern void _ASMAPI gl##pfx##_transform_points##v##_3d_##masked(XFORM_ARGS);
68
69
70
71 #define ASSIGN_XFORM_GROUP( pfx, cma, vsize, masked ) \
72 gl_transform_tab[cma][vsize][MATRIX_GENERAL] \
73 = gl##pfx##_transform_points##vsize##_general_##masked; \
74 gl_transform_tab[cma][vsize][MATRIX_IDENTITY] \
75 = gl##pfx##_transform_points##vsize##_identity_##masked; \
76 gl_transform_tab[cma][vsize][MATRIX_3D_NO_ROT] \
77 = gl##pfx##_transform_points##vsize##_3d_no_rot_##masked; \
78 gl_transform_tab[cma][vsize][MATRIX_PERSPECTIVE] \
79 = gl##pfx##_transform_points##vsize##_perspective_##masked; \
80 gl_transform_tab[cma][vsize][MATRIX_2D] \
81 = gl##pfx##_transform_points##vsize##_2d_##masked; \
82 gl_transform_tab[cma][vsize][MATRIX_2D_NO_ROT] \
83 = gl##pfx##_transform_points##vsize##_2d_no_rot_##masked; \
84 gl_transform_tab[cma][vsize][MATRIX_3D] \
85 = gl##pfx##_transform_points##vsize##_3d_##masked;
86
87
88
89
90 #define NORM_ARGS const GLmatrix *mat, \
91 GLfloat scale, \
92 const GLvector3f *in, \
93 const GLfloat *lengths, \
94 const GLubyte mask[], \
95 GLvector3f *dest
96
97
98
99 #define DECLARE_NORM_GROUP(pfx, masked) \
100 extern void _ASMAPI gl##pfx##_rescale_normals_##masked## (NORM_ARGS); \
101 extern void _ASMAPI gl##pfx##_normalize_normals_##masked## (NORM_ARGS); \
102 extern void _ASMAPI gl##pfx##_transform_normals_##masked## (NORM_ARGS); \
103 extern void _ASMAPI gl##pfx##_transform_normals_no_rot_##masked## (NORM_ARGS); \
104 extern void _ASMAPI gl##pfx##_transform_rescale_normals_##masked## (NORM_ARGS); \
105 extern void _ASMAPI gl##pfx##_transform_rescale_normals_no_rot_##masked## (NORM_ARGS); \
106 extern void _ASMAPI gl##pfx##_transform_normalize_normals_##masked## (NORM_ARGS); \
107 extern void _ASMAPI gl##pfx##_transform_normalize_normals_no_rot_##masked## (NORM_ARGS);
108
109
110
111 #define ASSIGN_NORM_GROUP( pfx, cma, masked ) \
112 gl_normal_tab[NORM_RESCALE][cma] = \
113 gl##pfx##_rescale_normals_##masked##; \
114 gl_normal_tab[NORM_NORMALIZE][cma] = \
115 gl##pfx##_normalize_normals_##masked##; \
116 gl_normal_tab[NORM_TRANSFORM][cma] = \
117 gl##pfx##_transform_normals_##masked##; \
118 gl_normal_tab[NORM_TRANSFORM_NO_ROT][cma] = \
119 gl##pfx##_transform_normals_no_rot_##masked##; \
120 gl_normal_tab[NORM_TRANSFORM | NORM_RESCALE][cma] = \
121 gl##pfx##_transform_rescale_normals_##masked##; \
122 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE][cma] = \
123 gl##pfx##_transform_rescale_normals_no_rot_##masked##; \
124 gl_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE][cma] = \
125 gl##pfx##_transform_normalize_normals_##masked##; \
126 gl_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE][cma] = \
127 gl##pfx##_transform_normalize_normals_no_rot_##masked##;
128
129
130 extern void _ASMAPI gl_3dnow_project_vertices( GLfloat *first,
131 GLfloat *last,
132 const GLfloat *m,
133 GLuint stride );
134
135 extern void _ASMAPI gl_3dnow_project_clipped_vertices( GLfloat *first,
136 GLfloat *last,
137 const GLfloat *m,
138 GLuint stride,
139 const GLubyte *clipmask );
140
141 extern void _ASMAPI gl_v16_3dnow_general_xform( GLfloat *first_vert,
142 const GLfloat *m,
143 const GLfloat *src,
144 GLuint src_stride,
145 GLuint count );
146
147 void gl_init_3dnow_asm_transforms (void)
148 {
149 DECLARE_XFORM_GROUP( _3dnow, 1, raw )
150 DECLARE_XFORM_GROUP( _3dnow, 2, raw )
151 DECLARE_XFORM_GROUP( _3dnow, 3, raw )
152 DECLARE_XFORM_GROUP( _3dnow, 4, raw )
153
154 DECLARE_XFORM_GROUP( _3dnow, 1, masked )
155 DECLARE_XFORM_GROUP( _3dnow, 2, masked )
156 DECLARE_XFORM_GROUP( _3dnow, 3, masked )
157 DECLARE_XFORM_GROUP( _3dnow, 4, masked )
158
159 DECLARE_NORM_GROUP( _3dnow, raw )
160 /* DECLARE_NORM_GROUP( _3dnow, masked )
161 */
162
163 ASSIGN_XFORM_GROUP( _3dnow, 0, 1, raw )
164 ASSIGN_XFORM_GROUP( _3dnow, 0, 2, raw )
165 ASSIGN_XFORM_GROUP( _3dnow, 0, 3, raw )
166 ASSIGN_XFORM_GROUP( _3dnow, 0, 4, raw )
167
168 ASSIGN_XFORM_GROUP( _3dnow, CULL_MASK_ACTIVE, 1, masked )
169 ASSIGN_XFORM_GROUP( _3dnow, CULL_MASK_ACTIVE, 2, masked )
170 ASSIGN_XFORM_GROUP( _3dnow, CULL_MASK_ACTIVE, 3, masked )
171 ASSIGN_XFORM_GROUP( _3dnow, CULL_MASK_ACTIVE, 4, masked )
172
173 ASSIGN_NORM_GROUP( _3dnow, 0, raw )
174 /* ASSIGN_NORM_GROUP( _3dnow, CULL_MASK_ACTIVE, masked )
175 */
176
177 #ifdef DEBUG
178 gl_test_all_transform_functions("3Dnow!");
179 gl_test_all_normal_transform_functions("3Dnow!");
180 #endif
181
182 /* Hook in some stuff for vertices.c.
183 */
184 gl_xform_points3_v16_general = gl_v16_3dnow_general_xform;
185 gl_project_v16 = gl_3dnow_project_vertices;
186 gl_project_clipped_v16 = gl_3dnow_project_clipped_vertices;
187 }
188
189 #else
190
191
192 /* silence compiler warning */
193 extern void _mesa_3dnow_dummy_function(void);
194 void _mesa_3dnow_dummy_function(void)
195 {
196 }
197
198 #endif