Add CColor::rgbDot()

This commit is contained in:
Jack Andersen 2017-04-13 09:27:59 -10:00
parent 39e240bf25
commit 5db81ca788
1 changed files with 18 additions and 0 deletions

View File

@ -290,6 +290,24 @@ public:
#endif
}
inline float rgbDot(const CColor& rhs) const
{
#if __SSE__
TVectorUnion result;
#if __SSE4_1__ || __SSE4_2__
if (cpuFeatures().SSE41 || cpuFeatures().SSE42)
{
result.mVec128 = _mm_dp_ps(mVec128, rhs.mVec128, 0x71);
return result.v[0];
}
#endif
result.mVec128 = _mm_mul_ps(mVec128, rhs.mVec128);
return result.v[0] + result.v[1] + result.v[2];
#else
return (r * rhs.r) + (g * rhs.g) + (b * rhs.b);
#endif
}
union {
struct
{