aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerjointmesh_sse2.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/newview/llviewerjointmesh_sse2.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llviewerjointmesh_sse2.cpp121
1 files changed, 121 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..27aab80
--- /dev/null
+++ b/linden/indra/newview/llviewerjointmesh_sse2.cpp
@@ -0,0 +1,121 @@
1/**
2 * @file llviewerjointmesh_sse2.cpp
3 * @brief SSE vectorized joint skinning code, only used when video card does
4 * not support avatar vertex programs.
5 *
6 * *NOTE: Disabled on Windows builds. See llv4math.h for details.
7 *
8 * Copyright (c) 2007-2007, Linden Research, Inc.
9 *
10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab
12 * to you under the terms of the GNU General Public License, version 2.0
13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlife.com/developers/opensource/gplv2
17 *
18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at http://secondlife.com/developers/opensource/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 */
31
32// Visual Studio required settings for this file:
33// Precompiled Headers OFF
34// Code Generation: SSE2
35
36//-----------------------------------------------------------------------------
37// Header Files
38//-----------------------------------------------------------------------------
39
40#include "llviewerprecompiledheaders.h"
41
42#include "llviewerjointmesh.h"
43
44// project includes
45#include "llface.h"
46#include "llpolymesh.h"
47
48// library includes
49#include "lldarray.h"
50#include "llstrider.h"
51#include "llv4math.h" // for LL_VECTORIZE
52#include "llv4matrix3.h"
53#include "llv4matrix4.h"
54#include "m4math.h"
55#include "v3math.h"
56
57
58#if LL_VECTORIZE
59
60
61inline void matrix_translate(LLV4Matrix4& m, const LLMatrix4* w, const LLVector3& j)
62{
63 m.mV[VX] = _mm_loadu_ps(w->mMatrix[VX]);
64 m.mV[VY] = _mm_loadu_ps(w->mMatrix[VY]);
65 m.mV[VZ] = _mm_loadu_ps(w->mMatrix[VZ]);
66 m.mV[VW] = _mm_loadu_ps(w->mMatrix[VW]);
67 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VX]), m.mV[VX])); // ( ax * vx ) + vw
68 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VY]), m.mV[VY]));
69 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VZ]), m.mV[VZ]));
70}
71
72// static
73void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh)
74{
75 // This cannot be a file-level static because it will be initialized
76 // before main() using SSE code, which will crash on non-SSE processors.
77 static LLV4Matrix4 sJointMat[32];
78 LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData;
79
80 //upload joint pivots/matrices
81 for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j )
82 {
83 matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix,
84 joint_data[j]->mSkinJoint ?
85 joint_data[j]->mSkinJoint->mRootToJointSkinOffset
86 : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset);
87 }
88
89 F32 weight = F32_MAX;
90 LLV4Matrix4 blend_mat;
91
92 LLStrider<LLVector3> o_vertices;
93 LLStrider<LLVector3> o_normals;
94
95 LLVertexBuffer *buffer = face->mVertexBuffer;
96 buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset);
97 buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset);
98
99 const F32* weights = mesh->getWeights();
100 const LLVector3* coords = mesh->getCoords();
101 const LLVector3* normals = mesh->getNormals();
102 for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
103 {
104 if( weight != weights[index])
105 {
106 S32 joint = llfloor(weight = weights[index]);
107 blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint);
108 }
109 blend_mat.multiply(coords[index], o_vertices[index]);
110 ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]);
111 }
112}
113
114#else
115
116void LLViewerJointMesh::updateGeometrySSE2(LLFace *face, LLPolyMesh *mesh)
117{
118 LLViewerJointMesh::updateGeometryVectorized(face, mesh);
119}
120
121#endif