* Auto* build fixes
[mesa.git] / src / mesa / x86 / x86.c
1 /* $Id: x86.c,v 1.11 2000/11/18 08:10:23 jtaylor Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999 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 * Intel x86 assembly code by Josh Vanderhoof
29 */
30
31 #include "glheader.h"
32 #include "context.h"
33 #include "types.h"
34 #include "math/m_vertices.h"
35 #include "math/m_xform.h"
36 #include "../tnl/t_context.h"
37 #include "x86.h"
38
39 #ifdef DEBUG
40 #include "math/m_debug_xform.h"
41 #endif
42
43
44 #define XFORM_ARGS GLvector4f *to_vec, \
45 const GLfloat m[16], \
46 const GLvector4f *from_vec, \
47 const GLubyte *mask, \
48 const GLubyte flag
49
50
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 );
59
60
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;
76
77
78 #ifdef USE_X86_ASM
79 DECLARE_XFORM_GROUP( x86, 2, raw )
80 DECLARE_XFORM_GROUP( x86, 3, raw )
81 DECLARE_XFORM_GROUP( x86, 4, raw )
82 DECLARE_XFORM_GROUP( x86, 2, masked )
83 DECLARE_XFORM_GROUP( x86, 3, masked )
84 DECLARE_XFORM_GROUP( x86, 4, masked )
85
86
87 extern GLvector4f * _ASMAPI gl_x86_cliptest_points4( GLvector4f *clip_vec,
88 GLvector4f *proj_vec,
89 GLubyte clipMask[],
90 GLubyte *orMask,
91 GLubyte *andMask );
92
93
94 extern void _ASMAPI gl_v16_x86_cliptest_points4( GLfloat *first_vert,
95 GLfloat *last_vert,
96 GLubyte *or_mask,
97 GLubyte *and_mask,
98 GLubyte *clip_mask );
99
100
101 extern void _ASMAPI gl_v16_x86_general_xform( GLfloat *dest,
102 const GLfloat *m,
103 const GLfloat *src,
104 GLuint src_stride,
105 GLuint count );
106 #endif
107
108
109 void gl_init_x86_transform_asm( void )
110 {
111 #ifdef USE_X86_ASM
112 ASSIGN_XFORM_GROUP( x86, 0, 2, raw );
113 ASSIGN_XFORM_GROUP( x86, 0, 3, raw );
114 ASSIGN_XFORM_GROUP( x86, 0, 4, raw );
115
116 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 2, masked );
117 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 3, masked );
118 ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 4, masked );
119
120 /* XXX this function has been found to cause FP overflow exceptions */
121 gl_clip_tab[4] = gl_x86_cliptest_points4;
122
123 #ifdef DEBUG
124 gl_test_all_transform_functions( "x86" );
125 #endif
126 #endif
127 }
128
129 void gl_init_x86_vertex_asm( void )
130 {
131 #ifdef USE_X86_ASM
132 gl_xform_points3_v16_general = gl_v16_x86_general_xform;
133 gl_cliptest_points4_v16 = gl_v16_x86_cliptest_points4;
134
135 #if 0
136 gl_test_all_vertex_functions( "x86" );
137 #endif
138 #endif
139 }