diff options
Diffstat (limited to 'linden/indra/llmath/llv4math.h')
-rw-r--r-- | linden/indra/llmath/llv4math.h | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/linden/indra/llmath/llv4math.h b/linden/indra/llmath/llv4math.h new file mode 100644 index 0000000..2853ab6 --- /dev/null +++ b/linden/indra/llmath/llv4math.h | |||
@@ -0,0 +1,143 @@ | |||
1 | /** | ||
2 | * @file llv4math.h | ||
3 | * @brief LLV4* class header file - vector processor enabled math | ||
4 | * | ||
5 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #ifndef LL_LLV4MATH_H | ||
30 | #define LL_LLV4MATH_H | ||
31 | |||
32 | // *NOTE: We do not support SSE acceleration on Windows builds. | ||
33 | // Our minimum specification for the viewer includes 1 GHz Athlon processors, | ||
34 | // which covers the Athlon Thunderbird series that does not support SSE. | ||
35 | // | ||
36 | // Our header files include statements like this | ||
37 | // const F32 HAVOK_TIMESTEP = 1.f / 45.f; | ||
38 | // This creates "globals" that are included in each .obj file. If a single | ||
39 | // .cpp file has SSE code generation turned on (eg, llviewerjointmesh_sse.cpp) | ||
40 | // these globals will be initialized using SSE instructions. This causes SL | ||
41 | // to crash before main() on processors without SSE. Untangling all these | ||
42 | // headers/variables is too much work for the small performance gains of | ||
43 | // vectorization. | ||
44 | // | ||
45 | // Therefore we only support vectorization on builds where the everything is | ||
46 | // built with SSE or Altivec. See https://jira.secondlife.com/browse/VWR-1610 | ||
47 | // and https://jira.lindenlab.com/browse/SL-47720 for details. | ||
48 | // | ||
49 | // Sorry the code is such a mess. JC | ||
50 | |||
51 | //----------------------------------------------------------------------------- | ||
52 | //----------------------------------------------------------------------------- | ||
53 | // LLV4MATH - GNUC | ||
54 | //----------------------------------------------------------------------------- | ||
55 | //----------------------------------------------------------------------------- | ||
56 | |||
57 | #if LL_GNUC && __GNUC__ >= 4 && __SSE__ | ||
58 | |||
59 | #define LL_VECTORIZE 1 | ||
60 | |||
61 | #if LL_DARWIN | ||
62 | |||
63 | #include <Accelerate/Accelerate.h> | ||
64 | #include <xmmintrin.h> | ||
65 | typedef vFloat V4F32; | ||
66 | |||
67 | #else | ||
68 | |||
69 | #include <xmmintrin.h> | ||
70 | typedef float V4F32 __attribute__((vector_size(16))); | ||
71 | |||
72 | #endif | ||
73 | |||
74 | #endif | ||
75 | #if LL_GNUC | ||
76 | |||
77 | #define LL_LLV4MATH_ALIGN_PREFIX | ||
78 | #define LL_LLV4MATH_ALIGN_POSTFIX __attribute__((aligned(16))) | ||
79 | |||
80 | #endif | ||
81 | |||
82 | //----------------------------------------------------------------------------- | ||
83 | //----------------------------------------------------------------------------- | ||
84 | // LLV4MATH - MSVC | ||
85 | //----------------------------------------------------------------------------- | ||
86 | //----------------------------------------------------------------------------- | ||
87 | |||
88 | // Only vectorize if the entire Windows build uses SSE. | ||
89 | // _M_IX86_FP is set when SSE code generation is turned on, and I have | ||
90 | // confirmed this in VS2003, VS2003 SP1, and VS2005. JC | ||
91 | #if LL_MSVC && _M_IX86_FP | ||
92 | |||
93 | #define LL_VECTORIZE 1 | ||
94 | |||
95 | #include <xmmintrin.h> | ||
96 | |||
97 | typedef __m128 V4F32; | ||
98 | |||
99 | #endif | ||
100 | #if LL_MSVC | ||
101 | |||
102 | #define LL_LLV4MATH_ALIGN_PREFIX __declspec(align(16)) | ||
103 | #define LL_LLV4MATH_ALIGN_POSTFIX | ||
104 | |||
105 | #endif | ||
106 | |||
107 | //----------------------------------------------------------------------------- | ||
108 | //----------------------------------------------------------------------------- | ||
109 | // LLV4MATH - default - no vectorization | ||
110 | //----------------------------------------------------------------------------- | ||
111 | //----------------------------------------------------------------------------- | ||
112 | |||
113 | #if !LL_VECTORIZE | ||
114 | |||
115 | #define LL_VECTORIZE 0 | ||
116 | |||
117 | struct V4F32 { F32 __pad__[4]; }; | ||
118 | |||
119 | inline F32 llv4lerp(F32 a, F32 b, F32 w) { return ( b - a ) * w + a; } | ||
120 | |||
121 | #endif | ||
122 | |||
123 | #ifndef LL_LLV4MATH_ALIGN_PREFIX | ||
124 | # define LL_LLV4MATH_ALIGN_PREFIX | ||
125 | #endif | ||
126 | #ifndef LL_LLV4MATH_ALIGN_POSTFIX | ||
127 | # define LL_LLV4MATH_ALIGN_POSTFIX | ||
128 | #endif | ||
129 | |||
130 | //----------------------------------------------------------------------------- | ||
131 | //----------------------------------------------------------------------------- | ||
132 | // LLV4MATH | ||
133 | //----------------------------------------------------------------------------- | ||
134 | //----------------------------------------------------------------------------- | ||
135 | |||
136 | |||
137 | #define LLV4_NUM_AXIS 4 | ||
138 | |||
139 | class LLV4Vector3; | ||
140 | class LLV4Matrix3; | ||
141 | class LLV4Matrix4; | ||
142 | |||
143 | #endif | ||