summaryrefslogtreecommitdiff
path: root/indra/llmath/llmatrix4a.h
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2016-12-05 15:20:27 -0500
committerOz Linden <oz@lindenlab.com>2016-12-05 15:20:27 -0500
commitc21571474c0022f83a4efc28d59e97fc020fd0e7 (patch)
tree15586cbd2055a1c84dad4ce2f74efe1a885d997d /indra/llmath/llmatrix4a.h
parentfd2ccb16068dfd21307b17e78e384d8ae19fef12 (diff)
parent68413474c4479eee9bdbeb34ea131475ba1d646e (diff)
merge changes for 5.0.0-release
Diffstat (limited to 'indra/llmath/llmatrix4a.h')
-rw-r--r--indra/llmath/llmatrix4a.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h
index d141298f69..216334752a 100644
--- a/indra/llmath/llmatrix4a.h
+++ b/indra/llmath/llmatrix4a.h
@@ -121,7 +121,7 @@ public:
res.add(z);
}
- inline void affineTransform(const LLVector4a& v, LLVector4a& res)
+ inline void affineTransformSSE(const LLVector4a& v, LLVector4a& res)
{
LLVector4a x,y,z;
@@ -137,6 +137,43 @@ public:
z.add(mMatrix[3]);
res.setAdd(x,z);
}
+
+ inline void affineTransformNonSSE(const LLVector4a& v, LLVector4a& res)
+ {
+ F32 x = v[0] * mMatrix[0][0] + v[1] * mMatrix[1][0] + v[2] * mMatrix[2][0] + mMatrix[3][0];
+ F32 y = v[0] * mMatrix[0][1] + v[1] * mMatrix[1][1] + v[2] * mMatrix[2][1] + mMatrix[3][1];
+ F32 z = v[0] * mMatrix[0][2] + v[1] * mMatrix[1][2] + v[2] * mMatrix[2][2] + mMatrix[3][2];
+ F32 w = 1.0f;
+ res.set(x,y,z,w);
+ }
+
+ inline void affineTransform(const LLVector4a& v, LLVector4a& res)
+ {
+ affineTransformSSE(v,res);
+ }
};
+inline LLVector4a rowMul(const LLVector4a &row, const LLMatrix4a &mat)
+{
+ LLVector4a result;
+ result = _mm_mul_ps(_mm_shuffle_ps(row, row, _MM_SHUFFLE(0, 0, 0, 0)), mat.mMatrix[0]);
+ result = _mm_add_ps(result, _mm_mul_ps(_mm_shuffle_ps(row, row, _MM_SHUFFLE(1, 1, 1, 1)), mat.mMatrix[1]));
+ result = _mm_add_ps(result, _mm_mul_ps(_mm_shuffle_ps(row, row, _MM_SHUFFLE(2, 2, 2, 2)), mat.mMatrix[2]));
+ result = _mm_add_ps(result, _mm_mul_ps(_mm_shuffle_ps(row, row, _MM_SHUFFLE(3, 3, 3, 3)), mat.mMatrix[3]));
+ return result;
+}
+
+inline void matMul(const LLMatrix4a &a, const LLMatrix4a &b, LLMatrix4a &res)
+{
+ LLVector4a row0 = rowMul(a.mMatrix[0], b);
+ LLVector4a row1 = rowMul(a.mMatrix[1], b);
+ LLVector4a row2 = rowMul(a.mMatrix[2], b);
+ LLVector4a row3 = rowMul(a.mMatrix[3], b);
+
+ res.mMatrix[0] = row0;
+ res.mMatrix[1] = row1;
+ res.mMatrix[2] = row2;
+ res.mMatrix[3] = row3;
+}
+
#endif