Annotation of /trunk/indra/newview/llviewerjointmesh_sse.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llviewerjointmesh_sse.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 : | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
| 9 : | * | ||
| 10 : | mjm | 137 | * Copyright (c) 2007-2010, Linden Research, Inc. |
| 11 : | mjm | 135 | * |
| 12 : | * Second Life Viewer Source Code | ||
| 13 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 14 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 15 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 16 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 17 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 18 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 19 : | * | ||
| 20 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 21 : | * it is applied to this Source Code. View the full text of the exception | ||
| 22 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 23 : | * online at | ||
| 24 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 25 : | * | ||
| 26 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 27 : | * that you have read and understood your obligations described above, | ||
| 28 : | * and agree to abide by those obligations. | ||
| 29 : | * | ||
| 30 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 31 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 32 : | * COMPLETENESS OR PERFORMANCE. | ||
| 33 : | * $/LicenseInfo$ | ||
| 34 : | */ | ||
| 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 "llv4math.h" // for LL_VECTORIZE | ||
| 51 : | #include "llv4matrix3.h" | ||
| 52 : | #include "llv4matrix4.h" | ||
| 53 : | #include "v3math.h" | ||
| 54 : | |||
| 55 : | |||
| 56 : | #if LL_VECTORIZE | ||
| 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::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh) | ||
| 71 : | { | ||
| 72 : | // This cannot be a file-level static because it will be initialized | ||
| 73 : | // before main() using SSE code, which will crash on non-SSE processors. | ||
| 74 : | static LLV4Matrix4 sJointMat[32]; | ||
| 75 : | LLDynamicArray<LLJointRenderData*>& joint_data = mesh->getReferenceMesh()->mJointRenderData; | ||
| 76 : | |||
| 77 : | //upload joint pivots/matrices | ||
| 78 : | for(S32 j = 0, jend = joint_data.count(); j < jend ; ++j ) | ||
| 79 : | { | ||
| 80 : | matrix_translate(sJointMat[j], joint_data[j]->mWorldMatrix, | ||
| 81 : | joint_data[j]->mSkinJoint ? | ||
| 82 : | joint_data[j]->mSkinJoint->mRootToJointSkinOffset | ||
| 83 : | : joint_data[j+1]->mSkinJoint->mRootToParentJointSkinOffset); | ||
| 84 : | } | ||
| 85 : | |||
| 86 : | F32 weight = F32_MAX; | ||
| 87 : | LLV4Matrix4 blend_mat; | ||
| 88 : | |||
| 89 : | LLStrider<LLVector3> o_vertices; | ||
| 90 : | LLStrider<LLVector3> o_normals; | ||
| 91 : | |||
| 92 : | LLVertexBuffer *buffer = face->mVertexBuffer; | ||
| 93 : | buffer->getVertexStrider(o_vertices, mesh->mFaceVertexOffset); | ||
| 94 : | buffer->getNormalStrider(o_normals, mesh->mFaceVertexOffset); | ||
| 95 : | |||
| 96 : | const F32* weights = mesh->getWeights(); | ||
| 97 : | const LLVector3* coords = mesh->getCoords(); | ||
| 98 : | const LLVector3* normals = mesh->getNormals(); | ||
| 99 : | for (U32 index = 0, index_end = mesh->getNumVertices(); index < index_end; ++index) | ||
| 100 : | { | ||
| 101 : | if( weight != weights[index]) | ||
| 102 : | { | ||
| 103 : | S32 joint = llfloor(weight = weights[index]); | ||
| 104 : | blend_mat.lerp(sJointMat[joint], sJointMat[joint+1], weight - joint); | ||
| 105 : | } | ||
| 106 : | blend_mat.multiply(coords[index], o_vertices[index]); | ||
| 107 : | ((LLV4Matrix3)blend_mat).multiply(normals[index], o_normals[index]); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | buffer->setBuffer(0); | ||
| 111 : | } | ||
| 112 : | |||
| 113 : | #else | ||
| 114 : | |||
| 115 : | void LLViewerJointMesh::updateGeometrySSE(LLFace *face, LLPolyMesh *mesh) | ||
| 116 : | { | ||
| 117 : | LLViewerJointMesh::updateGeometryVectorized(face, mesh); | ||
| 118 : | } | ||
| 119 : | |||
| 120 : | #endif |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

