aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerjointmesh_sse.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:01 -0500
committerJacek Antonelli2008-08-15 23:45:01 -0500
commit28d8d4e7664bcd6c8369cc18832e42096af7cad2 (patch)
tree069020fe66339aff2ca4176370ff743b14713f2d /linden/indra/newview/llviewerjointmesh_sse.cpp
parentSecond Life viewer sources 1.17.2.0 (diff)
downloadmeta-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 '')
-rw-r--r--linden/indra/newview/llviewerjointmesh_sse.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerjointmesh_sse.cpp b/linden/indra/newview/llviewerjointmesh_sse.cpp
new file mode 100644
index 0000000..4e30ce1
--- /dev/null
+++ b/linden/indra/newview/llviewerjointmesh_sse.cpp
@@ -0,0 +1,114 @@
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 "llv4math.h" // for LL_VECTORIZE
46#include "llv4matrix3.h"
47#include "llv4matrix4.h"
48#include "v3math.h"
49
50// *NOTE: SSE must be enabled for this module
51
52#if LL_VECTORIZE
53
54static LLV4Matrix4 sJointMat[32];
55
56inline void matrix_translate(LLV4Matrix4& m, const LLMatrix4* w, const LLVector3& j)
57{
58 m.mV[VX] = _mm_loadu_ps(w->mMatrix[VX]);
59 m.mV[VY] = _mm_loadu_ps(w->mMatrix[VY]);
60 m.mV[VZ] = _mm_loadu_ps(w->mMatrix[VZ]);
61 m.mV[VW] = _mm_loadu_ps(w->mMatrix[VW]);
62 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VX]), m.mV[VX])); // ( ax * vx ) + vw
63 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VY]), m.mV[VY]));
64 m.mV[VW] = _mm_add_ps(m.mV[VW], _mm_mul_ps(_mm_set1_ps(j.mV[VZ]), m.mV[VZ]));
65}
66
67// static
68void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh)
69{
70 LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData;
71
72 //upload joint pivots/matrices
73 for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j )
74 {
75 matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix,
76 joint_data[j]->mSkinJoint ?
77 joint_data[j]->mSkinJoint->mRootToJointSkinOffset
78 : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset);
79 }
80
81 F32 weight = F32_MAX;
82 LLV4Matrix4 blend_mat;
83
84 LLStrider<LLVector3> o_vertices;
85 LLStrider<LLVector3> o_normals;
86
87 LLVertexBuffer *buffer = face->mVertexBuffer;
88 buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset);
89 buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset);
90
91 const F32* weights = mesh->getWeights();
92 const LLVector3* coords = mesh->getCoords();
93 const LLVector3* normals = mesh->getNormals();
94 for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index)
95 {
96 if( weight != weights[index])
97 {
98 S32 joint = llfloor(weight = weights[index]);
99 blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint);
100 }
101 blend_mat.multiply(coords[index], o_vertices[index]);
102 ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]);
103 }
104}
105
106#else
107
108void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh)
109{
110 LLViewerJointMesh::updateGeometryVectorized(face, mesh);
111 return;
112}
113
114#endif