[MSHTML_WINETEST]
[reactos.git] / reactos / dll / opengl / mesa / src / mesa / x86 / sse.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.0
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /*
26 * PentiumIII-SIMD (SSE) optimizations contributed by
27 * Andre Werthmann <wertmann@cs.uni-potsdam.de>
28 */
29
30 #include "main/glheader.h"
31 #include "main/context.h"
32 #include "math/m_xform.h"
33 #include "tnl/t_context.h"
34
35 #include "sse.h"
36 #include "x86_xform.h"
37
38 #ifdef DEBUG_MATH
39 #include "math/m_debug.h"
40 #endif
41
42
43 #ifdef USE_SSE_ASM
44 DECLARE_XFORM_GROUP( sse, 2 )
45 DECLARE_XFORM_GROUP( sse, 3 )
46
47 #if 1
48 /* Some functions are not written in SSE-assembly, because the fpu ones are faster */
49 extern void _ASMAPI _mesa_sse_transform_normals_no_rot( NORM_ARGS );
50 extern void _ASMAPI _mesa_sse_transform_rescale_normals( NORM_ARGS );
51 extern void _ASMAPI _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS );
52
53 extern void _ASMAPI _mesa_sse_transform_points4_general( XFORM_ARGS );
54 extern void _ASMAPI _mesa_sse_transform_points4_3d( XFORM_ARGS );
55 /* XXX this function segfaults, see below */
56 extern void _ASMAPI _mesa_sse_transform_points4_identity( XFORM_ARGS );
57 /* XXX this one works, see below */
58 extern void _ASMAPI _mesa_x86_transform_points4_identity( XFORM_ARGS );
59 #else
60 DECLARE_NORM_GROUP( sse )
61 #endif
62
63
64 extern void _ASMAPI
65 _mesa_v16_sse_general_xform( GLfloat *first_vert,
66 const GLfloat *m,
67 const GLfloat *src,
68 GLuint src_stride,
69 GLuint count );
70
71 extern void _ASMAPI
72 _mesa_sse_project_vertices( GLfloat *first,
73 GLfloat *last,
74 const GLfloat *m,
75 GLuint stride );
76
77 extern void _ASMAPI
78 _mesa_sse_project_clipped_vertices( GLfloat *first,
79 GLfloat *last,
80 const GLfloat *m,
81 GLuint stride,
82 const GLubyte *clipmask );
83 #endif
84
85
86 void _mesa_init_sse_transform_asm( void )
87 {
88 #ifdef USE_SSE_ASM
89 ASSIGN_XFORM_GROUP( sse, 2 );
90 ASSIGN_XFORM_GROUP( sse, 3 );
91
92 #if 1
93 /* TODO: Finish these off.
94 */
95 _mesa_transform_tab[4][MATRIX_GENERAL] =
96 _mesa_sse_transform_points4_general;
97 _mesa_transform_tab[4][MATRIX_3D] =
98 _mesa_sse_transform_points4_3d;
99 /* XXX NOTE: _mesa_sse_transform_points4_identity segfaults with the
100 conformance tests, so use the x86 version.
101 */
102 _mesa_transform_tab[4][MATRIX_IDENTITY] =
103 _mesa_x86_transform_points4_identity;/*_mesa_sse_transform_points4_identity;*/
104
105 _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] =
106 _mesa_sse_transform_normals_no_rot;
107 _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] =
108 _mesa_sse_transform_rescale_normals;
109 _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] =
110 _mesa_sse_transform_rescale_normals_no_rot;
111 #else
112 ASSIGN_XFORM_GROUP( sse, 4 );
113
114 ASSIGN_NORM_GROUP( sse );
115 #endif
116
117 #ifdef DEBUG_MATH
118 _math_test_all_transform_functions( "SSE" );
119 _math_test_all_normal_transform_functions( "SSE" );
120 #endif
121 #endif
122 }
123