diff --git a/common/glm/glm/detail/func_common_simd.inl b/common/glm/glm/detail/func_common_simd.inl new file mode 100644 index 000000000..c76f18020 --- /dev/null +++ b/common/glm/glm/detail/func_common_simd.inl @@ -0,0 +1,231 @@ +/// @ref core +/// @file glm/detail/func_common_simd.inl + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +#include "../simd/common.h" + +#include + +namespace glm{ +namespace detail +{ + template + struct compute_abs_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_abs(v.data); + return result; + } + }; + + template + struct compute_abs_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_ivec4_abs(v.data); + return result; + } + }; + + template + struct compute_floor + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_floor(v.data); + return result; + } + }; + + template + struct compute_ceil + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_ceil(v.data); + return result; + } + }; + + template + struct compute_fract + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_fract(v.data); + return result; + } + }; + + template + struct compute_round + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_round(v.data); + return result; + } + }; + + template + struct compute_mod + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & x, tvec4 const & y) + { + tvec4 result(uninitialize); + result.data = glm_vec4_mod(x.data, y.data); + return result; + } + }; + + template + struct compute_min_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_min_ps(v1.data, v2.data); + return result; + } + }; + + template + struct compute_min_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_min_epi32(v1.data, v2.data); + return result; + } + }; + + template + struct compute_min_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_min_epu32(v1.data, v2.data); + return result; + } + }; + + template + struct compute_max_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_max_ps(v1.data, v2.data); + return result; + } + }; + + template + struct compute_max_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_max_epi32(v1.data, v2.data); + return result; + } + }; + + template + struct compute_max_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v1, tvec4 const & v2) + { + tvec4 result(uninitialize); + result.data = _mm_max_epu32(v1.data, v2.data); + return result; + } + }; + + template + struct compute_clamp_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & x, tvec4 const & minVal, tvec4 const & maxVal) + { + tvec4 result(uninitialize); + result.data = _mm_min_ps(_mm_max_ps(x.data, minVal.data), maxVal.data); + return result; + } + }; + + template + struct compute_clamp_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & x, tvec4 const & minVal, tvec4 const & maxVal) + { + tvec4 result(uninitialize); + result.data = _mm_min_epi32(_mm_max_epi32(x.data, minVal.data), maxVal.data); + return result; + } + }; + + template + struct compute_clamp_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & x, tvec4 const & minVal, tvec4 const & maxVal) + { + tvec4 result(uninitialize); + result.data = _mm_min_epu32(_mm_max_epu32(x.data, minVal.data), maxVal.data); + return result; + } + }; + + template + struct compute_mix_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & x, tvec4 const & y, tvec4 const & a) + { + __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); + __m128 const Mask = _mm_castsi128_ps(Load); + + tvec4 Result(uninitialize); +# if 0 && GLM_ARCH & GLM_ARCH_AVX + Result.data = _mm_blendv_ps(x.data, y.data, Mask); +# else + Result.data = _mm_or_ps(_mm_and_ps(Mask, y.data), _mm_andnot_ps(Mask, x.data)); +# endif + return Result; + } + }; +/* FIXME + template + struct compute_step_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& edge, tvec4 const& x) + { + tvec4 result(uninitialize); + result.data = glm_vec4_step(edge.data, x.data); + return result; + } + }; +*/ + template + struct compute_smoothstep_vector + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& edge0, tvec4 const& edge1, tvec4 const& x) + { + tvec4 result(uninitialize); + result.data = glm_vec4_smoothstep(edge0.data, edge1.data, x.data); + return result; + } + }; +}//namespace detail +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/common/glm/glm/detail/func_exponential_simd.inl b/common/glm/glm/detail/func_exponential_simd.inl new file mode 100644 index 000000000..d7529ba35 --- /dev/null +++ b/common/glm/glm/detail/func_exponential_simd.inl @@ -0,0 +1,35 @@ +/// @ref core +/// @file glm/detail/func_exponential_simd.inl + +#include "../simd/exponential.h" + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +namespace glm{ +namespace detail +{ + template + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = _mm_sqrt_ps(v.data); + return result; + } + }; + + template <> + struct compute_sqrt + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_sqrt_lowp(v.data); + return result; + } + }; +}//namespace detail +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/common/glm/glm/detail/func_geometric_simd.inl b/common/glm/glm/detail/func_geometric_simd.inl new file mode 100644 index 000000000..f0d14a26e --- /dev/null +++ b/common/glm/glm/detail/func_geometric_simd.inl @@ -0,0 +1,99 @@ +/// @ref core +/// @file glm/detail/func_geometric_simd.inl + +#include "../simd/geometric.h" + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +namespace glm{ +namespace detail +{ + template + struct compute_length + { + GLM_FUNC_QUALIFIER static float call(tvec4 const & v) + { + return _mm_cvtss_f32(glm_vec4_length(v.data)); + } + }; + + template + struct compute_distance + { + GLM_FUNC_QUALIFIER static float call(tvec4 const & p0, tvec4 const & p1) + { + return _mm_cvtss_f32(glm_vec4_distance(p0.data, p1.data)); + } + }; + + template + struct compute_dot + { + GLM_FUNC_QUALIFIER static float call(tvec4 const& x, tvec4 const& y) + { + return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data)); + } + }; + + template + struct compute_cross + { + GLM_FUNC_QUALIFIER static tvec3 call(tvec3 const & a, tvec3 const & b) + { + __m128 const set0 = _mm_set_ps(0.0f, a.z, a.y, a.x); + __m128 const set1 = _mm_set_ps(0.0f, b.z, b.y, b.x); + __m128 const xpd0 = glm_vec4_cross(set0, set1); + + tvec4 result(uninitialize); + result.data = xpd0; + return tvec3(result); + } + }; + + template + struct compute_normalize + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v) + { + tvec4 result(uninitialize); + result.data = glm_vec4_normalize(v.data); + return result; + } + }; + + template + struct compute_faceforward + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& N, tvec4 const& I, tvec4 const& Nref) + { + tvec4 result(uninitialize); + result.data = glm_vec4_faceforward(N.data, I.data, Nref.data); + return result; + } + }; + + template + struct compute_reflect + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& I, tvec4 const& N) + { + tvec4 result(uninitialize); + result.data = glm_vec4_reflect(I.data, N.data); + return result; + } + }; + + template + struct compute_refract + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& I, tvec4 const& N, float eta) + { + tvec4 result(uninitialize); + result.data = glm_vec4_refract(I.data, N.data, _mm_set1_ps(eta)); + return result; + } + }; +}//namespace detail +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/common/glm/glm/detail/func_integer_simd.inl b/common/glm/glm/detail/func_integer_simd.inl new file mode 100644 index 000000000..617586049 --- /dev/null +++ b/common/glm/glm/detail/func_integer_simd.inl @@ -0,0 +1,68 @@ +/// @ref core +/// @file glm/detail/func_integer_simd.inl + +#include "../simd/integer.h" + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +namespace glm{ +namespace detail +{ + template + struct compute_bitfieldReverseStep + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v, uint32 Mask, uint32 Shift) + { + __m128i const set0 = v.data; + + __m128i const set1 = _mm_set1_epi32(Mask); + __m128i const and1 = _mm_and_si128(set0, set1); + __m128i const sft1 = _mm_slli_epi32(and1, Shift); + + __m128i const set2 = _mm_andnot_si128(set0, _mm_set1_epi32(-1)); + __m128i const and2 = _mm_and_si128(set0, set2); + __m128i const sft2 = _mm_srai_epi32(and2, Shift); + + __m128i const or0 = _mm_or_si128(sft1, sft2); + + return or0; + } + }; + + template + struct compute_bitfieldBitCountStep + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & v, uint32 Mask, uint32 Shift) + { + __m128i const set0 = v.data; + + __m128i const set1 = _mm_set1_epi32(Mask); + __m128i const and0 = _mm_and_si128(set0, set1); + __m128i const sft0 = _mm_slli_epi32(set0, Shift); + __m128i const and1 = _mm_and_si128(sft0, set1); + __m128i const add0 = _mm_add_epi32(and0, and1); + + return add0; + } + }; +}//namespace detail + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template <> + GLM_FUNC_QUALIFIER int bitCount(uint32 x) + { + return _mm_popcnt_u32(x); + } + +# if(GLM_MODEL == GLM_MODEL_64) + template <> + GLM_FUNC_QUALIFIER int bitCount(uint64 x) + { + return static_cast(_mm_popcnt_u64(x)); + } +# endif//GLM_MODEL +# endif//GLM_ARCH + +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/common/glm/glm/detail/func_matrix_simd.inl b/common/glm/glm/detail/func_matrix_simd.inl new file mode 100644 index 000000000..61b0a5ba9 --- /dev/null +++ b/common/glm/glm/detail/func_matrix_simd.inl @@ -0,0 +1,88 @@ +/// @ref core +/// @file glm/detail/func_matrix_simd.inl + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +#include "type_mat4x4.hpp" +#include "func_geometric.hpp" +#include "../simd/matrix.h" + +namespace glm{ +namespace detail +{ + template + struct compute_matrixCompMult + { + GLM_STATIC_ASSERT(detail::is_aligned

::value, "Specialization requires aligned"); + + GLM_FUNC_QUALIFIER static tmat4x4 call(tmat4x4 const & x, tmat4x4 const & y) + { + tmat4x4 result(uninitialize); + glm_mat4_matrixCompMult( + *(glm_vec4 const (*)[4])&x[0].data, + *(glm_vec4 const (*)[4])&y[0].data, + *(glm_vec4(*)[4])&result[0].data); + return result; + } + }; + + template + struct compute_transpose + { + GLM_FUNC_QUALIFIER static tmat4x4 call(tmat4x4 const & m) + { + tmat4x4 result(uninitialize); + glm_mat4_transpose( + *(glm_vec4 const (*)[4])&m[0].data, + *(glm_vec4(*)[4])&result[0].data); + return result; + } + }; + + template + struct compute_determinant + { + GLM_FUNC_QUALIFIER static float call(tmat4x4 const& m) + { + return _mm_cvtss_f32(glm_mat4_determinant(*reinterpret_cast<__m128 const(*)[4]>(&m[0].data))); + } + }; + + template + struct compute_inverse + { + GLM_FUNC_QUALIFIER static tmat4x4 call(tmat4x4 const& m) + { + tmat4x4 Result(uninitialize); + glm_mat4_inverse(*reinterpret_cast<__m128 const(*)[4]>(&m[0].data), *reinterpret_cast<__m128(*)[4]>(&Result[0].data)); + return Result; + } + }; +}//namespace detail + + template<> + GLM_FUNC_QUALIFIER tmat4x4 outerProduct(tvec4 const & c, tvec4 const & r) + { + tmat4x4 m(uninitialize); + glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data)); + return m; + } + + template<> + GLM_FUNC_QUALIFIER tmat4x4 outerProduct(tvec4 const & c, tvec4 const & r) + { + tmat4x4 m(uninitialize); + glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data)); + return m; + } + + template<> + GLM_FUNC_QUALIFIER tmat4x4 outerProduct(tvec4 const & c, tvec4 const & r) + { + tmat4x4 m(uninitialize); + glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data)); + return m; + } +}//namespace glm + +#endif diff --git a/common/glm/glm/detail/func_packing_simd.inl b/common/glm/glm/detail/func_packing_simd.inl new file mode 100644 index 000000000..1d4a5225d --- /dev/null +++ b/common/glm/glm/detail/func_packing_simd.inl @@ -0,0 +1,9 @@ +/// @ref core +/// @file glm/detail/func_packing_simd.inl + +namespace glm{ +namespace detail +{ + +}//namespace detail +}//namespace glm diff --git a/common/glm/glm/detail/func_trigonometric_simd.inl b/common/glm/glm/detail/func_trigonometric_simd.inl new file mode 100644 index 000000000..e69de29bb diff --git a/common/glm/glm/detail/func_vector_relational_simd.inl b/common/glm/glm/detail/func_vector_relational_simd.inl new file mode 100644 index 000000000..faab59b82 --- /dev/null +++ b/common/glm/glm/detail/func_vector_relational_simd.inl @@ -0,0 +1,9 @@ +/// @ref core +/// @file glm/detail/func_vector_relational_simd.inl + +namespace glm{ +namespace detail +{ + +}//namespace detail +}//namespace glm diff --git a/common/glm/glm/detail/type_mat4x4_simd.inl b/common/glm/glm/detail/type_mat4x4_simd.inl new file mode 100644 index 000000000..09d0b1f15 --- /dev/null +++ b/common/glm/glm/detail/type_mat4x4_simd.inl @@ -0,0 +1,7 @@ +/// @ref core +/// @file glm/detail/type_mat4x4_sse2.inl + +namespace glm +{ + +}//namespace glm diff --git a/common/glm/glm/detail/type_vec4_simd.inl b/common/glm/glm/detail/type_vec4_simd.inl new file mode 100644 index 000000000..90652fd91 --- /dev/null +++ b/common/glm/glm/detail/type_vec4_simd.inl @@ -0,0 +1,481 @@ +/// @ref core +/// @file glm/detail/type_tvec4_simd.inl + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +namespace glm{ +namespace detail +{ +# if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED + template + struct _swizzle_base1<4, float, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER tvec4 operator ()() const + { + __m128 data = *reinterpret_cast<__m128 const*>(&this->_buffer); + + tvec4 Result(uninitialize); +# if GLM_ARCH & GLM_ARCH_AVX_BIT + Result.data = _mm_permute_ps(data, _MM_SHUFFLE(E3, E2, E1, E0)); +# else + Result.data = _mm_shuffle_ps(data, data, _MM_SHUFFLE(E3, E2, E1, E0)); +# endif + return Result; + } + }; + + template + struct _swizzle_base1<4, int32, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER tvec4 operator ()() const + { + __m128i data = *reinterpret_cast<__m128i const*>(&this->_buffer); + + tvec4 Result(uninitialize); + Result.data = _mm_shuffle_epi32(data, _MM_SHUFFLE(E3, E2, E1, E0)); + return Result; + } + }; + + template + struct _swizzle_base1<4, uint32, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0 + { + GLM_FUNC_QUALIFIER tvec4 operator ()() const + { + __m128i data = *reinterpret_cast<__m128i const*>(&this->_buffer); + + tvec4 Result(uninitialize); + Result.data = _mm_shuffle_epi32(data, _MM_SHUFFLE(E3, E2, E1, E0)); + return Result; + } + }; +# endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED + + template + struct compute_vec4_add + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm_add_ps(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_vec4_add + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_add_pd(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_sub + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm_sub_ps(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_vec4_sub + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_sub_pd(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_mul + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm_mul_ps(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_vec4_mul + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_mul_pd(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_div + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm_div_ps(a.data, b.data); + return Result; + } + }; + + # if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_vec4_div + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_div_pd(a.data, b.data); + return Result; + } + }; +# endif + + template <> + struct compute_vec4_div + { + static tvec4 call(tvec4 const & a, tvec4 const & b) + { + tvec4 Result(uninitialize); + Result.data = _mm_mul_ps(a.data, _mm_rcp_ps(b.data)); + return Result; + } + }; + + template + struct compute_vec4_and + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm_and_si128(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_and + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_and_si256(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_or + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm_or_si128(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_or + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_or_si256(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_xor + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm_xor_si128(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_xor + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_xor_si256(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_shift_left + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm_sll_epi32(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_shift_left + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_sll_epi64(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_shift_right + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm_srl_epi32(a.data, b.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_shift_right + { + static tvec4 call(tvec4 const& a, tvec4 const& b) + { + tvec4 Result(uninitialize); + Result.data = _mm256_srl_epi64(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_vec4_bitwise_not + { + static tvec4 call(tvec4 const & v) + { + tvec4 Result(uninitialize); + Result.data = _mm_xor_si128(v.data, _mm_set1_epi32(-1)); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template + struct compute_vec4_bitwise_not + { + static tvec4 call(tvec4 const & v) + { + tvec4 Result(uninitialize); + Result.data = _mm256_xor_si256(v.data, _mm_set1_epi32(-1)); + return Result; + } + }; +# endif + + template + struct compute_vec4_equal + { + static bool call(tvec4 const & v1, tvec4 const & v2) + { + return _mm_movemask_ps(_mm_cmpeq_ps(v1.data, v2.data)) != 0; + } + }; + + template + struct compute_vec4_equal + { + static bool call(tvec4 const & v1, tvec4 const & v2) + { + return _mm_movemask_epi8(_mm_cmpeq_epi32(v1.data, v2.data)) != 0; + } + }; + + template + struct compute_vec4_nequal + { + static bool call(tvec4 const & v1, tvec4 const & v2) + { + return _mm_movemask_ps(_mm_cmpneq_ps(v1.data, v2.data)) != 0; + } + }; + + template + struct compute_vec4_nequal + { + static bool call(tvec4 const & v1, tvec4 const & v2) + { + return _mm_movemask_epi8(_mm_cmpneq_epi32(v1.data, v2.data)) != 0; + } + }; +}//namespace detail + +# if !GLM_HAS_DEFAULTED_FUNCTIONS + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4() +# ifndef GLM_FORCE_NO_CTOR_INIT + : data(_mm_setzero_ps()) +# endif + {} +# endif//!GLM_HAS_DEFAULTED_FUNCTIONS + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float s) : + data(_mm_set1_ps(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float s) : + data(_mm_set1_ps(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float s) : + data(_mm_set1_ps(s)) + {} + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(double s) : + data(_mm256_set1_pd(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(double s) : + data(_mm256_set1_pd(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(double s) : + data(_mm256_set1_pd(s)) + {} +# endif + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 s) : + data(_mm_set1_epi32(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 s) : + data(_mm_set1_epi32(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 s) : + data(_mm_set1_epi32(s)) + {} + +# if GLM_ARCH & GLM_ARCH_AVX2_BIT + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int64 s) : + data(_mm256_set1_epi64x(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int64 s) : + data(_mm256_set1_epi64x(s)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int64 s) : + data(_mm256_set1_epi64x(s)) + {} +# endif + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float a, float b, float c, float d) : + data(_mm_set_ps(d, c, b, a)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float a, float b, float c, float d) : + data(_mm_set_ps(d, c, b, a)) + {} + + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(float a, float b, float c, float d) : + data(_mm_set_ps(d, c, b, a)) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_set_epi32(d, c, b, a)) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_set_epi32(d, c, b, a)) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_set_epi32(d, c, b, a)) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a))) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a))) + {} + + template <> + template <> + GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4::tvec4(int32 a, int32 b, int32 c, int32 d) : + data(_mm_castsi128_ps(_mm_set_epi32(d, c, b, a))) + {} +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT diff --git a/common/glm/glm/gtc/color_encoding.inl b/common/glm/glm/gtc/color_encoding.inl new file mode 100644 index 000000000..68570cbbc --- /dev/null +++ b/common/glm/glm/gtc/color_encoding.inl @@ -0,0 +1,65 @@ +/// @ref gtc_color_encoding +/// @file glm/gtc/color_encoding.inl + +namespace glm +{ + template + GLM_FUNC_QUALIFIER tvec3 convertLinearSRGBToD65XYZ(tvec3 const& ColorLinearSRGB) + { + tvec3 const M(0.490f, 0.17697f, 0.2f); + tvec3 const N(0.31f, 0.8124f, 0.01063f); + tvec3 const O(0.490f, 0.01f, 0.99f); + + return (M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB) * static_cast(5.650675255693055f); + } + + template + GLM_FUNC_QUALIFIER tvec3 convertD65XYZToLinearSRGB(tvec3 const& ColorD65XYZ) + { + tvec3 const M(0.41847f, -0.091169f, 0.0009209f); + tvec3 const N(-0.15866f, 0.25243f, 0.015708f); + tvec3 const O(0.0009209f, -0.0025498f, 0.1786f); + + return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; + } + + template + GLM_FUNC_QUALIFIER tvec3 convertLinearSRGBToD50XYZ(tvec3 const& ColorLinearSRGB) + { + tvec3 const M(0.436030342570117f, 0.222438466210245f, 0.013897440074263f); + tvec3 const N(0.385101860087134f, 0.716942745571917f, 0.097076381494207f); + tvec3 const O(0.143067806654203f, 0.060618777416563f, 0.713926257896652f); + + return M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB; + } + + template + GLM_FUNC_QUALIFIER tvec3 convertD50XYZToLinearSRGB(tvec3 const& ColorD50XYZ) + { + tvec3 const M(); + tvec3 const N(); + tvec3 const O(); + + return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; + } + + template + GLM_FUNC_QUALIFIER tvec3 convertD65XYZToD50XYZ(tvec3 const& ColorD65XYZ) + { + tvec3 const M(+1.047844353856414f, +0.029549007606644f, -0.009250984365223f); + tvec3 const N(+0.022898981050086f, +0.990508028941971f, +0.015072338237051f); + tvec3 const O(-0.050206647741605f, -0.017074711360960f, +0.751717835079977f); + + return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ; + } + + template + GLM_FUNC_QUALIFIER tvec3 convertD50XYZToD65XYZ(tvec3 const& ColorD50XYZ) + { + tvec3 const M(); + tvec3 const N(); + tvec3 const O(); + + return M * ColorD50XYZ + N * ColorD50XYZ + O * ColorD50XYZ; + } +}//namespace glm diff --git a/common/glm/glm/gtc/color_space.hpp b/common/glm/glm/gtc/color_space.hpp new file mode 100644 index 000000000..08ece8f8a --- /dev/null +++ b/common/glm/glm/gtc/color_space.hpp @@ -0,0 +1,56 @@ +/// @ref gtc_color_space +/// @file glm/gtc/color_space.hpp +/// +/// @see core (dependence) +/// @see gtc_color_space (dependence) +/// +/// @defgroup gtc_color_space GLM_GTC_color_space +/// @ingroup gtc +/// +/// @brief Allow to perform bit operations on integer values +/// +/// need to be included to use these functionalities. + +#pragma once + +// Dependencies +#include "../detail/setup.hpp" +#include "../detail/precision.hpp" +#include "../exponential.hpp" +#include "../vec3.hpp" +#include "../vec4.hpp" +#include + +#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) +# pragma message("GLM: GLM_GTC_color_space extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_color_space + /// @{ + + /// Convert a linear color to sRGB color using a standard gamma correction. + /// IEC 61966-2-1:1999 specification https://www.w3.org/Graphics/Color/srgb + template class vecType> + GLM_FUNC_DECL vecType convertLinearToSRGB(vecType const & ColorLinear); + + /// Convert a linear color to sRGB color using a custom gamma correction. + /// IEC 61966-2-1:1999 specification https://www.w3.org/Graphics/Color/srgb + template class vecType> + GLM_FUNC_DECL vecType convertLinearToSRGB(vecType const & ColorLinear, T Gamma); + + /// Convert a sRGB color to linear color using a standard gamma correction. + /// IEC 61966-2-1:1999 specification https://www.w3.org/Graphics/Color/srgb + template class vecType> + GLM_FUNC_DECL vecType convertSRGBToLinear(vecType const & ColorSRGB); + + /// Convert a sRGB color to linear color using a custom gamma correction. + // IEC 61966-2-1:1999 specification https://www.w3.org/Graphics/Color/srgb + template class vecType> + GLM_FUNC_DECL vecType convertSRGBToLinear(vecType const & ColorSRGB, T Gamma); + + /// @} +} //namespace glm + +#include "color_space.inl" diff --git a/common/glm/glm/gtc/color_space.inl b/common/glm/glm/gtc/color_space.inl new file mode 100644 index 000000000..c9a44efcc --- /dev/null +++ b/common/glm/glm/gtc/color_space.inl @@ -0,0 +1,75 @@ +/// @ref gtc_color_space +/// @file glm/gtc/color_space.inl + +namespace glm{ +namespace detail +{ + template class vecType> + struct compute_rgbToSrgb + { + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorRGB, T GammaCorrection) + { + vecType const ClampedColor(clamp(ColorRGB, static_cast(0), static_cast(1))); + + return mix( + pow(ClampedColor, vecType(GammaCorrection)) * static_cast(1.055) - static_cast(0.055), + ClampedColor * static_cast(12.92), + lessThan(ClampedColor, vecType(static_cast(0.0031308)))); + } + }; + + template + struct compute_rgbToSrgb + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorRGB, T GammaCorrection) + { + return tvec4(compute_rgbToSrgb::call(tvec3(ColorRGB), GammaCorrection), ColorRGB.w); + } + }; + + template class vecType> + struct compute_srgbToRgb + { + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorSRGB, T Gamma) + { + return mix( + pow((ColorSRGB + static_cast(0.055)) * static_cast(0.94786729857819905213270142180095), vecType(Gamma)), + ColorSRGB * static_cast(0.07739938080495356037151702786378), + lessThanEqual(ColorSRGB, vecType(static_cast(0.04045)))); + } + }; + + template + struct compute_srgbToRgb + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorSRGB, T Gamma) + { + return tvec4(compute_srgbToRgb::call(tvec3(ColorSRGB), Gamma), ColorSRGB.w); + } + }; +}//namespace detail + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear) + { + return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(0.41666)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear, T Gamma) + { + return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(1) / Gamma); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB) + { + return detail::compute_srgbToRgb::call(ColorSRGB, static_cast(2.4)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB, T Gamma) + { + return detail::compute_srgbToRgb::call(ColorSRGB, Gamma); + } +}//namespace glm diff --git a/common/glm/glm/gtc/functions.hpp b/common/glm/glm/gtc/functions.hpp new file mode 100644 index 000000000..ab1590b49 --- /dev/null +++ b/common/glm/glm/gtc/functions.hpp @@ -0,0 +1,53 @@ +/// @ref gtc_functions +/// @file glm/gtc/functions.hpp +/// +/// @see core (dependence) +/// @see gtc_half_float (dependence) +/// @see gtc_quaternion (dependence) +/// +/// @defgroup gtc_functions GLM_GTC_functions +/// @ingroup gtc +/// +/// @brief List of useful common functions. +/// +/// need to be included to use these functionalities. + +#pragma once + +// Dependencies +#include "../detail/setup.hpp" +#include "../detail/precision.hpp" +#include "../detail/type_vec2.hpp" + +#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) +# pragma message("GLM: GLM_GTC_functions extension included") +#endif + +namespace glm +{ + /// @addtogroup gtc_functions + /// @{ + + /// 1D gauss function + /// + /// @see gtc_epsilon + template + GLM_FUNC_DECL T gauss( + T x, + T ExpectedValue, + T StandardDeviation); + + /// 2D gauss function + /// + /// @see gtc_epsilon + template + GLM_FUNC_DECL T gauss( + tvec2 const& Coord, + tvec2 const& ExpectedValue, + tvec2 const& StandardDeviation); + + /// @} +}//namespace glm + +#include "functions.inl" + diff --git a/common/glm/glm/gtc/functions.inl b/common/glm/glm/gtc/functions.inl new file mode 100644 index 000000000..1dbc4967b --- /dev/null +++ b/common/glm/glm/gtc/functions.inl @@ -0,0 +1,31 @@ +/// @ref gtc_functions +/// @file glm/gtc/functions.inl + +#include "../detail/func_exponential.hpp" + +namespace glm +{ + template + GLM_FUNC_QUALIFIER T gauss + ( + T x, + T ExpectedValue, + T StandardDeviation + ) + { + return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast(6.28318530717958647692528676655900576))); + } + + template + GLM_FUNC_QUALIFIER T gauss + ( + tvec2 const& Coord, + tvec2 const& ExpectedValue, + tvec2 const& StandardDeviation + ) + { + tvec2 const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast(2) * StandardDeviation * StandardDeviation); + return exp(-(Squared.x + Squared.y)); + } +}//namespace glm + diff --git a/common/glm/glm/gtc/quaternion_simd.inl b/common/glm/glm/gtc/quaternion_simd.inl new file mode 100644 index 000000000..cca874bb5 --- /dev/null +++ b/common/glm/glm/gtc/quaternion_simd.inl @@ -0,0 +1,198 @@ +/// @ref core +/// @file glm/gtc/quaternion_simd.inl + +#if GLM_ARCH & GLM_ARCH_SSE2_BIT + +namespace glm{ +namespace detail +{ +/* + template + struct compute_quat_mul + { + static tquat call(tquat const& q1, tquat const& q2) + { + // SSE2 STATS: 11 shuffle, 8 mul, 8 add + // SSE4 STATS: 3 shuffle, 4 mul, 4 dpps + + __m128 const mul0 = _mm_mul_ps(q1.Data, _mm_shuffle_ps(q2.Data, q2.Data, _MM_SHUFFLE(0, 1, 2, 3))); + __m128 const mul1 = _mm_mul_ps(q1.Data, _mm_shuffle_ps(q2.Data, q2.Data, _MM_SHUFFLE(1, 0, 3, 2))); + __m128 const mul2 = _mm_mul_ps(q1.Data, _mm_shuffle_ps(q2.Data, q2.Data, _MM_SHUFFLE(2, 3, 0, 1))); + __m128 const mul3 = _mm_mul_ps(q1.Data, q2.Data); + +# if GLM_ARCH & GLM_ARCH_SSE41_BIT + __m128 const add0 = _mm_dp_ps(mul0, _mm_set_ps(1.0f, -1.0f, 1.0f, 1.0f), 0xff); + __m128 const add1 = _mm_dp_ps(mul1, _mm_set_ps(1.0f, 1.0f, 1.0f, -1.0f), 0xff); + __m128 const add2 = _mm_dp_ps(mul2, _mm_set_ps(1.0f, 1.0f, -1.0f, 1.0f), 0xff); + __m128 const add3 = _mm_dp_ps(mul3, _mm_set_ps(1.0f, -1.0f, -1.0f, -1.0f), 0xff); +# else + __m128 const mul4 = _mm_mul_ps(mul0, _mm_set_ps(1.0f, -1.0f, 1.0f, 1.0f)); + __m128 const add0 = _mm_add_ps(mul0, _mm_movehl_ps(mul4, mul4)); + __m128 const add4 = _mm_add_ss(add0, _mm_shuffle_ps(add0, add0, 1)); + + __m128 const mul5 = _mm_mul_ps(mul1, _mm_set_ps(1.0f, 1.0f, 1.0f, -1.0f)); + __m128 const add1 = _mm_add_ps(mul1, _mm_movehl_ps(mul5, mul5)); + __m128 const add5 = _mm_add_ss(add1, _mm_shuffle_ps(add1, add1, 1)); + + __m128 const mul6 = _mm_mul_ps(mul2, _mm_set_ps(1.0f, 1.0f, -1.0f, 1.0f)); + __m128 const add2 = _mm_add_ps(mul6, _mm_movehl_ps(mul6, mul6)); + __m128 const add6 = _mm_add_ss(add2, _mm_shuffle_ps(add2, add2, 1)); + + __m128 const mul7 = _mm_mul_ps(mul3, _mm_set_ps(1.0f, -1.0f, -1.0f, -1.0f)); + __m128 const add3 = _mm_add_ps(mul3, _mm_movehl_ps(mul7, mul7)); + __m128 const add7 = _mm_add_ss(add3, _mm_shuffle_ps(add3, add3, 1)); + #endif + + // This SIMD code is a politically correct way of doing this, but in every test I've tried it has been slower than + // the final code below. I'll keep this here for reference - maybe somebody else can do something better... + // + //__m128 xxyy = _mm_shuffle_ps(add4, add5, _MM_SHUFFLE(0, 0, 0, 0)); + //__m128 zzww = _mm_shuffle_ps(add6, add7, _MM_SHUFFLE(0, 0, 0, 0)); + // + //return _mm_shuffle_ps(xxyy, zzww, _MM_SHUFFLE(2, 0, 2, 0)); + + tquat Result(uninitialize); + _mm_store_ss(&Result.x, add4); + _mm_store_ss(&Result.y, add5); + _mm_store_ss(&Result.z, add6); + _mm_store_ss(&Result.w, add7); + return Result; + } + }; +*/ + + template + struct compute_dot + { + static GLM_FUNC_QUALIFIER float call(tquat const& x, tquat const& y) + { + return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data)); + } + }; + + template + struct compute_quat_add + { + static tquat call(tquat const& q, tquat const& p) + { + tquat Result(uninitialize); + Result.data = _mm_add_ps(q.data, p.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_quat_add + { + static tquat call(tquat const & a, tquat const & b) + { + tquat Result(uninitialize); + Result.data = _mm256_add_pd(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_quat_sub + { + static tquat call(tquat const& q, tquat const& p) + { + tvec4 Result(uninitialize); + Result.data = _mm_sub_ps(q.data, p.data); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_quat_sub + { + static tquat call(tquat const & a, tquat const & b) + { + tquat Result(uninitialize); + Result.data = _mm256_sub_pd(a.data, b.data); + return Result; + } + }; +# endif + + template + struct compute_quat_mul_scalar + { + static tquat call(tquat const& q, float s) + { + tvec4 Result(uninitialize); + Result.data = _mm_mul_ps(q.data, _mm_set_ps1(s)); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_quat_mul_scalar + { + static tquat call(tquat const& q, double s) + { + tquat Result(uninitialize); + Result.data = _mm256_mul_pd(q.data, _mm_set_ps1(s)); + return Result; + } + }; +# endif + + template + struct compute_quat_div_scalar + { + static tquat call(tquat const& q, float s) + { + tvec4 Result(uninitialize); + Result.data = _mm_div_ps(q.data, _mm_set_ps1(s)); + return Result; + } + }; + +# if GLM_ARCH & GLM_ARCH_AVX_BIT + template + struct compute_quat_div_scalar + { + static tquat call(tquat const& q, double s) + { + tquat Result(uninitialize); + Result.data = _mm256_div_pd(q.data, _mm_set_ps1(s)); + return Result; + } + }; +# endif + + template + struct compute_quat_mul_vec4 + { + static tvec4 call(tquat const& q, tvec4 const& v) + { + __m128 const q_wwww = _mm_shuffle_ps(q.data, q.data, _MM_SHUFFLE(3, 3, 3, 3)); + __m128 const q_swp0 = _mm_shuffle_ps(q.data, q.data, _MM_SHUFFLE(3, 0, 2, 1)); + __m128 const q_swp1 = _mm_shuffle_ps(q.data, q.data, _MM_SHUFFLE(3, 1, 0, 2)); + __m128 const v_swp0 = _mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(3, 0, 2, 1)); + __m128 const v_swp1 = _mm_shuffle_ps(v.data, v.data, _MM_SHUFFLE(3, 1, 0, 2)); + + __m128 uv = _mm_sub_ps(_mm_mul_ps(q_swp0, v_swp1), _mm_mul_ps(q_swp1, v_swp0)); + __m128 uv_swp0 = _mm_shuffle_ps(uv, uv, _MM_SHUFFLE(3, 0, 2, 1)); + __m128 uv_swp1 = _mm_shuffle_ps(uv, uv, _MM_SHUFFLE(3, 1, 0, 2)); + __m128 uuv = _mm_sub_ps(_mm_mul_ps(q_swp0, uv_swp1), _mm_mul_ps(q_swp1, uv_swp0)); + + __m128 const two = _mm_set1_ps(2.0f); + uv = _mm_mul_ps(uv, _mm_mul_ps(q_wwww, two)); + uuv = _mm_mul_ps(uuv, two); + + tvec4 Result(uninitialize); + Result.data = _mm_add_ps(v.Data, _mm_add_ps(uv, uuv)); + return Result; + } + }; +}//namespace detail +}//namespace glm + +#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT + diff --git a/common/glm/glm/gtc/type_aligned.hpp b/common/glm/glm/gtc/type_aligned.hpp new file mode 100644 index 000000000..2e4503c3a --- /dev/null +++ b/common/glm/glm/gtc/type_aligned.hpp @@ -0,0 +1,362 @@ +/// @ref gtc_type_aligned +/// @file glm/gtc/type_aligned.hpp +/// +/// @see core (dependence) +/// +/// @defgroup gtc_type_aligned GLM_GTC_type_aligned +/// @ingroup gtc +/// +/// @brief Aligned types. +/// need to be included to use these features. + +#pragma once + +#if !GLM_HAS_ALIGNED_TYPE +# error "GLM: Aligned types are not supported on this platform" +#endif +#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) +# pragma message("GLM: GLM_GTC_type_aligned extension included") +#endif + +#include "../vec2.hpp" +#include "../vec3.hpp" +#include "../vec4.hpp" +#include "../gtc/vec1.hpp" + +namespace glm +{ + template struct tvec1; + template struct tvec2; + template struct tvec3; + template struct tvec4; + /// @addtogroup gtc_type_aligned + /// @{ + + // -- *vec1 -- + + typedef tvec1 aligned_highp_vec1; + typedef tvec1 aligned_mediump_vec1; + typedef tvec1 aligned_lowp_vec1; + typedef tvec1 aligned_highp_dvec1; + typedef tvec1 aligned_mediump_dvec1; + typedef tvec1 aligned_lowp_dvec1; + typedef tvec1 aligned_highp_ivec1; + typedef tvec1 aligned_mediump_ivec1; + typedef tvec1 aligned_lowp_ivec1; + typedef tvec1 aligned_highp_uvec1; + typedef tvec1 aligned_mediump_uvec1; + typedef tvec1 aligned_lowp_uvec1; + typedef tvec1 aligned_highp_bvec1; + typedef tvec1 aligned_mediump_bvec1; + typedef tvec1 aligned_lowp_bvec1; + + typedef tvec1 packed_highp_vec1; + typedef tvec1 packed_mediump_vec1; + typedef tvec1 packed_lowp_vec1; + typedef tvec1 packed_highp_dvec1; + typedef tvec1 packed_mediump_dvec1; + typedef tvec1 packed_lowp_dvec1; + typedef tvec1 packed_highp_ivec1; + typedef tvec1 packed_mediump_ivec1; + typedef tvec1 packed_lowp_ivec1; + typedef tvec1 packed_highp_uvec1; + typedef tvec1 packed_mediump_uvec1; + typedef tvec1 packed_lowp_uvec1; + typedef tvec1 packed_highp_bvec1; + typedef tvec1 packed_mediump_bvec1; + typedef tvec1 packed_lowp_bvec1; + + // -- *vec2 -- + + /// 2 components vector of high single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_highp_vec2; + + /// 2 components vector of medium single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_mediump_vec2; + + /// 2 components vector of low single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_lowp_vec2; + + /// 2 components vector of high double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_highp_dvec2; + + /// 2 components vector of medium double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_mediump_dvec2; + + /// 2 components vector of low double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_lowp_dvec2; + + /// 2 components vector of high precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_highp_ivec2; + + /// 2 components vector of medium precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_mediump_ivec2; + + /// 2 components vector of low precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_lowp_ivec2; + + /// 2 components vector of high precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_highp_uvec2; + + /// 2 components vector of medium precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_mediump_uvec2; + + /// 2 components vector of low precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_lowp_uvec2; + + /// 2 components vector of high precision bool numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_highp_bvec2; + + /// 2 components vector of medium precision bool numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_mediump_bvec2; + + /// 2 components vector of low precision bool numbers. + /// There is no guarantee on the actual precision. + typedef tvec2 aligned_lowp_bvec2; + + // -- *vec3 -- + + /// 3 components vector of high single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_highp_vec3; + + /// 3 components vector of medium single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_mediump_vec3; + + /// 3 components vector of low single-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_lowp_vec3; + + /// 3 components vector of high double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_highp_dvec3; + + /// 3 components vector of medium double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_mediump_dvec3; + + /// 3 components vector of low double-precision floating-point numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_lowp_dvec3; + + /// 3 components vector of high precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_highp_ivec3; + + /// 3 components vector of medium precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_mediump_ivec3; + + /// 3 components vector of low precision signed integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_lowp_ivec3; + + /// 3 components vector of high precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_highp_uvec3; + + /// 3 components vector of medium precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_mediump_uvec3; + + /// 3 components vector of low precision unsigned integer numbers. + /// There is no guarantee on the actual precision. + typedef tvec3 aligned_lowp_uvec3; + + /// 3 components vector of high precision bool numbers. + typedef tvec3 aligned_highp_bvec3; + + /// 3 components vector of medium precision bool numbers. + typedef tvec3 aligned_mediump_bvec3; + + /// 3 components vector of low precision bool numbers. + typedef tvec3 aligned_lowp_bvec3; + + // -- *vec4 -- + + /// 4 components vector of high single-precision floating-point numbers. + typedef tvec4 aligned_highp_vec4; + + /// 4 components vector of medium single-precision floating-point numbers. + typedef tvec4 aligned_mediump_vec4; + + /// 4 components vector of low single-precision floating-point numbers. + typedef tvec4 aligned_lowp_vec4; + + /// 4 components vector of high double-precision floating-point numbers. + typedef tvec4 aligned_highp_dvec4; + + /// 4 components vector of medium double-precision floating-point numbers. + typedef tvec4 aligned_mediump_dvec4; + + /// 4 components vector of low double-precision floating-point numbers. + typedef tvec4 aligned_lowp_dvec4; + + /// 4 components vector of high precision signed integer numbers. + typedef tvec4 aligned_highp_ivec4; + + /// 4 components vector of medium precision signed integer numbers. + typedef tvec4 aligned_mediump_ivec4; + + /// 4 components vector of low precision signed integer numbers. + typedef tvec4 aligned_lowp_ivec4; + + /// 4 components vector of high precision unsigned integer numbers. + typedef tvec4 aligned_highp_uvec4; + + /// 4 components vector of medium precision unsigned integer numbers. + typedef tvec4 aligned_mediump_uvec4; + + /// 4 components vector of low precision unsigned integer numbers. + typedef tvec4 aligned_lowp_uvec4; + + /// 4 components vector of high precision bool numbers. + typedef tvec4 aligned_highp_bvec4; + + /// 4 components vector of medium precision bool numbers. + typedef tvec4 aligned_mediump_bvec4; + + /// 4 components vector of low precision bool numbers. + typedef tvec4 aligned_lowp_bvec4; + + // -- default -- + +#if(defined(GLM_PRECISION_LOWP_FLOAT)) + typedef aligned_lowp_vec1 aligned_vec1; + typedef aligned_lowp_vec2 aligned_vec2; + typedef aligned_lowp_vec3 aligned_vec3; + typedef aligned_lowp_vec4 aligned_vec4; +#elif(defined(GLM_PRECISION_MEDIUMP_FLOAT)) + typedef aligned_mediump_vec1 aligned_vec1; + typedef aligned_mediump_vec2 aligned_vec2; + typedef aligned_mediump_vec3 aligned_vec3; + typedef aligned_mediump_vec4 aligned_vec4; +#else //defined(GLM_PRECISION_HIGHP_FLOAT) + /// 1 component vector of floating-point numbers. + typedef aligned_highp_vec1 aligned_vec1; + + /// 2 components vector of floating-point numbers. + typedef aligned_highp_vec2 aligned_vec2; + + /// 3 components vector of floating-point numbers. + typedef aligned_highp_vec3 aligned_vec3; + + /// 4 components vector of floating-point numbers. + typedef aligned_highp_vec4 aligned_vec4; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_LOWP_DOUBLE)) + typedef aligned_lowp_dvec1 aligned_dvec1; + typedef aligned_lowp_dvec2 aligned_dvec2; + typedef aligned_lowp_dvec3 aligned_dvec3; + typedef aligned_lowp_dvec4 aligned_dvec4; +#elif(defined(GLM_PRECISION_MEDIUMP_DOUBLE)) + typedef aligned_mediump_dvec1 aligned_dvec1; + typedef aligned_mediump_dvec2 aligned_dvec2; + typedef aligned_mediump_dvec3 aligned_dvec3; + typedef aligned_mediump_dvec4 aligned_dvec4; +#else //defined(GLM_PRECISION_HIGHP_DOUBLE) + /// 1 component vector of double-precision floating-point numbers. + typedef aligned_highp_dvec1 aligned_dvec1; + + /// 2 components vector of double-precision floating-point numbers. + typedef aligned_highp_dvec2 aligned_dvec2; + + /// 3 components vector of double-precision floating-point numbers. + typedef aligned_highp_dvec3 aligned_dvec3; + + /// 4 components vector of double-precision floating-point numbers. + typedef aligned_highp_dvec4 aligned_dvec4; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_LOWP_INT)) + typedef aligned_lowp_ivec1 aligned_ivec1; + typedef aligned_lowp_ivec2 aligned_ivec2; + typedef aligned_lowp_ivec3 aligned_ivec3; + typedef aligned_lowp_ivec4 aligned_ivec4; +#elif(defined(GLM_PRECISION_MEDIUMP_INT)) + typedef aligned_mediump_ivec1 aligned_ivec1; + typedef aligned_mediump_ivec2 aligned_ivec2; + typedef aligned_mediump_ivec3 aligned_ivec3; + typedef aligned_mediump_ivec4 aligned_ivec4; +#else //defined(GLM_PRECISION_HIGHP_INT) + /// 1 component vector of signed integer numbers. + typedef aligned_highp_ivec1 aligned_ivec1; + + /// 2 components vector of signed integer numbers. + typedef aligned_highp_ivec2 aligned_ivec2; + + /// 3 components vector of signed integer numbers. + typedef aligned_highp_ivec3 aligned_ivec3; + + /// 4 components vector of signed integer numbers. + typedef aligned_highp_ivec4 aligned_ivec4; +#endif//GLM_PRECISION + + // -- Unsigned integer definition -- + +#if(defined(GLM_PRECISION_LOWP_UINT)) + typedef aligned_lowp_uvec1 aligned_uvec1; + typedef aligned_lowp_uvec2 aligned_uvec2; + typedef aligned_lowp_uvec3 aligned_uvec3; + typedef aligned_lowp_uvec4 aligned_uvec4; +#elif(defined(GLM_PRECISION_MEDIUMP_UINT)) + typedef aligned_mediump_uvec1 aligned_uvec1; + typedef aligned_mediump_uvec2 aligned_uvec2; + typedef aligned_mediump_uvec3 aligned_uvec3; + typedef aligned_mediump_uvec4 aligned_uvec4; +#else //defined(GLM_PRECISION_HIGHP_UINT) + /// 1 component vector of unsigned integer numbers. + typedef aligned_highp_uvec1 aligned_uvec1; + + /// 2 components vector of unsigned integer numbers. + typedef aligned_highp_uvec2 aligned_uvec2; + + /// 3 components vector of unsigned integer numbers. + typedef aligned_highp_uvec3 aligned_uvec3; + + /// 4 components vector of unsigned integer numbers. + typedef aligned_highp_uvec4 aligned_uvec4; +#endif//GLM_PRECISION + +#if(defined(GLM_PRECISION_LOWP_BOOL)) + typedef aligned_lowp_bvec1 aligned_bvec1; + typedef aligned_lowp_bvec2 aligned_bvec2; + typedef aligned_lowp_bvec3 aligned_bvec3; + typedef aligned_lowp_bvec4 aligned_bvec4; +#elif(defined(GLM_PRECISION_MEDIUMP_BOOL)) + typedef aligned_mediump_bvec1 aligned_bvec1; + typedef aligned_mediump_bvec2 aligned_bvec2; + typedef aligned_mediump_bvec3 aligned_bvec3; + typedef aligned_mediump_bvec4 aligned_bvec4; +#else //defined(GLM_PRECISION_HIGHP_BOOL) + /// 1 component vector of boolean. + typedef aligned_highp_bvec1 aligned_bvec1; + + /// 2 components vector of boolean. + typedef aligned_highp_bvec2 aligned_bvec2; + + /// 3 components vector of boolean. + typedef aligned_highp_bvec3 aligned_bvec3; + + /// 4 components vector of boolean. + typedef aligned_highp_bvec4 aligned_bvec4; +#endif//GLM_PRECISION + + /// @} +}//namespace glm diff --git a/common/glm/glm/gtx/extended_min_max.hpp b/common/glm/glm/gtx/extended_min_max.hpp new file mode 100644 index 000000000..f4d885953 --- /dev/null +++ b/common/glm/glm/gtx/extended_min_max.hpp @@ -0,0 +1,133 @@ +/// @ref gtx_extended_min_max +/// @file glm/gtx/extended_min_max.hpp +/// +/// @see core (dependence) +/// @see gtx_half_float (dependence) +/// +/// @defgroup gtx_extented_min_max GLM_GTX_extented_min_max +/// @ingroup gtx +/// +/// Min and max functions for 3 to 4 parameters. +/// +/// need to be included to use these functionalities. + +#pragma once + +// Dependency: +#include "../glm.hpp" + +#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) +# pragma message("GLM: GLM_GTX_extented_min_max extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_extented_min_max + /// @{ + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + GLM_FUNC_DECL T min( + T const & x, + T const & y, + T const & z); + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C min( + C const & x, + typename C::T const & y, + typename C::T const & z); + + /// Return the minimum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C min( + C const & x, + C const & y, + C const & z); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + GLM_FUNC_DECL T min( + T const & x, + T const & y, + T const & z, + T const & w); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C min( + C const & x, + typename C::T const & y, + typename C::T const & z, + typename C::T const & w); + + /// Return the minimum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C min( + C const & x, + C const & y, + C const & z, + C const & w); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template + GLM_FUNC_DECL T max( + T const & x, + T const & y, + T const & z); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C max( + C const & x, + typename C::T const & y, + typename C::T const & z); + + /// Return the maximum component-wise values of 3 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C max( + C const & x, + C const & y, + C const & z); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template + GLM_FUNC_DECL T max( + T const & x, + T const & y, + T const & z, + T const & w); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C max( + C const & x, + typename C::T const & y, + typename C::T const & z, + typename C::T const & w); + + /// Return the maximum component-wise values of 4 inputs + /// @see gtx_extented_min_max + template class C> + GLM_FUNC_DECL C max( + C const & x, + C const & y, + C const & z, + C const & w); + + /// @} +}//namespace glm + +#include "extended_min_max.inl" diff --git a/common/glm/glm/gtx/extended_min_max.inl b/common/glm/glm/gtx/extended_min_max.inl new file mode 100644 index 000000000..64ea44526 --- /dev/null +++ b/common/glm/glm/gtx/extended_min_max.inl @@ -0,0 +1,140 @@ +/// @ref gtx_extended_min_max +/// @file glm/gtx/extended_min_max.inl + +namespace glm +{ + template + GLM_FUNC_QUALIFIER T min( + T const & x, + T const & y, + T const & z) + { + return glm::min(glm::min(x, y), z); + } + + template class C> + GLM_FUNC_QUALIFIER C min + ( + C const & x, + typename C::T const & y, + typename C::T const & z + ) + { + return glm::min(glm::min(x, y), z); + } + + template class C> + GLM_FUNC_QUALIFIER C min + ( + C const & x, + C const & y, + C const & z + ) + { + return glm::min(glm::min(x, y), z); + } + + template + GLM_FUNC_QUALIFIER T min + ( + T const & x, + T const & y, + T const & z, + T const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template class C> + GLM_FUNC_QUALIFIER C min + ( + C const & x, + typename C::T const & y, + typename C::T const & z, + typename C::T const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template class C> + GLM_FUNC_QUALIFIER C min + ( + C const & x, + C const & y, + C const & z, + C const & w + ) + { + return glm::min(glm::min(x, y), glm::min(z, w)); + } + + template + GLM_FUNC_QUALIFIER T max( + T const & x, + T const & y, + T const & z) + { + return glm::max(glm::max(x, y), z); + } + + template class C> + GLM_FUNC_QUALIFIER C max + ( + C const & x, + typename C::T const & y, + typename C::T const & z + ) + { + return glm::max(glm::max(x, y), z); + } + + template class C> + GLM_FUNC_QUALIFIER C max + ( + C const & x, + C const & y, + C const & z + ) + { + return glm::max(glm::max(x, y), z); + } + + template + GLM_FUNC_QUALIFIER T max + ( + T const & x, + T const & y, + T const & z, + T const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + + template class C> + GLM_FUNC_QUALIFIER C max + ( + C const & x, + typename C::T const & y, + typename C::T const & z, + typename C::T const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + + template class C> + GLM_FUNC_QUALIFIER C max + ( + C const & x, + C const & y, + C const & z, + C const & w + ) + { + return glm::max(glm::max(x, y), glm::max(z, w)); + } + +}//namespace glm diff --git a/common/glm/glm/gtx/float_notmalize.inl b/common/glm/glm/gtx/float_notmalize.inl new file mode 100644 index 000000000..4dde02568 --- /dev/null +++ b/common/glm/glm/gtx/float_notmalize.inl @@ -0,0 +1,14 @@ +/// @ref gtx_float_normalize +/// @file glm/gtx/float_normalize.inl + +#include + +namespace glm +{ + template class vecType> + GLM_FUNC_QUALIFIER vecType floatNormalize(vecType const & v) + { + return vecType(v) / static_cast(std::numeric_limits::max()); + } + +}//namespace glm diff --git a/common/glm/glm/gtx/hash.hpp b/common/glm/glm/gtx/hash.hpp new file mode 100644 index 000000000..22626188c --- /dev/null +++ b/common/glm/glm/gtx/hash.hpp @@ -0,0 +1,134 @@ +/// @ref gtx_hash +/// @file glm/gtx/hash.hpp +/// +/// @see core (dependence) +/// +/// @defgroup gtx_hash GLM_GTX_hash +/// @ingroup gtx +/// +/// @brief Add std::hash support for glm types +/// +/// need to be included to use these functionalities. + +#pragma once + +#include + +#include "../vec2.hpp" +#include "../vec3.hpp" +#include "../vec4.hpp" +#include "../gtc/vec1.hpp" + +#include "../gtc/quaternion.hpp" +#include "../gtx/dual_quaternion.hpp" + +#include "../mat2x2.hpp" +#include "../mat2x3.hpp" +#include "../mat2x4.hpp" + +#include "../mat3x2.hpp" +#include "../mat3x3.hpp" +#include "../mat3x4.hpp" + +#include "../mat4x2.hpp" +#include "../mat4x3.hpp" +#include "../mat4x4.hpp" + +#if !GLM_HAS_CXX11_STL +# error "GLM_GTX_hash requires C++11 standard library support" +#endif + +namespace std +{ + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tvec1 const & v) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tvec2 const & v) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tvec3 const & v) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tvec4 const & v) const; + }; + + template + struct hash> + { + GLM_FUNC_DECL size_t operator()(glm::tquat const & q) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tdualquat const & q) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat2x2 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat2x3 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat2x4 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat3x2 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat3x3 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat3x4 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat4x2 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat4x3 const & m) const; + }; + + template + struct hash > + { + GLM_FUNC_DECL size_t operator()(glm::tmat4x4 const & m) const; + }; +} // namespace std + +#include "hash.inl" diff --git a/common/glm/glm/gtx/hash.inl b/common/glm/glm/gtx/hash.inl new file mode 100644 index 000000000..c42f4f0a8 --- /dev/null +++ b/common/glm/glm/gtx/hash.inl @@ -0,0 +1,185 @@ +/// @ref gtx_hash +/// @file glm/gtx/hash.inl +/// +/// @see core (dependence) +/// +/// @defgroup gtx_hash GLM_GTX_hash +/// @ingroup gtx +/// +/// @brief Add std::hash support for glm types +/// +/// need to be included to use these functionalities. + +namespace glm { +namespace detail +{ + GLM_INLINE void hash_combine(size_t &seed, size_t hash) + { + hash += 0x9e3779b9 + (seed << 6) + (seed >> 2); + seed ^= hash; + } +}} + +namespace std +{ + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec1 const & v) const + { + hash hasher; + return hasher(v.x); + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec2 const & v) const + { + size_t seed = 0; + hash hasher; + glm::detail::hash_combine(seed, hasher(v.x)); + glm::detail::hash_combine(seed, hasher(v.y)); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec3 const & v) const + { + size_t seed = 0; + hash hasher; + glm::detail::hash_combine(seed, hasher(v.x)); + glm::detail::hash_combine(seed, hasher(v.y)); + glm::detail::hash_combine(seed, hasher(v.z)); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tvec4 const & v) const + { + size_t seed = 0; + hash hasher; + glm::detail::hash_combine(seed, hasher(v.x)); + glm::detail::hash_combine(seed, hasher(v.y)); + glm::detail::hash_combine(seed, hasher(v.z)); + glm::detail::hash_combine(seed, hasher(v.w)); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tquat const & q) const + { + size_t seed = 0; + hash hasher; + glm::detail::hash_combine(seed, hasher(q.x)); + glm::detail::hash_combine(seed, hasher(q.y)); + glm::detail::hash_combine(seed, hasher(q.z)); + glm::detail::hash_combine(seed, hasher(q.w)); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tdualquat const & q) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(q.real)); + glm::detail::hash_combine(seed, hasher(q.dual)); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x2 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x3 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat2x4 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x2 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x3 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat3x4 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x2 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + glm::detail::hash_combine(seed, hasher(m[3])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x3 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + glm::detail::hash_combine(seed, hasher(m[3])); + return seed; + } + + template + GLM_FUNC_QUALIFIER size_t hash>::operator()(glm::tmat4x4 const & m) const + { + size_t seed = 0; + hash> hasher; + glm::detail::hash_combine(seed, hasher(m[0])); + glm::detail::hash_combine(seed, hasher(m[1])); + glm::detail::hash_combine(seed, hasher(m[2])); + glm::detail::hash_combine(seed, hasher(m[3])); + return seed; + } +} diff --git a/common/glm/glm/gtx/type_trait.hpp b/common/glm/glm/gtx/type_trait.hpp new file mode 100644 index 000000000..0207a06d4 --- /dev/null +++ b/common/glm/glm/gtx/type_trait.hpp @@ -0,0 +1,252 @@ +/// @ref gtx_type_trait +/// @file glm/gtx/type_trait.hpp +/// +/// @see core (dependence) +/// +/// @defgroup gtx_type_trait GLM_GTX_type_trait +/// @ingroup gtx +/// +/// @brief Defines traits for each type. +/// +/// need to be included to use these functionalities. + +#pragma once + +// Dependency: +#include "../detail/type_vec2.hpp" +#include "../detail/type_vec3.hpp" +#include "../detail/type_vec4.hpp" +#include "../detail/type_mat2x2.hpp" +#include "../detail/type_mat2x3.hpp" +#include "../detail/type_mat2x4.hpp" +#include "../detail/type_mat3x2.hpp" +#include "../detail/type_mat3x3.hpp" +#include "../detail/type_mat3x4.hpp" +#include "../detail/type_mat4x2.hpp" +#include "../detail/type_mat4x3.hpp" +#include "../detail/type_mat4x4.hpp" +#include "../gtc/quaternion.hpp" +#include "../gtx/dual_quaternion.hpp" + +#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) +# pragma message("GLM: GLM_GTX_type_trait extension included") +#endif + +namespace glm +{ + /// @addtogroup gtx_type_trait + /// @{ + + template