00001 00032 #ifndef LL_LLV4MATH_H 00033 #define LL_LLV4MATH_H 00034 00035 // *NOTE: We do not support SSE acceleration on Windows builds. 00036 // Our minimum specification for the viewer includes 1 GHz Athlon processors, 00037 // which covers the Athlon Thunderbird series that does not support SSE. 00038 // 00039 // Our header files include statements like this 00040 // const F32 HAVOK_TIMESTEP = 1.f / 45.f; 00041 // This creates "globals" that are included in each .obj file. If a single 00042 // .cpp file has SSE code generation turned on (eg, llviewerjointmesh_sse.cpp) 00043 // these globals will be initialized using SSE instructions. This causes SL 00044 // to crash before main() on processors without SSE. Untangling all these 00045 // headers/variables is too much work for the small performance gains of 00046 // vectorization. 00047 // 00048 // Therefore we only support vectorization on builds where the everything is 00049 // built with SSE or Altivec. See https://jira.secondlife.com/browse/VWR-1610 00050 // and https://jira.lindenlab.com/browse/SL-47720 for details. 00051 // 00052 // Sorry the code is such a mess. JC 00053 00054 //----------------------------------------------------------------------------- 00055 //----------------------------------------------------------------------------- 00056 // LLV4MATH - GNUC 00057 //----------------------------------------------------------------------------- 00058 //----------------------------------------------------------------------------- 00059 00060 #if LL_GNUC && __GNUC__ >= 4 && __SSE__ 00061 00062 #define LL_VECTORIZE 1 00063 00064 #if LL_DARWIN 00065 00066 #include <Accelerate/Accelerate.h> 00067 #include <xmmintrin.h> 00068 typedef vFloat V4F32; 00069 00070 #else 00071 00072 #include <xmmintrin.h> 00073 typedef float V4F32 __attribute__((vector_size(16))); 00074 00075 #endif 00076 00077 #endif 00078 #if LL_GNUC 00079 00080 #define LL_LLV4MATH_ALIGN_PREFIX 00081 #define LL_LLV4MATH_ALIGN_POSTFIX __attribute__((aligned(16))) 00082 00083 #endif 00084 00085 //----------------------------------------------------------------------------- 00086 //----------------------------------------------------------------------------- 00087 // LLV4MATH - MSVC 00088 //----------------------------------------------------------------------------- 00089 //----------------------------------------------------------------------------- 00090 00091 // Only vectorize if the entire Windows build uses SSE. 00092 // _M_IX86_FP is set when SSE code generation is turned on, and I have 00093 // confirmed this in VS2003, VS2003 SP1, and VS2005. JC 00094 #if LL_MSVC && _M_IX86_FP 00095 00096 #define LL_VECTORIZE 1 00097 00098 #include <xmmintrin.h> 00099 00100 typedef __m128 V4F32; 00101 00102 #endif 00103 #if LL_MSVC 00104 00105 #define LL_LLV4MATH_ALIGN_PREFIX __declspec(align(16)) 00106 #define LL_LLV4MATH_ALIGN_POSTFIX 00107 00108 #endif 00109 00110 //----------------------------------------------------------------------------- 00111 //----------------------------------------------------------------------------- 00112 // LLV4MATH - default - no vectorization 00113 //----------------------------------------------------------------------------- 00114 //----------------------------------------------------------------------------- 00115 00116 #if !LL_VECTORIZE 00117 00118 #define LL_VECTORIZE 0 00119 00120 struct V4F32 { F32 __pad__[4]; }; 00121 00122 inline F32 llv4lerp(F32 a, F32 b, F32 w) { return ( b - a ) * w + a; } 00123 00124 #endif 00125 00126 #ifndef LL_LLV4MATH_ALIGN_PREFIX 00127 # define LL_LLV4MATH_ALIGN_PREFIX 00128 #endif 00129 #ifndef LL_LLV4MATH_ALIGN_POSTFIX 00130 # define LL_LLV4MATH_ALIGN_POSTFIX 00131 #endif 00132 00133 //----------------------------------------------------------------------------- 00134 //----------------------------------------------------------------------------- 00135 // LLV4MATH 00136 //----------------------------------------------------------------------------- 00137 //----------------------------------------------------------------------------- 00138 00139 00140 #define LLV4_NUM_AXIS 4 00141 00142 class LLV4Vector3; 00143 class LLV4Matrix3; 00144 class LLV4Matrix4; 00145 00146 #endif