diff --git a/src/tenvex/expressions/core.h b/src/tenvex/expressions/core.h index 813e718..50ef0d7 100644 --- a/src/tenvex/expressions/core.h +++ b/src/tenvex/expressions/core.h @@ -66,13 +66,19 @@ vf4 div(vf4 l, vf4 r) noexcept [[nodiscard]] TNVX_INLINE vf4 dot3(vf4 l, vf4 r) noexcept { - return _mm_dp_ps(l, r, 0b01111111); + //return _mm_dp_ps(l, r, 0b01111111); + vf4 t = _mm_mul_ps(l, r); + vf4 ty = _mm_shuffle_ps(t, t, _MM_SHUFFLE(1, 1, 1, 1)); + vf4 xy = _mm_add_ss(t, ty); + vf4 tz = _mm_movehl_ps(t, t); + vf4 xyz = _mm_add_ss(xy, tz); + return _mm_shuffle_ps(xyz, xyz, _MM_SHUFFLE(0, 0, 0, 0)); } [[nodiscard]] TNVX_INLINE vf4 magnitude3(vf4 v) noexcept { - return _mm_sqrt_ps(_mm_dp_ps(v, v, 0b01111111)); + return _mm_sqrt_ps(dot3(v, v)); } [[nodiscard]] TNVX_INLINE diff --git a/src/tenvex/expressions/vec4.h b/src/tenvex/expressions/vec4.h index 30be4e7..82960ec 100644 --- a/src/tenvex/expressions/vec4.h +++ b/src/tenvex/expressions/vec4.h @@ -35,6 +35,9 @@ struct alignas(16) vec4 : Expr [[nodiscard]] TNVX_INLINE vf4 eval() const noexcept; + [[nodiscard]] TNVX_INLINE + vec4 operator-() const noexcept; + private: vf4 _data;