Tizen 2.1 base
[sdk/emulator/qemu.git] / gl / mesa / src / mesa / math / m_xform.c
1 /*
2  * Mesa 3-D graphics library
3  * Version:  5.1
4  *
5  * Copyright (C) 1999-2003  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 /*
27  * Matrix/vertex/vector transformation stuff
28  *
29  *
30  * NOTES:
31  * 1. 4x4 transformation matrices are stored in memory in column major order.
32  * 2. Points/vertices are to be thought of as column vectors.
33  * 3. Transformation of a point p by a matrix M is: p' = M * p
34  */
35
36 #include "main/glheader.h"
37 #include "main/macros.h"
38
39 #include "m_eval.h"
40 #include "m_matrix.h"
41 #include "m_translate.h"
42 #include "m_xform.h"
43
44
45 #ifdef DEBUG_MATH
46 #include "m_debug.h"
47 #endif
48
49 #ifdef USE_X86_ASM
50 #include "x86/common_x86_asm.h"
51 #endif
52
53 #ifdef USE_X86_64_ASM
54 #include "x86-64/x86-64.h"
55 #endif
56
57 #ifdef USE_SPARC_ASM
58 #include "sparc/sparc.h"
59 #endif
60
61 #ifdef USE_PPC_ASM
62 #include "ppc/common_ppc_features.h"
63 #endif
64
65 clip_func _mesa_clip_tab[5];
66 clip_func _mesa_clip_np_tab[5];
67 dotprod_func _mesa_dotprod_tab[5];
68 vec_copy_func _mesa_copy_tab[0x10];
69 normal_func _mesa_normal_tab[0xf];
70 transform_func *_mesa_transform_tab[5];
71
72
73 /* Raw data format used for:
74  *    - Object-to-eye transform prior to culling, although this too
75  *      could be culled under some circumstances.
76  *    - Eye-to-clip transform (via the function above).
77  *    - Cliptesting
78  *    - And everything else too, if culling happens to be disabled.
79  *
80  * GH: It's used for everything now, as clipping/culling is done
81  *     elsewhere (most often by the driver itself).
82  */
83 #define TAG(x) x
84 #define TAG2(x,y) x##y
85 #define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) )
86 #define LOOP for ( i = 0 ; i < n ; i++ )
87 #define ARGS
88 #include "m_xform_tmp.h"
89 #include "m_clip_tmp.h"
90 #include "m_norm_tmp.h"
91 #include "m_dotprod_tmp.h"
92 #include "m_copy_tmp.h"
93 #undef TAG
94 #undef TAG2
95 #undef LOOP
96 #undef ARGS
97
98
99 /*
100  * This is called only once.  It initializes several tables with pointers
101  * to optimized transformation functions.  This is where we can test for
102  * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code.
103  */
104 void
105 _math_init_transformation( void )
106 {
107    init_c_transformations();
108    init_c_norm_transform();
109    init_c_cliptest();
110    init_copy0();
111    init_dotprod();
112
113 #ifdef DEBUG_MATH
114    _math_test_all_transform_functions( "default" );
115    _math_test_all_normal_transform_functions( "default" );
116    _math_test_all_cliptest_functions( "default" );
117 #endif
118
119 #ifdef USE_X86_ASM
120    _mesa_init_all_x86_transform_asm();
121 #elif defined( USE_SPARC_ASM )
122    _mesa_init_all_sparc_transform_asm();
123 #elif defined( USE_PPC_ASM )
124    _mesa_init_all_ppc_transform_asm();
125 #elif defined( USE_X86_64_ASM )
126    _mesa_init_all_x86_64_transform_asm();
127 #endif
128 }