• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref core
2/// @file glm/detail/func_geometric_simd.inl
3
4#include "../simd/geometric.h"
5
6#if GLM_ARCH & GLM_ARCH_SSE2_BIT
7
8namespace glm{
9namespace detail
10{
11	template <precision P>
12	struct compute_length<tvec4, float, P, true>
13	{
14		GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const & v)
15		{
16			return _mm_cvtss_f32(glm_vec4_length(v.data));
17		}
18	};
19
20	template <precision P>
21	struct compute_distance<tvec4, float, P, true>
22	{
23		GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const & p0, tvec4<float, P> const & p1)
24		{
25			return _mm_cvtss_f32(glm_vec4_distance(p0.data, p1.data));
26		}
27	};
28
29	template <precision P>
30	struct compute_dot<tvec4, float, P, true>
31	{
32		GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const& x, tvec4<float, P> const& y)
33		{
34			return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data));
35		}
36	};
37
38	template <precision P>
39	struct compute_cross<float, P, true>
40	{
41		GLM_FUNC_QUALIFIER static tvec3<float, P> call(tvec3<float, P> const & a, tvec3<float, P> const & b)
42		{
43			__m128 const set0 = _mm_set_ps(0.0f, a.z, a.y, a.x);
44			__m128 const set1 = _mm_set_ps(0.0f, b.z, b.y, b.x);
45			__m128 const xpd0 = glm_vec4_cross(set0, set1);
46
47			tvec4<float, P> result(uninitialize);
48			result.data = xpd0;
49			return tvec3<float, P>(result);
50		}
51	};
52
53	template <precision P>
54	struct compute_normalize<float, P, tvec4, true>
55	{
56		GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
57		{
58			tvec4<float, P> result(uninitialize);
59			result.data = glm_vec4_normalize(v.data);
60			return result;
61		}
62	};
63
64	template <precision P>
65	struct compute_faceforward<float, P, tvec4, true>
66	{
67		GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& N, tvec4<float, P> const& I, tvec4<float, P> const& Nref)
68		{
69			tvec4<float, P> result(uninitialize);
70			result.data = glm_vec4_faceforward(N.data, I.data, Nref.data);
71			return result;
72		}
73	};
74
75	template <precision P>
76	struct compute_reflect<float, P, tvec4, true>
77	{
78		GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& I, tvec4<float, P> const& N)
79		{
80			tvec4<float, P> result(uninitialize);
81			result.data = glm_vec4_reflect(I.data, N.data);
82			return result;
83		}
84	};
85
86	template <precision P>
87	struct compute_refract<float, P, tvec4, true>
88	{
89		GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& I, tvec4<float, P> const& N, float eta)
90		{
91			tvec4<float, P> result(uninitialize);
92			result.data = glm_vec4_refract(I.data, N.data, _mm_set1_ps(eta));
93			return result;
94		}
95	};
96}//namespace detail
97}//namespace glm
98
99#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
100