diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmath/CMakeLists.txt | 4 | ||||
-rw-r--r-- | indra/llmath/llv4math.h | 141 | ||||
-rw-r--r-- | indra/llmath/llv4matrix3.h | 220 | ||||
-rw-r--r-- | indra/llmath/llv4matrix4.h | 249 | ||||
-rw-r--r-- | indra/llmath/llv4vector3.h | 80 | ||||
-rw-r--r-- | indra/newview/CMakeLists.txt | 17 | ||||
-rwxr-xr-x | indra/newview/app_settings/settings.xml | 44 | ||||
-rwxr-xr-x | indra/newview/llappviewer.cpp | 38 | ||||
-rw-r--r-- | indra/newview/llviewercontrol.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llviewerjointmesh.cpp | 171 | ||||
-rw-r--r-- | indra/newview/llviewerjointmesh.h | 19 | ||||
-rw-r--r-- | indra/newview/llviewerjointmesh_sse.cpp | 114 | ||||
-rw-r--r-- | indra/newview/llviewerjointmesh_sse2.cpp | 121 | ||||
-rw-r--r-- | indra/newview/llviewerjointmesh_vec.cpp | 97 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 21 |
15 files changed, 6 insertions, 1340 deletions
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index cd100cdf9f..b5e59c1ca3 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -75,10 +75,6 @@ set(llmath_HEADER_FILES llvector4a.h llvector4a.inl llvector4logical.h - llv4math.h - llv4matrix3.h - llv4matrix4.h - llv4vector3.h llvolume.h llvolumemgr.h llvolumeoctree.h diff --git a/indra/llmath/llv4math.h b/indra/llmath/llv4math.h deleted file mode 100644 index 5f403ba526..0000000000 --- a/indra/llmath/llv4math.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file llv4math.h - * @brief LLV4* class header file - vector processor enabled math - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLV4MATH_H -#define LL_LLV4MATH_H - -// *NOTE: We do not support SSE acceleration on Windows builds. -// Our minimum specification for the viewer includes 1 GHz Athlon processors, -// which covers the Athlon Thunderbird series that does not support SSE. -// -// Our header files include statements like this -// const F32 HAVOK_TIMESTEP = 1.f / 45.f; -// This creates "globals" that are included in each .obj file. If a single -// .cpp file has SSE code generation turned on (eg, llviewerjointmesh_sse.cpp) -// these globals will be initialized using SSE instructions. This causes SL -// to crash before main() on processors without SSE. Untangling all these -// headers/variables is too much work for the small performance gains of -// vectorization. -// -// Therefore we only support vectorization on builds where the everything is -// built with SSE or Altivec. See https://jira.secondlife.com/browse/VWR-1610 -// and https://jira.lindenlab.com/browse/SL-47720 for details. -// -// Sorry the code is such a mess. JC - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4MATH - GNUC -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#if LL_GNUC && __GNUC__ >= 4 && __SSE__ - -#define LL_VECTORIZE 1 - -#if LL_DARWIN - -#include <Accelerate/Accelerate.h> -#include <xmmintrin.h> -typedef vFloat V4F32; - -#else - -#include <xmmintrin.h> -typedef float V4F32 __attribute__((vector_size(16))); - -#endif - -#endif -#if LL_GNUC - -#define LL_LLV4MATH_ALIGN_PREFIX -#define LL_LLV4MATH_ALIGN_POSTFIX __attribute__((aligned(16))) - -#endif - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4MATH - MSVC -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -// Only vectorize if the entire Windows build uses SSE. -// _M_IX86_FP is set when SSE code generation is turned on, and I have -// confirmed this in VS2003, VS2003 SP1, and VS2005. JC -#if LL_MSVC && _M_IX86_FP - -#define LL_VECTORIZE 1 - -#include <xmmintrin.h> - -typedef __m128 V4F32; - -#endif -#if LL_MSVC - -#define LL_LLV4MATH_ALIGN_PREFIX __declspec(align(16)) -#define LL_LLV4MATH_ALIGN_POSTFIX - -#endif - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4MATH - default - no vectorization -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#if !LL_VECTORIZE - -#define LL_VECTORIZE 0 - -struct V4F32 { F32 __pad__[4]; }; - -inline F32 llv4lerp(F32 a, F32 b, F32 w) { return ( b - a ) * w + a; } - -#endif - -#ifndef LL_LLV4MATH_ALIGN_PREFIX -# define LL_LLV4MATH_ALIGN_PREFIX -#endif -#ifndef LL_LLV4MATH_ALIGN_POSTFIX -# define LL_LLV4MATH_ALIGN_POSTFIX -#endif - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4MATH -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - - -#define LLV4_NUM_AXIS 4 - -class LLV4Vector3; -class LLV4Matrix3; -class LLV4Matrix4; - -#endif diff --git a/indra/llmath/llv4matrix3.h b/indra/llmath/llv4matrix3.h deleted file mode 100644 index 270f5d7dae..0000000000 --- a/indra/llmath/llv4matrix3.h +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @file llviewerjointmesh.cpp - * @brief LLV4* class header file - vector processor enabled math - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLV4MATRIX3_H -#define LL_LLV4MATRIX3_H - -#include "llv4math.h" -#include "llv4vector3.h" -#include "m3math.h" // for operator LLMatrix3() - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix3 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -LL_LLV4MATH_ALIGN_PREFIX - -class LLV4Matrix3 -{ -public: - union { - F32 mMatrix[LLV4_NUM_AXIS][LLV4_NUM_AXIS]; - V4F32 mV[LLV4_NUM_AXIS]; - }; - - void lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w); - void multiply(const LLVector3 &a, LLVector3& out) const; - void multiply(const LLVector4 &a, LLV4Vector3& out) const; - void multiply(const LLVector3 &a, LLV4Vector3& out) const; - - const LLV4Matrix3& transpose(); - const LLV4Matrix3& operator=(const LLMatrix3& a); - - operator LLMatrix3() const { return (reinterpret_cast<const LLMatrix4*>(const_cast<const F32*>(&mMatrix[0][0])))->getMat3(); } - - friend LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b); -} - -LL_LLV4MATH_ALIGN_POSTFIX; - - - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix3 - SSE -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#if LL_VECTORIZE - -inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w) -{ - __m128 vw = _mm_set1_ps(w); - mV[VX] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VX], a.mV[VX]), vw), a.mV[VX]); // ( b - a ) * w + a - mV[VY] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VY], a.mV[VY]), vw), a.mV[VY]); - mV[VZ] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VZ], a.mV[VZ]), vw), a.mV[VZ]); -} - -inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const -{ - LLV4Vector3 j; - j.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... - j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); - j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); - o.setVec(j.mV); -} - -inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const -{ - o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); -} - -inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const -{ - o.v = _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX]); // ( ax * vx ) + ... - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix3 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#else - -inline void LLV4Matrix3::lerp(const LLV4Matrix3 &a, const LLV4Matrix3 &b, const F32 &w) -{ - mMatrix[VX][VX] = llv4lerp(a.mMatrix[VX][VX], b.mMatrix[VX][VX], w); - mMatrix[VX][VY] = llv4lerp(a.mMatrix[VX][VY], b.mMatrix[VX][VY], w); - mMatrix[VX][VZ] = llv4lerp(a.mMatrix[VX][VZ], b.mMatrix[VX][VZ], w); - - mMatrix[VY][VX] = llv4lerp(a.mMatrix[VY][VX], b.mMatrix[VY][VX], w); - mMatrix[VY][VY] = llv4lerp(a.mMatrix[VY][VY], b.mMatrix[VY][VY], w); - mMatrix[VY][VZ] = llv4lerp(a.mMatrix[VY][VZ], b.mMatrix[VY][VZ], w); - - mMatrix[VZ][VX] = llv4lerp(a.mMatrix[VZ][VX], b.mMatrix[VZ][VX], w); - mMatrix[VZ][VY] = llv4lerp(a.mMatrix[VZ][VY], b.mMatrix[VZ][VY], w); - mMatrix[VZ][VZ] = llv4lerp(a.mMatrix[VZ][VZ], b.mMatrix[VZ][VZ], w); -} - -inline void LLV4Matrix3::multiply(const LLVector3 &a, LLVector3& o) const -{ - o.setVec( a.mV[VX] * mMatrix[VX][VX] + - a.mV[VY] * mMatrix[VY][VX] + - a.mV[VZ] * mMatrix[VZ][VX], - - a.mV[VX] * mMatrix[VX][VY] + - a.mV[VY] * mMatrix[VY][VY] + - a.mV[VZ] * mMatrix[VZ][VY], - - a.mV[VX] * mMatrix[VX][VZ] + - a.mV[VY] * mMatrix[VY][VZ] + - a.mV[VZ] * mMatrix[VZ][VZ]); -} - -inline void LLV4Matrix3::multiply(const LLVector4 &a, LLV4Vector3& o) const -{ - o.setVec( a.mV[VX] * mMatrix[VX][VX] + - a.mV[VY] * mMatrix[VY][VX] + - a.mV[VZ] * mMatrix[VZ][VX], - - a.mV[VX] * mMatrix[VX][VY] + - a.mV[VY] * mMatrix[VY][VY] + - a.mV[VZ] * mMatrix[VZ][VY], - - a.mV[VX] * mMatrix[VX][VZ] + - a.mV[VY] * mMatrix[VY][VZ] + - a.mV[VZ] * mMatrix[VZ][VZ]); -} - -inline void LLV4Matrix3::multiply(const LLVector3 &a, LLV4Vector3& o) const -{ - o.setVec( a.mV[VX] * mMatrix[VX][VX] + - a.mV[VY] * mMatrix[VY][VX] + - a.mV[VZ] * mMatrix[VZ][VX], - - a.mV[VX] * mMatrix[VX][VY] + - a.mV[VY] * mMatrix[VY][VY] + - a.mV[VZ] * mMatrix[VZ][VY], - - a.mV[VX] * mMatrix[VX][VZ] + - a.mV[VY] * mMatrix[VY][VZ] + - a.mV[VZ] * mMatrix[VZ][VZ]); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix3 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#endif - -inline const LLV4Matrix3& LLV4Matrix3::transpose() -{ -#if LL_VECTORIZE && defined(_MM_TRANSPOSE4_PS) - _MM_TRANSPOSE4_PS(mV[VX], mV[VY], mV[VZ], mV[VW]); - return *this; -#else - F32 temp; - temp = mMatrix[VX][VY]; mMatrix[VX][VY] = mMatrix[VY][VX]; mMatrix[VY][VX] = temp; - temp = mMatrix[VX][VZ]; mMatrix[VX][VZ] = mMatrix[VZ][VX]; mMatrix[VZ][VX] = temp; - temp = mMatrix[VY][VZ]; mMatrix[VY][VZ] = mMatrix[VZ][VY]; mMatrix[VZ][VY] = temp; -#endif - return *this; -} - -inline const LLV4Matrix3& LLV4Matrix3::operator=(const LLMatrix3& a) -{ - memcpy(mMatrix[VX], a.mMatrix[VX], sizeof(F32) * 3 ); - memcpy(mMatrix[VY], a.mMatrix[VY], sizeof(F32) * 3 ); - memcpy(mMatrix[VZ], a.mMatrix[VZ], sizeof(F32) * 3 ); - return *this; -} - -inline LLVector3 operator*(const LLVector3& a, const LLV4Matrix3& b) -{ - return LLVector3( - a.mV[VX] * b.mMatrix[VX][VX] + - a.mV[VY] * b.mMatrix[VY][VX] + - a.mV[VZ] * b.mMatrix[VZ][VX], - - a.mV[VX] * b.mMatrix[VX][VY] + - a.mV[VY] * b.mMatrix[VY][VY] + - a.mV[VZ] * b.mMatrix[VZ][VY], - - a.mV[VX] * b.mMatrix[VX][VZ] + - a.mV[VY] * b.mMatrix[VY][VZ] + - a.mV[VZ] * b.mMatrix[VZ][VZ] ); -} - -#endif diff --git a/indra/llmath/llv4matrix4.h b/indra/llmath/llv4matrix4.h deleted file mode 100644 index 2eb49d9294..0000000000 --- a/indra/llmath/llv4matrix4.h +++ /dev/null @@ -1,249 +0,0 @@ -/** - * @file llviewerjointmesh.cpp - * @brief LLV4* class header file - vector processor enabled math - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLV4MATRIX4_H -#define LL_LLV4MATRIX4_H - -#include "llv4math.h" -#include "llv4matrix3.h" // just for operator LLV4Matrix3() -#include "llv4vector3.h" - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix4 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -LL_LLV4MATH_ALIGN_PREFIX - -class LLV4Matrix4 -{ -public: - union { - F32 mMatrix[LLV4_NUM_AXIS][LLV4_NUM_AXIS]; - V4F32 mV[LLV4_NUM_AXIS]; - }; - - void lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w); - void multiply(const LLVector3 &a, LLVector3& o) const; - void multiply(const LLVector3 &a, LLV4Vector3& o) const; - - const LLV4Matrix4& transpose(); - const LLV4Matrix4& translate(const LLVector3 &vec); - const LLV4Matrix4& translate(const LLV4Vector3 &vec); - const LLV4Matrix4& operator=(const LLMatrix4& a); - - operator LLMatrix4() const { return *(reinterpret_cast<const LLMatrix4*>(const_cast<const F32*>(&mMatrix[0][0]))); } - operator LLV4Matrix3() const { return *(reinterpret_cast<const LLV4Matrix3*>(const_cast<const F32*>(&mMatrix[0][0]))); } - - friend LLVector3 operator*(const LLVector3 &a, const LLV4Matrix4 &b); -} - -LL_LLV4MATH_ALIGN_POSTFIX; - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix4 - SSE -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#if LL_VECTORIZE - -inline void LLV4Matrix4::lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w) -{ - __m128 vw = _mm_set1_ps(w); - mV[VX] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VX], a.mV[VX]), vw), a.mV[VX]); // ( b - a ) * w + a - mV[VY] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VY], a.mV[VY]), vw), a.mV[VY]); - mV[VZ] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VZ], a.mV[VZ]), vw), a.mV[VZ]); - mV[VW] = _mm_add_ps(_mm_mul_ps(_mm_sub_ps(b.mV[VW], a.mV[VW]), vw), a.mV[VW]); -} - -inline void LLV4Matrix4::multiply(const LLVector3 &a, LLVector3& o) const -{ - LLV4Vector3 j; - j.v = _mm_add_ps(mV[VW], _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX])); // ( ax * vx ) + vw - j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); - j.v = _mm_add_ps(j.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); - o.setVec(j.mV); -} - -inline void LLV4Matrix4::multiply(const LLVector3 &a, LLV4Vector3& o) const -{ - o.v = _mm_add_ps(mV[VW], _mm_mul_ps(_mm_set1_ps(a.mV[VX]), mV[VX])); // ( ax * vx ) + vw - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VY]), mV[VY])); - o.v = _mm_add_ps(o.v , _mm_mul_ps(_mm_set1_ps(a.mV[VZ]), mV[VZ])); -} - -inline const LLV4Matrix4& LLV4Matrix4::translate(const LLV4Vector3 &vec) -{ - mV[VW] = _mm_add_ps(mV[VW], vec.v); - return (*this); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix4 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#else - -inline void LLV4Matrix4::lerp(const LLV4Matrix4 &a, const LLV4Matrix4 &b, const F32 &w) -{ - mMatrix[VX][VX] = llv4lerp(a.mMatrix[VX][VX], b.mMatrix[VX][VX], w); - mMatrix[VX][VY] = llv4lerp(a.mMatrix[VX][VY], b.mMatrix[VX][VY], w); - mMatrix[VX][VZ] = llv4lerp(a.mMatrix[VX][VZ], b.mMatrix[VX][VZ], w); - - mMatrix[VY][VX] = llv4lerp(a.mMatrix[VY][VX], b.mMatrix[VY][VX], w); - mMatrix[VY][VY] = llv4lerp(a.mMatrix[VY][VY], b.mMatrix[VY][VY], w); - mMatrix[VY][VZ] = llv4lerp(a.mMatrix[VY][VZ], b.mMatrix[VY][VZ], w); - - mMatrix[VZ][VX] = llv4lerp(a.mMatrix[VZ][VX], b.mMatrix[VZ][VX], w); - mMatrix[VZ][VY] = llv4lerp(a.mMatrix[VZ][VY], b.mMatrix[VZ][VY], w); - mMatrix[VZ][VZ] = llv4lerp(a.mMatrix[VZ][VZ], b.mMatrix[VZ][VZ], w); - - mMatrix[VW][VX] = llv4lerp(a.mMatrix[VW][VX], b.mMatrix[VW][VX], w); - mMatrix[VW][VY] = llv4lerp(a.mMatrix[VW][VY], b.mMatrix[VW][VY], w); - mMatrix[VW][VZ] = llv4lerp(a.mMatrix[VW][VZ], b.mMatrix[VW][VZ], w); -} - -inline void LLV4Matrix4::multiply(const LLVector3 &a, LLVector3& o) const -{ - o.setVec( a.mV[VX] * mMatrix[VX][VX] + - a.mV[VY] * mMatrix[VY][VX] + - a.mV[VZ] * mMatrix[VZ][VX] + - mMatrix[VW][VX], - - a.mV[VX] * mMatrix[VX][VY] + - a.mV[VY] * mMatrix[VY][VY] + - a.mV[VZ] * mMatrix[VZ][VY] + - mMatrix[VW][VY], - - a.mV[VX] * mMatrix[VX][VZ] + - a.mV[VY] * mMatrix[VY][VZ] + - a.mV[VZ] * mMatrix[VZ][VZ] + - mMatrix[VW][VZ]); -} - -inline void LLV4Matrix4::multiply(const LLVector3 &a, LLV4Vector3& o) const -{ - o.setVec( a.mV[VX] * mMatrix[VX][VX] + - a.mV[VY] * mMatrix[VY][VX] + - a.mV[VZ] * mMatrix[VZ][VX] + - mMatrix[VW][VX], - - a.mV[VX] * mMatrix[VX][VY] + - a.mV[VY] * mMatrix[VY][VY] + - a.mV[VZ] * mMatrix[VZ][VY] + - mMatrix[VW][VY], - - a.mV[VX] * mMatrix[VX][VZ] + - a.mV[VY] * mMatrix[VY][VZ] + - a.mV[VZ] * mMatrix[VZ][VZ] + - mMatrix[VW][VZ]); -} - -inline const LLV4Matrix4& LLV4Matrix4::translate(const LLV4Vector3 &vec) -{ - mMatrix[3][0] += vec.mV[0]; - mMatrix[3][1] += vec.mV[1]; - mMatrix[3][2] += vec.mV[2]; - return (*this); -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Matrix4 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#endif - -inline const LLV4Matrix4& LLV4Matrix4::operator=(const LLMatrix4& a) -{ - memcpy(mMatrix, a.mMatrix, sizeof(F32) * 16 ); - return *this; -} - -inline const LLV4Matrix4& LLV4Matrix4::transpose() -{ -#if LL_VECTORIZE && defined(_MM_TRANSPOSE4_PS) - _MM_TRANSPOSE4_PS(mV[VX], mV[VY], mV[VZ], mV[VW]); -#else - LLV4Matrix4 mat; - mat.mMatrix[0][0] = mMatrix[0][0]; - mat.mMatrix[1][0] = mMatrix[0][1]; - mat.mMatrix[2][0] = mMatrix[0][2]; - mat.mMatrix[3][0] = mMatrix[0][3]; - - mat.mMatrix[0][1] = mMatrix[1][0]; - mat.mMatrix[1][1] = mMatrix[1][1]; - mat.mMatrix[2][1] = mMatrix[1][2]; - mat.mMatrix[3][1] = mMatrix[1][3]; - - mat.mMatrix[0][2] = mMatrix[2][0]; - mat.mMatrix[1][2] = mMatrix[2][1]; - mat.mMatrix[2][2] = mMatrix[2][2]; - mat.mMatrix[3][2] = mMatrix[2][3]; - - mat.mMatrix[0][3] = mMatrix[3][0]; - mat.mMatrix[1][3] = mMatrix[3][1]; - mat.mMatrix[2][3] = mMatrix[3][2]; - mat.mMatrix[3][3] = mMatrix[3][3]; - - *this = mat; -#endif - return *this; -} - -inline const LLV4Matrix4& LLV4Matrix4::translate(const LLVector3 &vec) -{ - mMatrix[3][0] += vec.mV[0]; - mMatrix[3][1] += vec.mV[1]; - mMatrix[3][2] += vec.mV[2]; - return (*this); -} - -inline LLVector3 operator*(const LLVector3 &a, const LLV4Matrix4 &b) -{ - return LLVector3(a.mV[VX] * b.mMatrix[VX][VX] + - a.mV[VY] * b.mMatrix[VY][VX] + - a.mV[VZ] * b.mMatrix[VZ][VX] + - b.mMatrix[VW][VX], - - a.mV[VX] * b.mMatrix[VX][VY] + - a.mV[VY] * b.mMatrix[VY][VY] + - a.mV[VZ] * b.mMatrix[VZ][VY] + - b.mMatrix[VW][VY], - - a.mV[VX] * b.mMatrix[VX][VZ] + - a.mV[VY] * b.mMatrix[VY][VZ] + - a.mV[VZ] * b.mMatrix[VZ][VZ] + - b.mMatrix[VW][VZ]); -} - - -#endif diff --git a/indra/llmath/llv4vector3.h b/indra/llmath/llv4vector3.h deleted file mode 100644 index a340d53f5a..0000000000 --- a/indra/llmath/llv4vector3.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file llviewerjointmesh.cpp - * @brief LLV4* class header file - vector processor enabled math - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLV4VECTOR3_H -#define LL_LLV4VECTOR3_H - -#include "llv4math.h" - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Vector3 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -LL_LLV4MATH_ALIGN_PREFIX - -class LLV4Vector3 -{ -public: - union { - F32 mV[LLV4_NUM_AXIS]; - V4F32 v; - }; - - enum { - ALIGNMENT = 16 - }; - - void setVec(F32 x, F32 y, F32 z); - void setVec(F32 a); -} - -LL_LLV4MATH_ALIGN_POSTFIX; - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// LLV4Vector3 -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -inline void LLV4Vector3::setVec(F32 x, F32 y, F32 z) -{ - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; -} - -inline void LLV4Vector3::setVec(F32 a) -{ -#if LL_VECTORIZE - v = _mm_set1_ps(a); -#else - setVec(a, a, a); -#endif -} - -#endif diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index fa74804314..0467a93dfe 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -540,9 +540,6 @@ set(viewer_SOURCE_FILES llviewerjoint.cpp llviewerjointattachment.cpp llviewerjointmesh.cpp - llviewerjointmesh_sse.cpp - llviewerjointmesh_sse2.cpp - llviewerjointmesh_vec.cpp llviewerjoystick.cpp llviewerkeyboard.cpp llviewerlayer.cpp @@ -624,20 +621,6 @@ set(viewer_SOURCE_FILES set(VIEWER_BINARY_NAME "secondlife-bin" CACHE STRING "The name of the viewer executable to create.") -if (LINUX) - # We can't set these flags for Darwin, because they get passed to - # the PPC compiler. Ugh. - - set_source_files_properties( - llviewerjointmesh_sse.cpp - PROPERTIES COMPILE_FLAGS "-msse -mfpmath=sse" - ) - set_source_files_properties( - llviewerjointmesh_sse2.cpp - PROPERTIES COMPILE_FLAGS "-msse2 -mfpmath=sse" - ) -endif (LINUX) - set(viewer_HEADER_FILES CMakeLists.txt ViewerInstall.cmake diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d057323e51..d07efa6a37 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12202,50 +12202,6 @@ <key>Value</key> <integer>1</integer> </map> - <key>VectorizeEnable</key> - <map> - <key>Comment</key> - <string>Enable general vector operations and data alignment.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>0</integer> - </map> - <key>VectorizePerfTest</key> - <map> - <key>Comment</key> - <string>Test SSE/vectorization performance and choose fastest version.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>1</integer> - </map> - <key>VectorizeProcessor</key> - <map> - <key>Comment</key> - <string>0=Compiler Default, 1=SSE, 2=SSE2, autodetected</string> - <key>Persist</key> - <integer>0</integer> - <key>Type</key> - <string>U32</string> - <key>Value</key> - <integer>0</integer> - </map> - <key>VectorizeSkin</key> - <map> - <key>Comment</key> - <string>Enable vector operations for avatar skinning.</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>1</integer> - </map> <key>VelocityInterpolate</key> <map> <key>Comment</key> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index dfb677dc2c..bab99e8a54 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -558,42 +558,6 @@ static void settings_modify() gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession; gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline"); gAuditTexture = gSavedSettings.getBOOL("AuditTexture"); -#if LL_VECTORIZE - if (gSysCPU.hasAltivec()) - { - gSavedSettings.setBOOL("VectorizeEnable", TRUE ); - gSavedSettings.setU32("VectorizeProcessor", 0 ); - } - else - if (gSysCPU.hasSSE2()) - { - gSavedSettings.setBOOL("VectorizeEnable", TRUE ); - gSavedSettings.setU32("VectorizeProcessor", 2 ); - } - else - if (gSysCPU.hasSSE()) - { - gSavedSettings.setBOOL("VectorizeEnable", TRUE ); - gSavedSettings.setU32("VectorizeProcessor", 1 ); - } - else - { - // Don't bother testing or running if CPU doesn't support it. JC - gSavedSettings.setBOOL("VectorizePerfTest", FALSE ); - gSavedSettings.setBOOL("VectorizeEnable", FALSE ); - gSavedSettings.setU32("VectorizeProcessor", 0 ); - gSavedSettings.setBOOL("VectorizeSkin", FALSE); - } -#else - // This build target doesn't support SSE, don't test/run. - gSavedSettings.setBOOL("VectorizePerfTest", FALSE ); - gSavedSettings.setBOOL("VectorizeEnable", FALSE ); - gSavedSettings.setU32("VectorizeProcessor", 0 ); - gSavedSettings.setBOOL("VectorizeSkin", FALSE); - - // disable fullscreen mode, unsupported - //gSavedSettings.setBOOL("WindowFullScreen", FALSE); -#endif } class LLFastTimerLogThread : public LLThread @@ -877,8 +841,6 @@ bool LLAppViewer::init() LLAgent::parseTeleportMessages("teleport_strings.xml"); - LLViewerJointMesh::updateVectorize(); - // load MIME type -> media impl mappings std::string mime_types_name; #if LL_DARWIN diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 03d765eaee..73e4d11d7b 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -452,12 +452,6 @@ bool handleEffectColorChanged(const LLSD& newvalue) return true; } -bool handleVectorizeChanged(const LLSD& newvalue) -{ - LLViewerJointMesh::updateVectorize(); - return true; -} - bool handleHighResSnapshotChanged(const LLSD& newvalue) { // High Res Snapshot active, must uncheck RenderUIInSnapshot @@ -692,10 +686,6 @@ void settings_setup_listeners() gSavedSettings.getControl("UserLogFile")->getSignal()->connect(boost::bind(&handleLogFileChanged, _2)); gSavedSettings.getControl("RenderHideGroupTitle")->getSignal()->connect(boost::bind(handleHideGroupTitleChanged, _2)); gSavedSettings.getControl("HighResSnapshot")->getSignal()->connect(boost::bind(handleHighResSnapshotChanged, _2)); - gSavedSettings.getControl("VectorizePerfTest")->getSignal()->connect(boost::bind(&handleVectorizeChanged, _2)); - gSavedSettings.getControl("VectorizeEnable")->getSignal()->connect(boost::bind(&handleVectorizeChanged, _2)); - gSavedSettings.getControl("VectorizeProcessor")->getSignal()->connect(boost::bind(&handleVectorizeChanged, _2)); - gSavedSettings.getControl("VectorizeSkin")->getSignal()->connect(boost::bind(&handleVectorizeChanged, _2)); gSavedSettings.getControl("EnableVoiceChat")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); gSavedSettings.getControl("PTTCurrentlyEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); gSavedSettings.getControl("PushToTalkButton")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2)); diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 3e20abecb7..b18323bed0 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -766,7 +766,7 @@ BOOL LLViewerJointMesh::updateLOD(F32 pixel_area, BOOL activate) } // static -void LLViewerJointMesh::updateGeometryOriginal(LLFace *mFace, LLPolyMesh *mMesh) +void LLViewerJointMesh::updateGeometry(LLFace *mFace, LLPolyMesh *mMesh) { LLStrider<LLVector3> o_vertices; LLStrider<LLVector3> o_normals; @@ -832,50 +832,6 @@ static F64 sUpdateGeometryRunAvgOn[10]; static U32 sUpdateGeometryRunCount = 0 ; static U32 sUpdateGeometryCalls = 0 ; static U32 sUpdateGeometryLastProcessor = 0 ; -static BOOL sVectorizePerfTest = FALSE; -static U32 sVectorizeProcessor = 0; - -//static -void (*LLViewerJointMesh::sUpdateGeometryFunc)(LLFace* face, LLPolyMesh* mesh); - -//static -void LLViewerJointMesh::updateVectorize() -{ - sVectorizePerfTest = gSavedSettings.getBOOL("VectorizePerfTest"); - sVectorizeProcessor = gSavedSettings.getU32("VectorizeProcessor"); - BOOL vectorizeEnable = gSavedSettings.getBOOL("VectorizeEnable"); - BOOL vectorizeSkin = gSavedSettings.getBOOL("VectorizeSkin"); - - std::string vp; - switch(sVectorizeProcessor) - { - case 2: vp = "SSE2"; break; // *TODO: replace the magic #s - case 1: vp = "SSE"; break; - default: vp = "COMPILER DEFAULT"; break; - } - LL_INFOS("AppInit") << "Vectorization : " << ( vectorizeEnable ? "ENABLED" : "DISABLED" ) << LL_ENDL ; - LL_INFOS("AppInit") << "Vector Processor : " << vp << LL_ENDL ; - LL_INFOS("AppInit") << "Vectorized Skinning : " << ( vectorizeSkin ? "ENABLED" : "DISABLED" ) << LL_ENDL ; - if(vectorizeEnable && vectorizeSkin) - { - switch(sVectorizeProcessor) - { - case 2: - sUpdateGeometryFunc = &updateGeometrySSE2; - break; - case 1: - sUpdateGeometryFunc = &updateGeometrySSE; - break; - default: - sUpdateGeometryFunc = &updateGeometryVectorized; - break; - } - } - else - { - sUpdateGeometryFunc = &updateGeometryOriginal; - } -} void LLViewerJointMesh::updateJointGeometry() { @@ -889,129 +845,8 @@ void LLViewerJointMesh::updateJointGeometry() return; } - if (!sVectorizePerfTest) - { - // Once we've measured performance, just run the specified - // code version. - if(sUpdateGeometryFunc == updateGeometryOriginal) - uploadJointMatrices(); - sUpdateGeometryFunc(mFace, mMesh); - } - else - { - // At startup, measure the amount of time in skinning and choose - // the fastest one. - LLTimer ug_timer ; - - if (sUpdateGeometryCallPointer) - { - if(sUpdateGeometryFunc == updateGeometryOriginal) - uploadJointMatrices(); - // call accelerated version for this processor - sUpdateGeometryFunc(mFace, mMesh); - } - else - { - uploadJointMatrices(); - updateGeometryOriginal(mFace, mMesh); - } - - sUpdateGeometryElapsedTime += ug_timer.getElapsedTimeF64(); - ++sUpdateGeometryCalls; - if(0 != (sUpdateGeometryCalls & UPDATE_GEOMETRY_CALL_OVERFLOW)) - { - F64 time_since_app_start = ug_timer.getElapsedSeconds(); - if(sUpdateGeometryGlobalTime == 0.0 - || sUpdateGeometryLastProcessor != sVectorizeProcessor) - { - sUpdateGeometryGlobalTime = time_since_app_start; - sUpdateGeometryElapsedTime = 0; - sUpdateGeometryCalls = 0; - sUpdateGeometryRunCount = 0; - sUpdateGeometryLastProcessor = sVectorizeProcessor; - sUpdateGeometryCallPointer = false; - return; - } - F64 percent_time_in_function = - ( sUpdateGeometryElapsedTime * 100.0 ) / ( time_since_app_start - sUpdateGeometryGlobalTime ) ; - sUpdateGeometryGlobalTime = time_since_app_start; - if (!sUpdateGeometryCallPointer) - { - // First set of run data is with vectorization off. - sUpdateGeometryCallPointer = true; - llinfos << "profile (avg of " << sUpdateGeometryCalls << " samples) = " - << "vectorize off " << percent_time_in_function - << "% of time with " - << (sUpdateGeometryElapsedTime / (F64)sUpdateGeometryCalls) - << " seconds per call " - << llendl; - sUpdateGeometryRunAvgOff[sUpdateGeometryRunCount] = percent_time_in_function; - sUpdateGeometryElapsedTimeOff += sUpdateGeometryElapsedTime; - sUpdateGeometryCalls = 0; - } - else - { - // Second set of run data is with vectorization on. - sUpdateGeometryCallPointer = false; - llinfos << "profile (avg of " << sUpdateGeometryCalls << " samples) = " - << "VEC on " << percent_time_in_function - << "% of time with " - << (sUpdateGeometryElapsedTime / (F64)sUpdateGeometryCalls) - << " seconds per call " - << llendl; - sUpdateGeometryRunAvgOn[sUpdateGeometryRunCount] = percent_time_in_function ; - sUpdateGeometryElapsedTimeOn += sUpdateGeometryElapsedTime; - - sUpdateGeometryCalls = 0; - sUpdateGeometryRunCount++; - F64 a = 0.0, b = 0.0; - for(U32 i = 0; i<sUpdateGeometryRunCount; i++) - { - a += sUpdateGeometryRunAvgOff[i]; - b += sUpdateGeometryRunAvgOn[i]; - } - a /= sUpdateGeometryRunCount; - b /= sUpdateGeometryRunCount; - F64 perf_boost = ( sUpdateGeometryElapsedTimeOff - sUpdateGeometryElapsedTimeOn ) / sUpdateGeometryElapsedTimeOn; - llinfos << "run averages (" << (F64)sUpdateGeometryRunCount - << "/10) vectorize off " << a - << "% : vectorize type " << sVectorizeProcessor - << " " << b - << "% : performance boost " - << perf_boost * 100.0 - << "%" - << llendl ; - if(sUpdateGeometryRunCount == 10) - { - // In case user runs test again, force reset of data on - // next run. - sUpdateGeometryGlobalTime = 0.0; - - // We have data now on which version is faster. Switch to that - // code and save the data for next run. - gSavedSettings.setBOOL("VectorizePerfTest", FALSE); - - if (perf_boost > 0.0) - { - llinfos << "Vectorization improves avatar skinning performance, " - << "keeping on for future runs." - << llendl; - gSavedSettings.setBOOL("VectorizeSkin", TRUE); - } - else - { - // SIMD decreases performance, fall back to original code - llinfos << "Vectorization decreases avatar skinning performance, " - << "switching back to original code." - << llendl; - - gSavedSettings.setBOOL("VectorizeSkin", FALSE); - } - } - } - sUpdateGeometryElapsedTime = 0.0f; - } - } + uploadJointMatrices(); + updateGeometry(mFace, mMesh); } void LLViewerJointMesh::dump() diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index cab1205d61..0191f0cae8 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -143,23 +143,10 @@ public: /*virtual*/ BOOL isAnimatable() const { return FALSE; } - static void updateVectorize(); // Update globals when settings variables change - private: - // Avatar vertex skinning is a significant performance issue on computers - // with avatar vertex programs turned off (for example, most Macs). We - // therefore have custom versions that use SIMD instructions. - // - // These functions require compiler options for SSE2, SSE, or neither, and - // hence are contained in separate individual .cpp files. JC - static void updateGeometryOriginal(LLFace* face, LLPolyMesh* mesh); - // generic vector code, used for Altivec - static void updateGeometryVectorized(LLFace* face, LLPolyMesh* mesh); - static void updateGeometrySSE(LLFace* face, LLPolyMesh* mesh); - static void updateGeometrySSE2(LLFace* face, LLPolyMesh* mesh); - - // Use a fuction pointer to indicate which version we are running. - static void (*sUpdateGeometryFunc)(LLFace* face, LLPolyMesh* mesh); + + //copy mesh into given face's vertex buffer, applying current animation pose + static void updateGeometry(LLFace* face, LLPolyMesh* mesh); private: // Allocate skin data diff --git a/indra/newview/llviewerjointmesh_sse.cpp b/indra/newview/llviewerjointmesh_sse.cpp deleted file mode 100644 index 00ed47e091..0000000000 --- a/indra/newview/llviewerjointmesh_sse.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @file llviewerjointmesh_sse.cpp - * @brief SSE vectorized joint skinning code, only used when video card does - * not support avatar vertex programs. - * - * *NOTE: Disabled on Windows builds. See llv4math.h for details. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -//----------------------------------------------------------------------------- -// Header Files -//----------------------------------------------------------------------------- - -#include "llviewerprecompiledheaders.h" - -#include "llviewerjointmesh.h" - -// project includes -#include "llface.h" -#include "llpolymesh.h" - -// library includes -#include "lldarray.h" -#include "llv4math.h" // for LL_VECTORIZE -#include "llv4matrix3.h" -#include "llv4matrix4.h" -#include "v3math.h" - - -#if LL_VECTORIZE - -inline void matrix_translate(LLV4Matrix4& m, const LLMatrix4* w, const LLVector3& j) -{ - m.mV[VX] = _mm_loadu_ps(w->mMatrix[VX]); - m.mV[VY] = _mm_loadu_ps(w->mMatrix[VY]); - m.mV[VZ] = _mm_loadu_ps(w->mMatrix[VZ]); - m.mV[VW] = _mm_loadu_ps(w->mMatrix[VW]); - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VX]), m.mV[VX])); // ( ax * vx ) + vw - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VY]), m.mV[VY])); - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VZ]), m.mV[VZ])); -} - -// static -void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh) -{ - // This cannot be a file-level static because it will be initialized - // before main() using SSE code, which will crash on non-SSE processors. - static LLV4Matrix4 sJointMat[32]; - LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; - - //upload joint pivots/matrices - for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j ) - { - matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix, - joint_data[j]->mSkinJoint ? - joint_data[j]->mSkinJoint->mRootToJointSkinOffset - : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset); - } - - F32 weight = F32_MAX; - LLV4Matrix4 blend_mat; - - LLStrider<LLVector3> o_vertices; - LLStrider<LLVector3> o_normals; - - LLVertexBuffer *buffer = face->getVertexBuffer(); - buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); - buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); - - const F32* weights = mesh->getWeights(); - const LLVector3* coords = (const LLVector3*)mesh->getCoords(); - const LLVector3* normals = (const LLVector3*)mesh->getNormals(); - for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) - { - if( weight != weights[index]) - { - S32 joint = llfloor(weight = weights[index]); - blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); - } - blend_mat.multiply(coords[index], o_vertices[index]); - ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); - } - - buffer->flush(); -} - -#else - -void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh) -{ - LLViewerJointMesh::updateGeometryVectorized(face, mesh); -} - -#endif diff --git a/indra/newview/llviewerjointmesh_sse2.cpp b/indra/newview/llviewerjointmesh_sse2.cpp deleted file mode 100644 index c2296dd569..0000000000 --- a/indra/newview/llviewerjointmesh_sse2.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @file llviewerjointmesh_sse2.cpp - * @brief SSE vectorized joint skinning code, only used when video card does - * not support avatar vertex programs. - * - * *NOTE: Disabled on Windows builds. See llv4math.h for details. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// Visual Studio required settings for this file: -// Precompiled Headers OFF -// Code Generation: SSE2 - -//----------------------------------------------------------------------------- -// Header Files -//----------------------------------------------------------------------------- - -#include "llviewerprecompiledheaders.h" - -#include "llviewerjointmesh.h" - -// project includes -#include "llface.h" -#include "llpolymesh.h" - -// library includes -#include "lldarray.h" -#include "llstrider.h" -#include "llv4math.h" // for LL_VECTORIZE -#include "llv4matrix3.h" -#include "llv4matrix4.h" -#include "m4math.h" -#include "v3math.h" - - -#if LL_VECTORIZE - - -inline void matrix_translate(LLV4Matrix4& m, const LLMatrix4* w, const LLVector3& j) -{ - m.mV[VX] = _mm_loadu_ps(w->mMatrix[VX]); - m.mV[VY] = _mm_loadu_ps(w->mMatrix[VY]); - m.mV[VZ] = _mm_loadu_ps(w->mMatrix[VZ]); - m.mV[VW] = _mm_loadu_ps(w->mMatrix[VW]); - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VX]), m.mV[VX])); // ( ax * vx ) + vw - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VY]), m.mV[VY])); - m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VZ]), m.mV[VZ])); -} - -// static -void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh) -{ - // This cannot be a file-level static because it will be initialized - // before main() using SSE code, which will crash on non-SSE processors. - static LLV4Matrix4 sJointMat[32]; - LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; - - //upload joint pivots/matrices - for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j ) - { - matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix, - joint_data[j]->mSkinJoint ? - joint_data[j]->mSkinJoint->mRootToJointSkinOffset - : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset); - } - - F32 weight = F32_MAX; - LLV4Matrix4 blend_mat; - - LLStrider<LLVector3> o_vertices; - LLStrider<LLVector3> o_normals; - - LLVertexBuffer *buffer = face->getVertexBuffer(); - buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); - buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); - - const F32* weights = mesh->getWeights(); - const LLVector3* coords = (const LLVector3*)mesh->getCoords(); - const LLVector3* normals = (const LLVector3*)mesh->getNormals(); - for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) - { - if( weight != weights[index]) - { - S32 joint = llfloor(weight = weights[index]); - blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); - } - blend_mat.multiply(coords[index], o_vertices[index]); - ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); - } - - //setBuffer(0) called in LLVOAvatar::renderSkinned -} - -#else - -void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh) -{ - LLViewerJointMesh::updateGeometryVectorized(face, mesh); -} - -#endif diff --git a/indra/newview/llviewerjointmesh_vec.cpp b/indra/newview/llviewerjointmesh_vec.cpp deleted file mode 100644 index a8713b6f05..0000000000 --- a/indra/newview/llviewerjointmesh_vec.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file llviewerjointmesh_vec.cpp - * @brief Compiler-generated vectorized joint skinning code, works well on - * Altivec processors (PowerPC Mac) - * - * *NOTE: See llv4math.h for notes on SSE/Altivec vector code. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -//----------------------------------------------------------------------------- -// Header Files -//----------------------------------------------------------------------------- -#include "llviewerprecompiledheaders.h" - -#include "llviewerjointmesh.h" - -#include "llface.h" -#include "llpolymesh.h" -#include "llv4math.h" -#include "llv4matrix3.h" -#include "llv4matrix4.h" - -// Generic vectorized code, uses compiler defaults, works well for Altivec -// on PowerPC. - -// static -void LLViewerJointMesh::updateGeometryVectorized(LLFace *face, LLPolyMesh *mesh) -{ -#if 0 - static LLV4Matrix4 sJointMat[32]; - LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; - S32 j, joint_num, joint_end = joint_data.count(); - LLV4Vector3 pivot; - - //upload joint pivots/matrices - for(j = joint_num = 0; joint_num < joint_end ; ++joint_num ) - { - LLSkinJoint *sj; - const LLMatrix4 * wm = joint_data[joint_num]->mWorldMatrix; - if (NULL == (sj = joint_data[joint_num]->mSkinJoint)) - { - sj = joint_data[++joint_num]->mSkinJoint; - ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToParentJointSkinOffset, pivot); - sJointMat[j++].translate(pivot); - wm = joint_data[joint_num]->mWorldMatrix; - } - ((LLV4Matrix3)(sJointMat[j] = *wm)).multiply(sj->mRootToJointSkinOffset, pivot); - sJointMat[j++].translate(pivot); - } - - F32 weight = F32_MAX; - LLV4Matrix4 blend_mat; - - LLStrider<LLVector3> o_vertices; - LLStrider<LLVector3> o_normals; - - LLVertexBuffer *buffer = face->mVertexBuffer; - buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); - buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); - - const F32* weights = mesh->getWeights(); - const LLVector3* coords = mesh->getCoords(); - const LLVector3* normals = mesh->getNormals(); - for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) - { - if( weight != weights[index]) - { - S32 joint = llfloor(weight = weights[index]); - blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); - } - blend_mat.multiply(coords[index], o_vertices[index]); - ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); - } - - buffer->flush(); -#endif -} diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 22d95563d8..9fbc28a5e1 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1038,26 +1038,6 @@ class LLAdvancedCheckRandomizeFramerate : public view_listener_t } }; -void run_vectorize_perf_test(void *) -{ - gSavedSettings.setBOOL("VectorizePerfTest", TRUE); -} - - -//////////////////////////////// -// RUN Vectorized Perform Test// -//////////////////////////////// - - -class LLAdvancedVectorizePerfTest : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - run_vectorize_perf_test(NULL); - return true; - } -}; - /////////////////////////// //// PERIODIC SLOW FRAME // /////////////////////////// @@ -8117,7 +8097,6 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedCheckRandomizeFramerate(), "Advanced.CheckRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedTogglePeriodicSlowFrame(), "Advanced.TogglePeriodicSlowFrame"); view_listener_t::addMenu(new LLAdvancedCheckPeriodicSlowFrame(), "Advanced.CheckPeriodicSlowFrame"); - view_listener_t::addMenu(new LLAdvancedVectorizePerfTest(), "Advanced.VectorizePerfTest"); view_listener_t::addMenu(new LLAdvancedToggleFrameTest(), "Advanced.ToggleFrameTest"); view_listener_t::addMenu(new LLAdvancedCheckFrameTest(), "Advanced.CheckFrameTest"); view_listener_t::addMenu(new LLAdvancedHandleAttachedLightParticles(), "Advanced.HandleAttachedLightParticles"); |