• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * 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 _mesa_sse_transform_normals_no_rot( NORM_ARGS );
50 extern void _mesa_sse_transform_rescale_normals( NORM_ARGS );
51 extern void _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS );
52 
53 extern void _mesa_sse_transform_points4_general( XFORM_ARGS );
54 extern void _mesa_sse_transform_points4_3d( XFORM_ARGS );
55 /* XXX this function segfaults, see below */
56 extern void _mesa_sse_transform_points4_identity( XFORM_ARGS );
57 /* XXX this one works, see below */
58 extern void _mesa_x86_transform_points4_identity( XFORM_ARGS );
59 #else
60 DECLARE_NORM_GROUP( sse )
61 #endif
62 
63 
64 extern void
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
72 _mesa_sse_project_vertices( GLfloat *first,
73 			    GLfloat *last,
74 			    const GLfloat *m,
75 			    GLuint stride );
76 
77 extern void
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 
_mesa_init_sse_transform_asm(void)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 
124