diff options
author | Jacek Antonelli | 2008-08-15 23:45:01 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:01 -0500 |
commit | 28d8d4e7664bcd6c8369cc18832e42096af7cad2 (patch) | |
tree | 069020fe66339aff2ca4176370ff743b14713f2d /linden/indra/newview/llviewerjointmesh_sse2.cpp | |
parent | Second Life viewer sources 1.17.2.0 (diff) | |
download | meta-impy-28d8d4e7664bcd6c8369cc18832e42096af7cad2.zip meta-impy-28d8d4e7664bcd6c8369cc18832e42096af7cad2.tar.gz meta-impy-28d8d4e7664bcd6c8369cc18832e42096af7cad2.tar.bz2 meta-impy-28d8d4e7664bcd6c8369cc18832e42096af7cad2.tar.xz |
Second Life viewer sources 1.17.3.0
Diffstat (limited to 'linden/indra/newview/llviewerjointmesh_sse2.cpp')
-rw-r--r-- | linden/indra/newview/llviewerjointmesh_sse2.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerjointmesh_sse2.cpp b/linden/indra/newview/llviewerjointmesh_sse2.cpp new file mode 100644 index 0000000..1c205ae --- /dev/null +++ b/linden/indra/newview/llviewerjointmesh_sse2.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | /** | ||
2 | * @file llviewerjointmesh.cpp | ||
3 | * @brief LLV4 class implementation with LLViewerJointMesh class | ||
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 | //----------------------------------------------------------------------------- | ||
30 | // Header Files | ||
31 | //----------------------------------------------------------------------------- | ||
32 | |||
33 | // Do not use precompiled headers, because we need to build this file with | ||
34 | // SSE support, but not the precompiled header file. JC | ||
35 | #include "linden_common.h" | ||
36 | |||
37 | #include "llviewerjointmesh.h" | ||
38 | |||
39 | // project includes | ||
40 | #include "llface.h" | ||
41 | #include "llpolymesh.h" | ||
42 | |||
43 | // library includes | ||
44 | #include "lldarray.h" | ||
45 | #include "llstrider.h" | ||
46 | #include "llv4math.h" // for LL_VECTORIZE | ||
47 | #include "llv4matrix3.h" | ||
48 | #include "llv4matrix4.h" | ||
49 | #include "m4math.h" | ||
50 | #include "v3math.h" | ||
51 | |||
52 | // *NOTE: SSE2 must be enabled for this module | ||
53 | |||
54 | #if LL_VECTORIZE | ||
55 | |||
56 | static LLV4Matrix4 sJointMat[32]; | ||
57 | |||
58 | inline void matrix_translate(LLV4Matrix4& m, const LLMatrix4* w, const LLVector3& j) | ||
59 | { | ||
60 | m.mV[VX] = _mm_loadu_ps(w->mMatrix[VX]); | ||
61 | m.mV[VY] = _mm_loadu_ps(w->mMatrix[VY]); | ||
62 | m.mV[VZ] = _mm_loadu_ps(w->mMatrix[VZ]); | ||
63 | m.mV[VW] = _mm_loadu_ps(w->mMatrix[VW]); | ||
64 | m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VX]), m.mV[VX])); // ( ax * vx ) + vw | ||
65 | m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VY]), m.mV[VY])); | ||
66 | m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VZ]), m.mV[VZ])); | ||
67 | } | ||
68 | |||
69 | // static | ||
70 | void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh) | ||
71 | { | ||
72 | LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; | ||
73 | |||
74 | //upload joint pivots/matrices | ||
75 | for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j ) | ||
76 | { | ||
77 | matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix, | ||
78 | joint_data[j]->mSkinJoint ? | ||
79 | joint_data[j]->mSkinJoint->mRootToJointSkinOffset | ||
80 | : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset); | ||
81 | } | ||
82 | |||
83 | F32 weight = F32_MAX; | ||
84 | LLV4Matrix4 blend_mat; | ||
85 | |||
86 | LLStrider<LLVector3> o_vertices; | ||
87 | LLStrider<LLVector3> o_normals; | ||
88 | |||
89 | LLVertexBuffer *buffer = face->mVertexBuffer; | ||
90 | buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); | ||
91 | buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); | ||
92 | |||
93 | const F32* weights = mesh->getWeights(); | ||
94 | const LLVector3* coords = mesh->getCoords(); | ||
95 | const LLVector3* normals = mesh->getNormals(); | ||
96 | for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) | ||
97 | { | ||
98 | if( weight != weights[index]) | ||
99 | { | ||
100 | S32 joint = llfloor(weight = weights[index]); | ||
101 | blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); | ||
102 | } | ||
103 | blend_mat.multiply(coords[index], o_vertices[index]); | ||
104 | ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | #else | ||
109 | |||
110 | void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh) | ||
111 | { | ||
112 | LLViewerJointMesh::updateGeometryVectorized(face, mesh); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | #endif | ||