Oops! (don't attempt a commit when you have to go to the restroom...)

This commit is contained in:
Uleat
2017-03-26 13:51:03 -04:00
parent 8febc906a5
commit 05e97f4c64
34 changed files with 5711 additions and 0 deletions
+231
View File
@@ -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 <immintrin.h>
namespace glm{
namespace detail
{
template <precision P>
struct compute_abs_vector<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_abs(v.data);
return result;
}
};
template <precision P>
struct compute_abs_vector<int, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<int, P> call(tvec4<int, P> const & v)
{
tvec4<int, P> result(uninitialize);
result.data = glm_ivec4_abs(v.data);
return result;
}
};
template <precision P>
struct compute_floor<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_floor(v.data);
return result;
}
};
template <precision P>
struct compute_ceil<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_ceil(v.data);
return result;
}
};
template <precision P>
struct compute_fract<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_fract(v.data);
return result;
}
};
template <precision P>
struct compute_round<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_round(v.data);
return result;
}
};
template <precision P>
struct compute_mod<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & x, tvec4<float, P> const & y)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_mod(x.data, y.data);
return result;
}
};
template <precision P>
struct compute_min_vector<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v1, tvec4<float, P> const & v2)
{
tvec4<float, P> result(uninitialize);
result.data = _mm_min_ps(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_min_vector<int32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<int32, P> call(tvec4<int32, P> const & v1, tvec4<int32, P> const & v2)
{
tvec4<int32, P> result(uninitialize);
result.data = _mm_min_epi32(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_min_vector<uint32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<int32, P> call(tvec4<uint32, P> const & v1, tvec4<uint32, P> const & v2)
{
tvec4<uint32, P> result(uninitialize);
result.data = _mm_min_epu32(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_max_vector<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v1, tvec4<float, P> const & v2)
{
tvec4<float, P> result(uninitialize);
result.data = _mm_max_ps(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_max_vector<int32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<int32, P> call(tvec4<int32, P> const & v1, tvec4<int32, P> const & v2)
{
tvec4<int32, P> result(uninitialize);
result.data = _mm_max_epi32(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_max_vector<uint32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<uint32, P> call(tvec4<uint32, P> const & v1, tvec4<uint32, P> const & v2)
{
tvec4<uint32, P> result(uninitialize);
result.data = _mm_max_epu32(v1.data, v2.data);
return result;
}
};
template <precision P>
struct compute_clamp_vector<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & x, tvec4<float, P> const & minVal, tvec4<float, P> const & maxVal)
{
tvec4<float, P> result(uninitialize);
result.data = _mm_min_ps(_mm_max_ps(x.data, minVal.data), maxVal.data);
return result;
}
};
template <precision P>
struct compute_clamp_vector<int32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<int32, P> call(tvec4<int32, P> const & x, tvec4<int32, P> const & minVal, tvec4<int32, P> const & maxVal)
{
tvec4<int32, P> result(uninitialize);
result.data = _mm_min_epi32(_mm_max_epi32(x.data, minVal.data), maxVal.data);
return result;
}
};
template <precision P>
struct compute_clamp_vector<uint32, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<uint32, P> call(tvec4<uint32, P> const & x, tvec4<uint32, P> const & minVal, tvec4<uint32, P> const & maxVal)
{
tvec4<uint32, P> result(uninitialize);
result.data = _mm_min_epu32(_mm_max_epu32(x.data, minVal.data), maxVal.data);
return result;
}
};
template <precision P>
struct compute_mix_vector<float, bool, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & x, tvec4<float, P> const & y, tvec4<bool, P> 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<float, P> 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 <precision P>
struct compute_step_vector<float, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& edge, tvec4<float, P> const& x)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_step(edge.data, x.data);
return result;
}
};
*/
template <precision P>
struct compute_smoothstep_vector<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& edge0, tvec4<float, P> const& edge1, tvec4<float, P> const& x)
{
tvec4<float, P> 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
@@ -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 <precision P>
struct compute_sqrt<tvec4, float, P, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = _mm_sqrt_ps(v.data);
return result;
}
};
template <>
struct compute_sqrt<tvec4, float, aligned_lowp, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, aligned_lowp> call(tvec4<float, aligned_lowp> const & v)
{
tvec4<float, aligned_lowp> result(uninitialize);
result.data = glm_vec4_sqrt_lowp(v.data);
return result;
}
};
}//namespace detail
}//namespace glm
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
@@ -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 <precision P>
struct compute_length<tvec4, float, P, true>
{
GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const & v)
{
return _mm_cvtss_f32(glm_vec4_length(v.data));
}
};
template <precision P>
struct compute_distance<tvec4, float, P, true>
{
GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const & p0, tvec4<float, P> const & p1)
{
return _mm_cvtss_f32(glm_vec4_distance(p0.data, p1.data));
}
};
template <precision P>
struct compute_dot<tvec4, float, P, true>
{
GLM_FUNC_QUALIFIER static float call(tvec4<float, P> const& x, tvec4<float, P> const& y)
{
return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data));
}
};
template <precision P>
struct compute_cross<float, P, true>
{
GLM_FUNC_QUALIFIER static tvec3<float, P> call(tvec3<float, P> const & a, tvec3<float, P> 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<float, P> result(uninitialize);
result.data = xpd0;
return tvec3<float, P>(result);
}
};
template <precision P>
struct compute_normalize<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & v)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_normalize(v.data);
return result;
}
};
template <precision P>
struct compute_faceforward<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& N, tvec4<float, P> const& I, tvec4<float, P> const& Nref)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_faceforward(N.data, I.data, Nref.data);
return result;
}
};
template <precision P>
struct compute_reflect<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& I, tvec4<float, P> const& N)
{
tvec4<float, P> result(uninitialize);
result.data = glm_vec4_reflect(I.data, N.data);
return result;
}
};
template <precision P>
struct compute_refract<float, P, tvec4, true>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const& I, tvec4<float, P> const& N, float eta)
{
tvec4<float, P> 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
@@ -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 <glm::precision P>
struct compute_bitfieldReverseStep<uint32, P, tvec4, true, true>
{
GLM_FUNC_QUALIFIER static tvec4<uint32, P> call(tvec4<uint32, P> 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 <glm::precision P>
struct compute_bitfieldBitCountStep<uint32, P, tvec4, true, true>
{
GLM_FUNC_QUALIFIER static tvec4<uint32, P> call(tvec4<uint32, P> 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<int>(_mm_popcnt_u64(x));
}
# endif//GLM_MODEL
# endif//GLM_ARCH
}//namespace glm
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
@@ -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 <precision P>
struct compute_matrixCompMult<tmat4x4, float, P, true>
{
GLM_STATIC_ASSERT(detail::is_aligned<P>::value, "Specialization requires aligned");
GLM_FUNC_QUALIFIER static tmat4x4<float, P> call(tmat4x4<float, P> const & x, tmat4x4<float, P> const & y)
{
tmat4x4<float, P> 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 <precision P>
struct compute_transpose<tmat4x4, float, P, true>
{
GLM_FUNC_QUALIFIER static tmat4x4<float, P> call(tmat4x4<float, P> const & m)
{
tmat4x4<float, P> result(uninitialize);
glm_mat4_transpose(
*(glm_vec4 const (*)[4])&m[0].data,
*(glm_vec4(*)[4])&result[0].data);
return result;
}
};
template <precision P>
struct compute_determinant<tmat4x4, float, P, true>
{
GLM_FUNC_QUALIFIER static float call(tmat4x4<float, P> const& m)
{
return _mm_cvtss_f32(glm_mat4_determinant(*reinterpret_cast<__m128 const(*)[4]>(&m[0].data)));
}
};
template <precision P>
struct compute_inverse<tmat4x4, float, P, true>
{
GLM_FUNC_QUALIFIER static tmat4x4<float, P> call(tmat4x4<float, P> const& m)
{
tmat4x4<float, P> 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<float, aligned_lowp> outerProduct<float, aligned_lowp, tvec4, tvec4>(tvec4<float, aligned_lowp> const & c, tvec4<float, aligned_lowp> const & r)
{
tmat4x4<float, aligned_lowp> m(uninitialize);
glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data));
return m;
}
template<>
GLM_FUNC_QUALIFIER tmat4x4<float, aligned_mediump> outerProduct<float, aligned_mediump, tvec4, tvec4>(tvec4<float, aligned_mediump> const & c, tvec4<float, aligned_mediump> const & r)
{
tmat4x4<float, aligned_mediump> m(uninitialize);
glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data));
return m;
}
template<>
GLM_FUNC_QUALIFIER tmat4x4<float, aligned_highp> outerProduct<float, aligned_highp, tvec4, tvec4>(tvec4<float, aligned_highp> const & c, tvec4<float, aligned_highp> const & r)
{
tmat4x4<float, aligned_highp> m(uninitialize);
glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data));
return m;
}
}//namespace glm
#endif
@@ -0,0 +1,9 @@
/// @ref core
/// @file glm/detail/func_packing_simd.inl
namespace glm{
namespace detail
{
}//namespace detail
}//namespace glm
@@ -0,0 +1,9 @@
/// @ref core
/// @file glm/detail/func_vector_relational_simd.inl
namespace glm{
namespace detail
{
}//namespace detail
}//namespace glm
@@ -0,0 +1,7 @@
/// @ref core
/// @file glm/detail/type_mat4x4_sse2.inl
namespace glm
{
}//namespace glm
+481
View File
@@ -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 <precision P, int E0, int E1, int E2, int E3>
struct _swizzle_base1<4, float, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0<float, 4>
{
GLM_FUNC_QUALIFIER tvec4<float, P> operator ()() const
{
__m128 data = *reinterpret_cast<__m128 const*>(&this->_buffer);
tvec4<float, P> 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 <precision P, int E0, int E1, int E2, int E3>
struct _swizzle_base1<4, int32, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0<int32, 4>
{
GLM_FUNC_QUALIFIER tvec4<int32, P> operator ()() const
{
__m128i data = *reinterpret_cast<__m128i const*>(&this->_buffer);
tvec4<int32, P> Result(uninitialize);
Result.data = _mm_shuffle_epi32(data, _MM_SHUFFLE(E3, E2, E1, E0));
return Result;
}
};
template <precision P, int E0, int E1, int E2, int E3>
struct _swizzle_base1<4, uint32, P, glm::tvec4, E0,E1,E2,E3, true> : public _swizzle_base0<uint32, 4>
{
GLM_FUNC_QUALIFIER tvec4<uint32, P> operator ()() const
{
__m128i data = *reinterpret_cast<__m128i const*>(&this->_buffer);
tvec4<uint32, P> Result(uninitialize);
Result.data = _mm_shuffle_epi32(data, _MM_SHUFFLE(E3, E2, E1, E0));
return Result;
}
};
# endif// GLM_SWIZZLE == GLM_SWIZZLE_ENABLED
template <precision P>
struct compute_vec4_add<float, P, true>
{
static tvec4<float, P> call(tvec4<float, P> const & a, tvec4<float, P> const & b)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_add_ps(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_vec4_add<double, P, true>
{
static tvec4<double, P> call(tvec4<double, P> const & a, tvec4<double, P> const & b)
{
tvec4<double, P> Result(uninitialize);
Result.data = _mm256_add_pd(a.data, b.data);
return Result;
}
};
# endif
template <precision P>
struct compute_vec4_sub<float, P, true>
{
static tvec4<float, P> call(tvec4<float, P> const & a, tvec4<float, P> const & b)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_sub_ps(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_vec4_sub<double, P, true>
{
static tvec4<double, P> call(tvec4<double, P> const & a, tvec4<double, P> const & b)
{
tvec4<double, P> Result(uninitialize);
Result.data = _mm256_sub_pd(a.data, b.data);
return Result;
}
};
# endif
template <precision P>
struct compute_vec4_mul<float, P, true>
{
static tvec4<float, P> call(tvec4<float, P> const & a, tvec4<float, P> const & b)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_mul_ps(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_vec4_mul<double, P, true>
{
static tvec4<double, P> call(tvec4<double, P> const & a, tvec4<double, P> const & b)
{
tvec4<double, P> Result(uninitialize);
Result.data = _mm256_mul_pd(a.data, b.data);
return Result;
}
};
# endif
template <precision P>
struct compute_vec4_div<float, P, true>
{
static tvec4<float, P> call(tvec4<float, P> const & a, tvec4<float, P> const & b)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_div_ps(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_vec4_div<double, P, true>
{
static tvec4<double, P> call(tvec4<double, P> const & a, tvec4<double, P> const & b)
{
tvec4<double, P> Result(uninitialize);
Result.data = _mm256_div_pd(a.data, b.data);
return Result;
}
};
# endif
template <>
struct compute_vec4_div<float, aligned_lowp, true>
{
static tvec4<float, aligned_lowp> call(tvec4<float, aligned_lowp> const & a, tvec4<float, aligned_lowp> const & b)
{
tvec4<float, aligned_lowp> Result(uninitialize);
Result.data = _mm_mul_ps(a.data, _mm_rcp_ps(b.data));
return Result;
}
};
template <typename T, precision P>
struct compute_vec4_and<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_and_si128(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_and<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_and_si256(a.data, b.data);
return Result;
}
};
# endif
template <typename T, precision P>
struct compute_vec4_or<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_or_si128(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_or<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_or_si256(a.data, b.data);
return Result;
}
};
# endif
template <typename T, precision P>
struct compute_vec4_xor<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_xor_si128(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_xor<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_xor_si256(a.data, b.data);
return Result;
}
};
# endif
template <typename T, precision P>
struct compute_vec4_shift_left<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_sll_epi32(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_shift_left<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_sll_epi64(a.data, b.data);
return Result;
}
};
# endif
template <typename T, precision P>
struct compute_vec4_shift_right<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_srl_epi32(a.data, b.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_shift_right<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const& a, tvec4<T, P> const& b)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_srl_epi64(a.data, b.data);
return Result;
}
};
# endif
template <typename T, precision P>
struct compute_vec4_bitwise_not<T, P, true, 32, true>
{
static tvec4<T, P> call(tvec4<T, P> const & v)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm_xor_si128(v.data, _mm_set1_epi32(-1));
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <typename T, precision P>
struct compute_vec4_bitwise_not<T, P, true, 64, true>
{
static tvec4<T, P> call(tvec4<T, P> const & v)
{
tvec4<T, P> Result(uninitialize);
Result.data = _mm256_xor_si256(v.data, _mm_set1_epi32(-1));
return Result;
}
};
# endif
template <precision P>
struct compute_vec4_equal<float, P, false, 32, true>
{
static bool call(tvec4<float, P> const & v1, tvec4<float, P> const & v2)
{
return _mm_movemask_ps(_mm_cmpeq_ps(v1.data, v2.data)) != 0;
}
};
template <precision P>
struct compute_vec4_equal<int32, P, true, 32, true>
{
static bool call(tvec4<int32, P> const & v1, tvec4<int32, P> const & v2)
{
return _mm_movemask_epi8(_mm_cmpeq_epi32(v1.data, v2.data)) != 0;
}
};
template <precision P>
struct compute_vec4_nequal<float, P, false, 32, true>
{
static bool call(tvec4<float, P> const & v1, tvec4<float, P> const & v2)
{
return _mm_movemask_ps(_mm_cmpneq_ps(v1.data, v2.data)) != 0;
}
};
template <precision P>
struct compute_vec4_nequal<int32, P, true, 32, true>
{
static bool call(tvec4<int32, P> const & v1, tvec4<int32, P> 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<float, aligned_lowp>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_mediump>::tvec4()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::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<float, aligned_lowp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_mediump>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_highp>::tvec4(float s) :
data(_mm_set1_ps(s))
{}
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_lowp>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_mediump>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<double, aligned_highp>::tvec4(double s) :
data(_mm256_set1_pd(s))
{}
# endif
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_lowp>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_mediump>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int32, aligned_highp>::tvec4(int32 s) :
data(_mm_set1_epi32(s))
{}
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_lowp>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_mediump>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<int64, aligned_highp>::tvec4(int64 s) :
data(_mm256_set1_epi64x(s))
{}
# endif
template <>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD tvec4<float, aligned_lowp>::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<float, aligned_mediump>::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<float, aligned_highp>::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<int32, aligned_lowp>::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<int32, aligned_mediump>::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<int32, aligned_highp>::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<float, aligned_lowp>::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<float, aligned_mediump>::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<float, aligned_highp>::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
+65
View File
@@ -0,0 +1,65 @@
/// @ref gtc_color_encoding
/// @file glm/gtc/color_encoding.inl
namespace glm
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertLinearSRGBToD65XYZ(tvec3<T, P> const& ColorLinearSRGB)
{
tvec3<T, P> const M(0.490f, 0.17697f, 0.2f);
tvec3<T, P> const N(0.31f, 0.8124f, 0.01063f);
tvec3<T, P> const O(0.490f, 0.01f, 0.99f);
return (M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB) * static_cast<T>(5.650675255693055f);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertD65XYZToLinearSRGB(tvec3<T, P> const& ColorD65XYZ)
{
tvec3<T, P> const M(0.41847f, -0.091169f, 0.0009209f);
tvec3<T, P> const N(-0.15866f, 0.25243f, 0.015708f);
tvec3<T, P> const O(0.0009209f, -0.0025498f, 0.1786f);
return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertLinearSRGBToD50XYZ(tvec3<T, P> const& ColorLinearSRGB)
{
tvec3<T, P> const M(0.436030342570117f, 0.222438466210245f, 0.013897440074263f);
tvec3<T, P> const N(0.385101860087134f, 0.716942745571917f, 0.097076381494207f);
tvec3<T, P> const O(0.143067806654203f, 0.060618777416563f, 0.713926257896652f);
return M * ColorLinearSRGB + N * ColorLinearSRGB + O * ColorLinearSRGB;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertD50XYZToLinearSRGB(tvec3<T, P> const& ColorD50XYZ)
{
tvec3<T, P> const M();
tvec3<T, P> const N();
tvec3<T, P> const O();
return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertD65XYZToD50XYZ(tvec3<T, P> const& ColorD65XYZ)
{
tvec3<T, P> const M(+1.047844353856414f, +0.029549007606644f, -0.009250984365223f);
tvec3<T, P> const N(+0.022898981050086f, +0.990508028941971f, +0.015072338237051f);
tvec3<T, P> const O(-0.050206647741605f, -0.017074711360960f, +0.751717835079977f);
return M * ColorD65XYZ + N * ColorD65XYZ + O * ColorD65XYZ;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> convertD50XYZToD65XYZ(tvec3<T, P> const& ColorD50XYZ)
{
tvec3<T, P> const M();
tvec3<T, P> const N();
tvec3<T, P> const O();
return M * ColorD50XYZ + N * ColorD50XYZ + O * ColorD50XYZ;
}
}//namespace glm
+56
View File
@@ -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
///
/// <glm/gtc/color.hpp> 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 <limits>
#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 <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> 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 <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertLinearToSRGB(vecType<T, P> 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 <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> 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 <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> convertSRGBToLinear(vecType<T, P> const & ColorSRGB, T Gamma);
/// @}
} //namespace glm
#include "color_space.inl"
+75
View File
@@ -0,0 +1,75 @@
/// @ref gtc_color_space
/// @file glm/gtc/color_space.inl
namespace glm{
namespace detail
{
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_rgbToSrgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorRGB, T GammaCorrection)
{
vecType<T, P> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
return mix(
pow(ClampedColor, vecType<T, P>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
ClampedColor * static_cast<T>(12.92),
lessThan(ClampedColor, vecType<T, P>(static_cast<T>(0.0031308))));
}
};
template <typename T, precision P>
struct compute_rgbToSrgb<T, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorRGB, T GammaCorrection)
{
return tvec4<T, P>(compute_rgbToSrgb<T, P, tvec3>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.w);
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_srgbToRgb
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorSRGB, T Gamma)
{
return mix(
pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<T, P>(Gamma)),
ColorSRGB * static_cast<T>(0.07739938080495356037151702786378),
lessThanEqual(ColorSRGB, vecType<T, P>(static_cast<T>(0.04045))));
}
};
template <typename T, precision P>
struct compute_srgbToRgb<T, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorSRGB, T Gamma)
{
return tvec4<T, P>(compute_srgbToRgb<T, P, tvec3>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.w);
}
};
}//namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear, T Gamma)
{
return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
}
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB, T Gamma)
{
return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
}
}//namespace glm
+53
View File
@@ -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.
///
/// <glm/gtc/functions.hpp> 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 <typename T>
GLM_FUNC_DECL T gauss(
T x,
T ExpectedValue,
T StandardDeviation);
/// 2D gauss function
///
/// @see gtc_epsilon
template <typename T, precision P>
GLM_FUNC_DECL T gauss(
tvec2<T, P> const& Coord,
tvec2<T, P> const& ExpectedValue,
tvec2<T, P> const& StandardDeviation);
/// @}
}//namespace glm
#include "functions.inl"
+31
View File
@@ -0,0 +1,31 @@
/// @ref gtc_functions
/// @file glm/gtc/functions.inl
#include "../detail/func_exponential.hpp"
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER T gauss
(
T x,
T ExpectedValue,
T StandardDeviation
)
{
return exp(-((x - ExpectedValue) * (x - ExpectedValue)) / (static_cast<T>(2) * StandardDeviation * StandardDeviation)) / (StandardDeviation * sqrt(static_cast<T>(6.28318530717958647692528676655900576)));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T gauss
(
tvec2<T, P> const& Coord,
tvec2<T, P> const& ExpectedValue,
tvec2<T, P> const& StandardDeviation
)
{
tvec2<T, P> const Squared = ((Coord - ExpectedValue) * (Coord - ExpectedValue)) / (static_cast<T>(2) * StandardDeviation * StandardDeviation);
return exp(-(Squared.x + Squared.y));
}
}//namespace glm
+198
View File
@@ -0,0 +1,198 @@
/// @ref core
/// @file glm/gtc/quaternion_simd.inl
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
namespace glm{
namespace detail
{
/*
template <precision P>
struct compute_quat_mul<float, P, true>
{
static tquat<float, P> call(tquat<float, P> const& q1, tquat<float, P> 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<float, P> 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 <precision P>
struct compute_dot<tquat, float, P, true>
{
static GLM_FUNC_QUALIFIER float call(tquat<float, P> const& x, tquat<float, P> const& y)
{
return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data));
}
};
template <precision P>
struct compute_quat_add<float, P, true>
{
static tquat<float, P> call(tquat<float, P> const& q, tquat<float, P> const& p)
{
tquat<float, P> Result(uninitialize);
Result.data = _mm_add_ps(q.data, p.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_quat_add<double, P, true>
{
static tquat<double, P> call(tquat<double, P> const & a, tquat<double, P> const & b)
{
tquat<double, P> Result(uninitialize);
Result.data = _mm256_add_pd(a.data, b.data);
return Result;
}
};
# endif
template <precision P>
struct compute_quat_sub<float, P, true>
{
static tquat<float, P> call(tquat<float, P> const& q, tquat<float, P> const& p)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_sub_ps(q.data, p.data);
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_quat_sub<double, P, true>
{
static tquat<double, P> call(tquat<double, P> const & a, tquat<double, P> const & b)
{
tquat<double, P> Result(uninitialize);
Result.data = _mm256_sub_pd(a.data, b.data);
return Result;
}
};
# endif
template <precision P>
struct compute_quat_mul_scalar<float, P, true>
{
static tquat<float, P> call(tquat<float, P> const& q, float s)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_mul_ps(q.data, _mm_set_ps1(s));
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_quat_mul_scalar<double, P, true>
{
static tquat<double, P> call(tquat<double, P> const& q, double s)
{
tquat<double, P> Result(uninitialize);
Result.data = _mm256_mul_pd(q.data, _mm_set_ps1(s));
return Result;
}
};
# endif
template <precision P>
struct compute_quat_div_scalar<float, P, true>
{
static tquat<float, P> call(tquat<float, P> const& q, float s)
{
tvec4<float, P> Result(uninitialize);
Result.data = _mm_div_ps(q.data, _mm_set_ps1(s));
return Result;
}
};
# if GLM_ARCH & GLM_ARCH_AVX_BIT
template <precision P>
struct compute_quat_div_scalar<double, P, true>
{
static tquat<double, P> call(tquat<double, P> const& q, double s)
{
tquat<double, P> Result(uninitialize);
Result.data = _mm256_div_pd(q.data, _mm_set_ps1(s));
return Result;
}
};
# endif
template <precision P>
struct compute_quat_mul_vec4<float, P, true>
{
static tvec4<float, P> call(tquat<float, P> const& q, tvec4<float, P> 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<float, P> 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
+362
View File
@@ -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.
/// <glm/gtc/type_aligned.hpp> 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 <typename T, precision P> struct tvec1;
template <typename T, precision P> struct tvec2;
template <typename T, precision P> struct tvec3;
template <typename T, precision P> struct tvec4;
/// @addtogroup gtc_type_aligned
/// @{
// -- *vec1 --
typedef tvec1<float, aligned_highp> aligned_highp_vec1;
typedef tvec1<float, aligned_mediump> aligned_mediump_vec1;
typedef tvec1<float, aligned_lowp> aligned_lowp_vec1;
typedef tvec1<double, aligned_highp> aligned_highp_dvec1;
typedef tvec1<double, aligned_mediump> aligned_mediump_dvec1;
typedef tvec1<double, aligned_lowp> aligned_lowp_dvec1;
typedef tvec1<int, aligned_highp> aligned_highp_ivec1;
typedef tvec1<int, aligned_mediump> aligned_mediump_ivec1;
typedef tvec1<int, aligned_lowp> aligned_lowp_ivec1;
typedef tvec1<uint, aligned_highp> aligned_highp_uvec1;
typedef tvec1<uint, aligned_mediump> aligned_mediump_uvec1;
typedef tvec1<uint, aligned_lowp> aligned_lowp_uvec1;
typedef tvec1<bool, aligned_highp> aligned_highp_bvec1;
typedef tvec1<bool, aligned_mediump> aligned_mediump_bvec1;
typedef tvec1<bool, aligned_lowp> aligned_lowp_bvec1;
typedef tvec1<float, packed_highp> packed_highp_vec1;
typedef tvec1<float, packed_mediump> packed_mediump_vec1;
typedef tvec1<float, packed_lowp> packed_lowp_vec1;
typedef tvec1<double, packed_highp> packed_highp_dvec1;
typedef tvec1<double, packed_mediump> packed_mediump_dvec1;
typedef tvec1<double, packed_lowp> packed_lowp_dvec1;
typedef tvec1<int, packed_highp> packed_highp_ivec1;
typedef tvec1<int, packed_mediump> packed_mediump_ivec1;
typedef tvec1<int, packed_lowp> packed_lowp_ivec1;
typedef tvec1<uint, packed_highp> packed_highp_uvec1;
typedef tvec1<uint, packed_mediump> packed_mediump_uvec1;
typedef tvec1<uint, packed_lowp> packed_lowp_uvec1;
typedef tvec1<bool, packed_highp> packed_highp_bvec1;
typedef tvec1<bool, packed_mediump> packed_mediump_bvec1;
typedef tvec1<bool, packed_lowp> packed_lowp_bvec1;
// -- *vec2 --
/// 2 components vector of high single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<float, aligned_highp> aligned_highp_vec2;
/// 2 components vector of medium single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<float, aligned_mediump> aligned_mediump_vec2;
/// 2 components vector of low single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<float, aligned_lowp> aligned_lowp_vec2;
/// 2 components vector of high double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<double, aligned_highp> aligned_highp_dvec2;
/// 2 components vector of medium double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<double, aligned_mediump> aligned_mediump_dvec2;
/// 2 components vector of low double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<double, aligned_lowp> aligned_lowp_dvec2;
/// 2 components vector of high precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<int, aligned_highp> aligned_highp_ivec2;
/// 2 components vector of medium precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<int, aligned_mediump> aligned_mediump_ivec2;
/// 2 components vector of low precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<int, aligned_lowp> aligned_lowp_ivec2;
/// 2 components vector of high precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<uint, aligned_highp> aligned_highp_uvec2;
/// 2 components vector of medium precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<uint, aligned_mediump> aligned_mediump_uvec2;
/// 2 components vector of low precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<uint, aligned_lowp> aligned_lowp_uvec2;
/// 2 components vector of high precision bool numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<bool, aligned_highp> aligned_highp_bvec2;
/// 2 components vector of medium precision bool numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<bool, aligned_mediump> aligned_mediump_bvec2;
/// 2 components vector of low precision bool numbers.
/// There is no guarantee on the actual precision.
typedef tvec2<bool, aligned_lowp> aligned_lowp_bvec2;
// -- *vec3 --
/// 3 components vector of high single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<float, aligned_highp> aligned_highp_vec3;
/// 3 components vector of medium single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<float, aligned_mediump> aligned_mediump_vec3;
/// 3 components vector of low single-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<float, aligned_lowp> aligned_lowp_vec3;
/// 3 components vector of high double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<double, aligned_highp> aligned_highp_dvec3;
/// 3 components vector of medium double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<double, aligned_mediump> aligned_mediump_dvec3;
/// 3 components vector of low double-precision floating-point numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<double, aligned_lowp> aligned_lowp_dvec3;
/// 3 components vector of high precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<int, aligned_highp> aligned_highp_ivec3;
/// 3 components vector of medium precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<int, aligned_mediump> aligned_mediump_ivec3;
/// 3 components vector of low precision signed integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<int, aligned_lowp> aligned_lowp_ivec3;
/// 3 components vector of high precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<uint, aligned_highp> aligned_highp_uvec3;
/// 3 components vector of medium precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<uint, aligned_mediump> aligned_mediump_uvec3;
/// 3 components vector of low precision unsigned integer numbers.
/// There is no guarantee on the actual precision.
typedef tvec3<uint, aligned_lowp> aligned_lowp_uvec3;
/// 3 components vector of high precision bool numbers.
typedef tvec3<bool, aligned_highp> aligned_highp_bvec3;
/// 3 components vector of medium precision bool numbers.
typedef tvec3<bool, aligned_mediump> aligned_mediump_bvec3;
/// 3 components vector of low precision bool numbers.
typedef tvec3<bool, aligned_lowp> aligned_lowp_bvec3;
// -- *vec4 --
/// 4 components vector of high single-precision floating-point numbers.
typedef tvec4<float, aligned_highp> aligned_highp_vec4;
/// 4 components vector of medium single-precision floating-point numbers.
typedef tvec4<float, aligned_mediump> aligned_mediump_vec4;
/// 4 components vector of low single-precision floating-point numbers.
typedef tvec4<float, aligned_lowp> aligned_lowp_vec4;
/// 4 components vector of high double-precision floating-point numbers.
typedef tvec4<double, aligned_highp> aligned_highp_dvec4;
/// 4 components vector of medium double-precision floating-point numbers.
typedef tvec4<double, aligned_mediump> aligned_mediump_dvec4;
/// 4 components vector of low double-precision floating-point numbers.
typedef tvec4<double, aligned_lowp> aligned_lowp_dvec4;
/// 4 components vector of high precision signed integer numbers.
typedef tvec4<int, aligned_highp> aligned_highp_ivec4;
/// 4 components vector of medium precision signed integer numbers.
typedef tvec4<int, aligned_mediump> aligned_mediump_ivec4;
/// 4 components vector of low precision signed integer numbers.
typedef tvec4<int, aligned_lowp> aligned_lowp_ivec4;
/// 4 components vector of high precision unsigned integer numbers.
typedef tvec4<uint, aligned_highp> aligned_highp_uvec4;
/// 4 components vector of medium precision unsigned integer numbers.
typedef tvec4<uint, aligned_mediump> aligned_mediump_uvec4;
/// 4 components vector of low precision unsigned integer numbers.
typedef tvec4<uint, aligned_lowp> aligned_lowp_uvec4;
/// 4 components vector of high precision bool numbers.
typedef tvec4<bool, aligned_highp> aligned_highp_bvec4;
/// 4 components vector of medium precision bool numbers.
typedef tvec4<bool, aligned_mediump> aligned_mediump_bvec4;
/// 4 components vector of low precision bool numbers.
typedef tvec4<bool, aligned_lowp> 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
+133
View File
@@ -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.
///
/// <glm/gtx/extented_min_max.hpp> 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 <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> min(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z);
/// Return the minimum component-wise values of 3 inputs
/// @see gtx_extented_min_max
template <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> min(
C<T> const & x,
C<T> const & y,
C<T> const & z);
/// Return the minimum component-wise values of 4 inputs
/// @see gtx_extented_min_max
template <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> min(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z,
typename C<T>::T const & w);
/// Return the minimum component-wise values of 4 inputs
/// @see gtx_extented_min_max
template <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> min(
C<T> const & x,
C<T> const & y,
C<T> const & z,
C<T> const & w);
/// Return the maximum component-wise values of 3 inputs
/// @see gtx_extented_min_max
template <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> max(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z);
/// Return the maximum component-wise values of 3 inputs
/// @see gtx_extented_min_max
template <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> max(
C<T> const & x,
C<T> const & y,
C<T> const & z);
/// Return the maximum component-wise values of 4 inputs
/// @see gtx_extented_min_max
template <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> max(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z,
typename C<T>::T const & w);
/// Return the maximum component-wise values of 4 inputs
/// @see gtx_extented_min_max
template <typename T, template <typename> class C>
GLM_FUNC_DECL C<T> max(
C<T> const & x,
C<T> const & y,
C<T> const & z,
C<T> const & w);
/// @}
}//namespace glm
#include "extended_min_max.inl"
+140
View File
@@ -0,0 +1,140 @@
/// @ref gtx_extended_min_max
/// @file glm/gtx/extended_min_max.inl
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER T min(
T const & x,
T const & y,
T const & z)
{
return glm::min(glm::min(x, y), z);
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> min
(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z
)
{
return glm::min(glm::min(x, y), z);
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> min
(
C<T> const & x,
C<T> const & y,
C<T> const & z
)
{
return glm::min(glm::min(x, y), z);
}
template <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> min
(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z,
typename C<T>::T const & w
)
{
return glm::min(glm::min(x, y), glm::min(z, w));
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> min
(
C<T> const & x,
C<T> const & y,
C<T> const & z,
C<T> const & w
)
{
return glm::min(glm::min(x, y), glm::min(z, w));
}
template <typename T>
GLM_FUNC_QUALIFIER T max(
T const & x,
T const & y,
T const & z)
{
return glm::max(glm::max(x, y), z);
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> max
(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z
)
{
return glm::max(glm::max(x, y), z);
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> max
(
C<T> const & x,
C<T> const & y,
C<T> const & z
)
{
return glm::max(glm::max(x, y), z);
}
template <typename T>
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 <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> max
(
C<T> const & x,
typename C<T>::T const & y,
typename C<T>::T const & z,
typename C<T>::T const & w
)
{
return glm::max(glm::max(x, y), glm::max(z, w));
}
template <typename T, template <typename> class C>
GLM_FUNC_QUALIFIER C<T> max
(
C<T> const & x,
C<T> const & y,
C<T> const & z,
C<T> const & w
)
{
return glm::max(glm::max(x, y), glm::max(z, w));
}
}//namespace glm
+14
View File
@@ -0,0 +1,14 @@
/// @ref gtx_float_normalize
/// @file glm/gtx/float_normalize.inl
#include <limits>
namespace glm
{
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<float, P> floatNormalize(vecType<T, P> const & v)
{
return vecType<float, P>(v) / static_cast<float>(std::numeric_limits<T>::max());
}
}//namespace glm
+134
View File
@@ -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
///
/// <glm/gtx/hash.hpp> need to be included to use these functionalities.
#pragma once
#include <functional>
#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 <typename T, glm::precision P>
struct hash<glm::tvec1<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tvec1<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec2<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tvec2<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec3<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tvec3<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tvec4<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tvec4<T, P> const & v) const;
};
template <typename T, glm::precision P>
struct hash<glm::tquat<T,P>>
{
GLM_FUNC_DECL size_t operator()(glm::tquat<T, P> const & q) const;
};
template <typename T, glm::precision P>
struct hash<glm::tdualquat<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,P> const & q) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat2x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat2x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat2x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat2x4<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat3x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat3x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat3x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat3x4<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x2<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat4x2<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x3<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat4x3<T,P> const & m) const;
};
template <typename T, glm::precision P>
struct hash<glm::tmat4x4<T,P> >
{
GLM_FUNC_DECL size_t operator()(glm::tmat4x4<T,P> const & m) const;
};
} // namespace std
#include "hash.inl"
+185
View File
@@ -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
///
/// <glm/gtx/hash.inl> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tvec1<T, P>>::operator()(glm::tvec1<T, P> const & v) const
{
hash<T> hasher;
return hasher(v.x);
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tvec2<T, P>>::operator()(glm::tvec2<T, P> const & v) const
{
size_t seed = 0;
hash<T> hasher;
glm::detail::hash_combine(seed, hasher(v.x));
glm::detail::hash_combine(seed, hasher(v.y));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tvec3<T, P>>::operator()(glm::tvec3<T, P> const & v) const
{
size_t seed = 0;
hash<T> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tvec4<T, P>>::operator()(glm::tvec4<T, P> const & v) const
{
size_t seed = 0;
hash<T> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tquat<T, P>>::operator()(glm::tquat<T,P> const & q) const
{
size_t seed = 0;
hash<T> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tdualquat<T, P>>::operator()(glm::tdualquat<T, P> const & q) const
{
size_t seed = 0;
hash<glm::tquat<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(q.real));
glm::detail::hash_combine(seed, hasher(q.dual));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x2<T, P>>::operator()(glm::tmat2x2<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x3<T, P>>::operator()(glm::tmat2x3<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat2x4<T, P>>::operator()(glm::tmat2x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T, P>> hasher;
glm::detail::hash_combine(seed, hasher(m[0]));
glm::detail::hash_combine(seed, hasher(m[1]));
return seed;
}
template <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x2<T, P>>::operator()(glm::tmat3x2<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T, P>> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x3<T, P>>::operator()(glm::tmat3x3<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T, P>> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat3x4<T, P>>::operator()(glm::tmat3x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T, P>> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x2<T,P>>::operator()(glm::tmat4x2<T,P> const & m) const
{
size_t seed = 0;
hash<glm::tvec2<T, P>> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x3<T,P>>::operator()(glm::tmat4x3<T,P> const & m) const
{
size_t seed = 0;
hash<glm::tvec3<T, P>> 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 <typename T, glm::precision P>
GLM_FUNC_QUALIFIER size_t hash<glm::tmat4x4<T,P>>::operator()(glm::tmat4x4<T, P> const & m) const
{
size_t seed = 0;
hash<glm::tvec4<T, P>> 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;
}
}
+252
View File
@@ -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.
///
/// <glm/gtx/type_trait.hpp> 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 <template <typename, precision> class genType, typename T, precision P>
struct type
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = false;
static length_t const components = 0;
static length_t const cols = 0;
static length_t const rows = 0;
};
template <typename T, precision P>
struct type<tvec1, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
enum
{
components = 1
};
};
template <typename T, precision P>
struct type<tvec2, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
enum
{
components = 2
};
};
template <typename T, precision P>
struct type<tvec3, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
enum
{
components = 3
};
};
template <typename T, precision P>
struct type<tvec4, T, P>
{
static bool const is_vec = true;
static bool const is_mat = false;
static bool const is_quat = false;
enum
{
components = 4
};
};
template <typename T, precision P>
struct type<tmat2x2, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 2,
cols = 2,
rows = 2
};
};
template <typename T, precision P>
struct type<tmat2x3, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 2,
cols = 2,
rows = 3
};
};
template <typename T, precision P>
struct type<tmat2x4, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 2,
cols = 2,
rows = 4
};
};
template <typename T, precision P>
struct type<tmat3x2, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 3,
cols = 3,
rows = 2
};
};
template <typename T, precision P>
struct type<tmat3x3, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 3,
cols = 3,
rows = 3
};
};
template <typename T, precision P>
struct type<tmat3x4, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 3,
cols = 3,
rows = 4
};
};
template <typename T, precision P>
struct type<tmat4x2, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 4,
cols = 4,
rows = 2
};
};
template <typename T, precision P>
struct type<tmat4x3, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 4,
cols = 4,
rows = 3
};
};
template <typename T, precision P>
struct type<tmat4x4, T, P>
{
static bool const is_vec = false;
static bool const is_mat = true;
static bool const is_quat = false;
enum
{
components = 4,
cols = 4,
rows = 4
};
};
template <typename T, precision P>
struct type<tquat, T, P>
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
enum
{
components = 4
};
};
template <typename T, precision P>
struct type<tdualquat, T, P>
{
static bool const is_vec = false;
static bool const is_mat = false;
static bool const is_quat = true;
enum
{
components = 8
};
};
/// @}
}//namespace glm
#include "type_trait.inl"
View File
+240
View File
@@ -0,0 +1,240 @@
/// @ref simd
/// @file glm/simd/common.h
#pragma once
#include "platform.h"
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_add(glm_vec4 a, glm_vec4 b)
{
return _mm_add_ps(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_add(glm_vec4 a, glm_vec4 b)
{
return _mm_add_ss(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sub(glm_vec4 a, glm_vec4 b)
{
return _mm_sub_ps(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_sub(glm_vec4 a, glm_vec4 b)
{
return _mm_sub_ss(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_mul(glm_vec4 a, glm_vec4 b)
{
return _mm_mul_ps(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_mul(glm_vec4 a, glm_vec4 b)
{
return _mm_mul_ss(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_div(glm_vec4 a, glm_vec4 b)
{
return _mm_div_ps(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_div(glm_vec4 a, glm_vec4 b)
{
return _mm_div_ss(a, b);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_div_lowp(glm_vec4 a, glm_vec4 b)
{
return glm_vec4_mul(a, _mm_rcp_ps(b));
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_swizzle_xyzw(glm_vec4 a)
{
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
return _mm_permute_ps(a, _MM_SHUFFLE(3, 2, 1, 0));
# else
return _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 2, 1, 0));
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c)
{
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
return _mm_fmadd_ss(a, b, c);
# else
return _mm_add_ss(_mm_mul_ss(a, b), c);
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_fma(glm_vec4 a, glm_vec4 b, glm_vec4 c)
{
# if GLM_ARCH & GLM_ARCH_AVX2_BIT
return _mm_fmadd_ps(a, b, c);
# else
return glm_vec4_add(glm_vec4_mul(a, b), c);
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_abs(glm_vec4 x)
{
return _mm_and_ps(x, _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)));
}
GLM_FUNC_QUALIFIER glm_ivec4 glm_ivec4_abs(glm_ivec4 x)
{
# if GLM_ARCH & GLM_ARCH_SSSE3_BIT
return _mm_sign_epi32(x, x);
# else
glm_ivec4 const sgn0 = _mm_srai_epi32(x, 31);
glm_ivec4 const inv0 = _mm_xor_si128(x, sgn0);
glm_ivec4 const sub0 = _mm_sub_epi32(inv0, sgn0);
return sub0;
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sign(glm_vec4 x)
{
glm_vec4 const zro0 = _mm_setzero_ps();
glm_vec4 const cmp0 = _mm_cmplt_ps(x, zro0);
glm_vec4 const cmp1 = _mm_cmpgt_ps(x, zro0);
glm_vec4 const and0 = _mm_and_ps(cmp0, _mm_set1_ps(-1.0f));
glm_vec4 const and1 = _mm_and_ps(cmp1, _mm_set1_ps(1.0f));
glm_vec4 const or0 = _mm_or_ps(and0, and1);;
return or0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_round(glm_vec4 x)
{
# if GLM_ARCH & GLM_ARCH_SSE41_BIT
return _mm_round_ps(x, _MM_FROUND_TO_NEAREST_INT);
# else
glm_vec4 const sgn0 = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
glm_vec4 const and0 = _mm_and_ps(sgn0, x);
glm_vec4 const or0 = _mm_or_ps(and0, _mm_set_ps1(8388608.0f));
glm_vec4 const add0 = glm_vec4_add(x, or0);
glm_vec4 const sub0 = glm_vec4_sub(add0, or0);
return sub0;
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_floor(glm_vec4 x)
{
# if GLM_ARCH & GLM_ARCH_SSE41_BIT
return _mm_floor_ps(x);
# else
glm_vec4 const rnd0 = glm_vec4_round(x);
glm_vec4 const cmp0 = _mm_cmplt_ps(x, rnd0);
glm_vec4 const and0 = _mm_and_ps(cmp0, _mm_set1_ps(1.0f));
glm_vec4 const sub0 = glm_vec4_sub(rnd0, and0);
return sub0;
# endif
}
/* trunc TODO
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_trunc(glm_vec4 x)
{
return glm_vec4();
}
*/
//roundEven
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_roundEven(glm_vec4 x)
{
glm_vec4 const sgn0 = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
glm_vec4 const and0 = _mm_and_ps(sgn0, x);
glm_vec4 const or0 = _mm_or_ps(and0, _mm_set_ps1(8388608.0f));
glm_vec4 const add0 = glm_vec4_add(x, or0);
glm_vec4 const sub0 = glm_vec4_sub(add0, or0);
return sub0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_ceil(glm_vec4 x)
{
# if GLM_ARCH & GLM_ARCH_SSE41_BIT
return _mm_ceil_ps(x);
# else
glm_vec4 const rnd0 = glm_vec4_round(x);
glm_vec4 const cmp0 = _mm_cmpgt_ps(x, rnd0);
glm_vec4 const and0 = _mm_and_ps(cmp0, _mm_set1_ps(1.0f));
glm_vec4 const add0 = glm_vec4_add(rnd0, and0);
return add0;
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_fract(glm_vec4 x)
{
glm_vec4 const flr0 = glm_vec4_floor(x);
glm_vec4 const sub0 = glm_vec4_sub(x, flr0);
return sub0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_mod(glm_vec4 x, glm_vec4 y)
{
glm_vec4 const div0 = glm_vec4_div(x, y);
glm_vec4 const flr0 = glm_vec4_floor(div0);
glm_vec4 const mul0 = glm_vec4_mul(y, flr0);
glm_vec4 const sub0 = glm_vec4_sub(x, mul0);
return sub0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_clamp(glm_vec4 v, glm_vec4 minVal, glm_vec4 maxVal)
{
glm_vec4 const min0 = _mm_min_ps(v, maxVal);
glm_vec4 const max0 = _mm_max_ps(min0, minVal);
return max0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_mix(glm_vec4 v1, glm_vec4 v2, glm_vec4 a)
{
glm_vec4 const sub0 = glm_vec4_sub(_mm_set1_ps(1.0f), a);
glm_vec4 const mul0 = glm_vec4_mul(v1, sub0);
glm_vec4 const mad0 = glm_vec4_fma(v2, a, mul0);
return mad0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_step(glm_vec4 edge, glm_vec4 x)
{
glm_vec4 const cmp = _mm_cmple_ps(x, edge);
return _mm_movemask_ps(cmp) == 0 ? _mm_set1_ps(1.0f) : _mm_setzero_ps();
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_smoothstep(glm_vec4 edge0, glm_vec4 edge1, glm_vec4 x)
{
glm_vec4 const sub0 = glm_vec4_sub(x, edge0);
glm_vec4 const sub1 = glm_vec4_sub(edge1, edge0);
glm_vec4 const div0 = glm_vec4_sub(sub0, sub1);
glm_vec4 const clp0 = glm_vec4_clamp(div0, _mm_setzero_ps(), _mm_set1_ps(1.0f));
glm_vec4 const mul0 = glm_vec4_mul(_mm_set1_ps(2.0f), clp0);
glm_vec4 const sub2 = glm_vec4_sub(_mm_set1_ps(3.0f), mul0);
glm_vec4 const mul1 = glm_vec4_mul(clp0, clp0);
glm_vec4 const mul2 = glm_vec4_mul(mul1, sub2);
return mul2;
}
// Agner Fog method
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_nan(glm_vec4 x)
{
glm_ivec4 const t1 = _mm_castps_si128(x); // reinterpret as 32-bit integer
glm_ivec4 const t2 = _mm_sll_epi32(t1, _mm_cvtsi32_si128(1)); // shift out sign bit
glm_ivec4 const t3 = _mm_set1_epi32(0xFF000000); // exponent mask
glm_ivec4 const t4 = _mm_and_si128(t2, t3); // exponent
glm_ivec4 const t5 = _mm_andnot_si128(t3, t2); // fraction
glm_ivec4 const Equal = _mm_cmpeq_epi32(t3, t4);
glm_ivec4 const Nequal = _mm_cmpeq_epi32(t5, _mm_setzero_si128());
glm_ivec4 const And = _mm_and_si128(Equal, Nequal);
return _mm_castsi128_ps(And); // exponent = all 1s and fraction != 0
}
// Agner Fog method
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_inf(glm_vec4 x)
{
glm_ivec4 const t1 = _mm_castps_si128(x); // reinterpret as 32-bit integer
glm_ivec4 const t2 = _mm_sll_epi32(t1, _mm_cvtsi32_si128(1)); // shift out sign bit
return _mm_castsi128_ps(_mm_cmpeq_epi32(t2, _mm_set1_epi32(0xFF000000))); // exponent is all 1s, fraction is 0
}
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
+20
View File
@@ -0,0 +1,20 @@
/// @ref simd
/// @file glm/simd/experimental.h
#pragma once
#include "platform.h"
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_sqrt_lowp(glm_vec4 x)
{
return _mm_mul_ss(_mm_rsqrt_ss(x), x);
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_sqrt_lowp(glm_vec4 x)
{
return _mm_mul_ps(_mm_rsqrt_ps(x), x);
}
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
+124
View File
@@ -0,0 +1,124 @@
/// @ref simd
/// @file glm/simd/geometric.h
#pragma once
#include "common.h"
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_DECL glm_vec4 glm_vec4_dot(glm_vec4 v1, glm_vec4 v2);
GLM_FUNC_DECL glm_vec4 glm_vec1_dot(glm_vec4 v1, glm_vec4 v2);
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_length(glm_vec4 x)
{
glm_vec4 const dot0 = glm_vec4_dot(x, x);
glm_vec4 const sqt0 = _mm_sqrt_ps(dot0);
return sqt0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_distance(glm_vec4 p0, glm_vec4 p1)
{
glm_vec4 const sub0 = _mm_sub_ps(p0, p1);
glm_vec4 const len0 = glm_vec4_length(sub0);
return len0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_dot(glm_vec4 v1, glm_vec4 v2)
{
# if GLM_ARCH & GLM_ARCH_AVX_BIT
return _mm_dp_ps(v1, v2, 0xff);
# elif GLM_ARCH & GLM_ARCH_SSE3_BIT
glm_vec4 const mul0 = _mm_mul_ps(v1, v2);
glm_vec4 const hadd0 = _mm_hadd_ps(mul0, mul0);
glm_vec4 const hadd1 = _mm_hadd_ps(hadd0, hadd0);
return hadd1;
# else
glm_vec4 const mul0 = _mm_mul_ps(v1, v2);
glm_vec4 const swp0 = _mm_shuffle_ps(mul0, mul0, _MM_SHUFFLE(2, 3, 0, 1));
glm_vec4 const add0 = _mm_add_ps(mul0, swp0);
glm_vec4 const swp1 = _mm_shuffle_ps(add0, add0, _MM_SHUFFLE(0, 1, 2, 3));
glm_vec4 const add1 = _mm_add_ps(add0, swp1);
return add1;
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec1_dot(glm_vec4 v1, glm_vec4 v2)
{
# if GLM_ARCH & GLM_ARCH_AVX_BIT
return _mm_dp_ps(v1, v2, 0xff);
# elif GLM_ARCH & GLM_ARCH_SSE3_BIT
glm_vec4 const mul0 = _mm_mul_ps(v1, v2);
glm_vec4 const had0 = _mm_hadd_ps(mul0, mul0);
glm_vec4 const had1 = _mm_hadd_ps(had0, had0);
return had1;
# else
glm_vec4 const mul0 = _mm_mul_ps(v1, v2);
glm_vec4 const mov0 = _mm_movehl_ps(mul0, mul0);
glm_vec4 const add0 = _mm_add_ps(mov0, mul0);
glm_vec4 const swp1 = _mm_shuffle_ps(add0, add0, 1);
glm_vec4 const add1 = _mm_add_ss(add0, swp1);
return add1;
# endif
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_cross(glm_vec4 v1, glm_vec4 v2)
{
glm_vec4 const swp0 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 0, 2, 1));
glm_vec4 const swp1 = _mm_shuffle_ps(v1, v1, _MM_SHUFFLE(3, 1, 0, 2));
glm_vec4 const swp2 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 0, 2, 1));
glm_vec4 const swp3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(3, 1, 0, 2));
glm_vec4 const mul0 = _mm_mul_ps(swp0, swp3);
glm_vec4 const mul1 = _mm_mul_ps(swp1, swp2);
glm_vec4 const sub0 = _mm_sub_ps(mul0, mul1);
return sub0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_normalize(glm_vec4 v)
{
glm_vec4 const dot0 = glm_vec4_dot(v, v);
glm_vec4 const isr0 = _mm_rsqrt_ps(dot0);
glm_vec4 const mul0 = _mm_mul_ps(v, isr0);
return mul0;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_faceforward(glm_vec4 N, glm_vec4 I, glm_vec4 Nref)
{
glm_vec4 const dot0 = glm_vec4_dot(Nref, I);
glm_vec4 const sgn0 = glm_vec4_sign(dot0);
glm_vec4 const mul0 = _mm_mul_ps(sgn0, _mm_set1_ps(-1.0f));
glm_vec4 const mul1 = _mm_mul_ps(N, mul0);
return mul1;
}
GLM_FUNC_QUALIFIER glm_vec4 glm_vec4_reflect(glm_vec4 I, glm_vec4 N)
{
glm_vec4 const dot0 = glm_vec4_dot(N, I);
glm_vec4 const mul0 = _mm_mul_ps(N, dot0);
glm_vec4 const mul1 = _mm_mul_ps(mul0, _mm_set1_ps(2.0f));
glm_vec4 const sub0 = _mm_sub_ps(I, mul1);
return sub0;
}
GLM_FUNC_QUALIFIER __m128 glm_vec4_refract(glm_vec4 I, glm_vec4 N, glm_vec4 eta)
{
glm_vec4 const dot0 = glm_vec4_dot(N, I);
glm_vec4 const mul0 = _mm_mul_ps(eta, eta);
glm_vec4 const mul1 = _mm_mul_ps(dot0, dot0);
glm_vec4 const sub0 = _mm_sub_ps(_mm_set1_ps(1.0f), mul0);
glm_vec4 const sub1 = _mm_sub_ps(_mm_set1_ps(1.0f), mul1);
glm_vec4 const mul2 = _mm_mul_ps(sub0, sub1);
if(_mm_movemask_ps(_mm_cmplt_ss(mul2, _mm_set1_ps(0.0f))) == 0)
return _mm_set1_ps(0.0f);
glm_vec4 const sqt0 = _mm_sqrt_ps(mul2);
glm_vec4 const mad0 = glm_vec4_fma(eta, dot0, sqt0);
glm_vec4 const mul4 = _mm_mul_ps(mad0, N);
glm_vec4 const mul5 = _mm_mul_ps(eta, I);
glm_vec4 const sub2 = _mm_sub_ps(mul5, mul4);
return sub2;
}
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
+115
View File
@@ -0,0 +1,115 @@
/// @ref simd
/// @file glm/simd/integer.h
#pragma once
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
GLM_FUNC_QUALIFIER glm_uvec4 glm_i128_interleave(glm_uvec4 x)
{
glm_uvec4 const Mask4 = _mm_set1_epi32(0x0000FFFF);
glm_uvec4 const Mask3 = _mm_set1_epi32(0x00FF00FF);
glm_uvec4 const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
glm_uvec4 const Mask1 = _mm_set1_epi32(0x33333333);
glm_uvec4 const Mask0 = _mm_set1_epi32(0x55555555);
glm_uvec4 Reg1;
glm_uvec4 Reg2;
// REG1 = x;
// REG2 = y;
//Reg1 = _mm_unpacklo_epi64(x, y);
Reg1 = x;
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
return Reg1;
}
GLM_FUNC_QUALIFIER glm_uvec4 glm_i128_interleave2(glm_uvec4 x, glm_uvec4 y)
{
glm_uvec4 const Mask4 = _mm_set1_epi32(0x0000FFFF);
glm_uvec4 const Mask3 = _mm_set1_epi32(0x00FF00FF);
glm_uvec4 const Mask2 = _mm_set1_epi32(0x0F0F0F0F);
glm_uvec4 const Mask1 = _mm_set1_epi32(0x33333333);
glm_uvec4 const Mask0 = _mm_set1_epi32(0x55555555);
glm_uvec4 Reg1;
glm_uvec4 Reg2;
// REG1 = x;
// REG2 = y;
Reg1 = _mm_unpacklo_epi64(x, y);
//REG1 = ((REG1 << 16) | REG1) & glm::uint64(0x0000FFFF0000FFFF);
//REG2 = ((REG2 << 16) | REG2) & glm::uint64(0x0000FFFF0000FFFF);
Reg2 = _mm_slli_si128(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask4);
//REG1 = ((REG1 << 8) | REG1) & glm::uint64(0x00FF00FF00FF00FF);
//REG2 = ((REG2 << 8) | REG2) & glm::uint64(0x00FF00FF00FF00FF);
Reg2 = _mm_slli_si128(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask3);
//REG1 = ((REG1 << 4) | REG1) & glm::uint64(0x0F0F0F0F0F0F0F0F);
//REG2 = ((REG2 << 4) | REG2) & glm::uint64(0x0F0F0F0F0F0F0F0F);
Reg2 = _mm_slli_epi32(Reg1, 4);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask2);
//REG1 = ((REG1 << 2) | REG1) & glm::uint64(0x3333333333333333);
//REG2 = ((REG2 << 2) | REG2) & glm::uint64(0x3333333333333333);
Reg2 = _mm_slli_epi32(Reg1, 2);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask1);
//REG1 = ((REG1 << 1) | REG1) & glm::uint64(0x5555555555555555);
//REG2 = ((REG2 << 1) | REG2) & glm::uint64(0x5555555555555555);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg1 = _mm_or_si128(Reg2, Reg1);
Reg1 = _mm_and_si128(Reg1, Mask0);
//return REG1 | (REG2 << 1);
Reg2 = _mm_slli_epi32(Reg1, 1);
Reg2 = _mm_srli_si128(Reg2, 8);
Reg1 = _mm_or_si128(Reg1, Reg2);
return Reg1;
}
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
/// @ref simd
/// @file glm/simd/packing.h
#pragma once
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
+452
View File
@@ -0,0 +1,452 @@
/// @ref simd
/// @file glm/simd/platform.h
#pragma once
///////////////////////////////////////////////////////////////////////////////////
// Platform
#define GLM_PLATFORM_UNKNOWN 0x00000000
#define GLM_PLATFORM_WINDOWS 0x00010000
#define GLM_PLATFORM_LINUX 0x00020000
#define GLM_PLATFORM_APPLE 0x00040000
//#define GLM_PLATFORM_IOS 0x00080000
#define GLM_PLATFORM_ANDROID 0x00100000
#define GLM_PLATFORM_CHROME_NACL 0x00200000
#define GLM_PLATFORM_UNIX 0x00400000
#define GLM_PLATFORM_QNXNTO 0x00800000
#define GLM_PLATFORM_WINCE 0x01000000
#define GLM_PLATFORM_CYGWIN 0x02000000
#ifdef GLM_FORCE_PLATFORM_UNKNOWN
# define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
#elif defined(__CYGWIN__)
# define GLM_PLATFORM GLM_PLATFORM_CYGWIN
#elif defined(__QNXNTO__)
# define GLM_PLATFORM GLM_PLATFORM_QNXNTO
#elif defined(__APPLE__)
# define GLM_PLATFORM GLM_PLATFORM_APPLE
#elif defined(WINCE)
# define GLM_PLATFORM GLM_PLATFORM_WINCE
#elif defined(_WIN32)
# define GLM_PLATFORM GLM_PLATFORM_WINDOWS
#elif defined(__native_client__)
# define GLM_PLATFORM GLM_PLATFORM_CHROME_NACL
#elif defined(__ANDROID__)
# define GLM_PLATFORM GLM_PLATFORM_ANDROID
#elif defined(__linux)
# define GLM_PLATFORM GLM_PLATFORM_LINUX
#elif defined(__unix)
# define GLM_PLATFORM GLM_PLATFORM_UNIX
#else
# define GLM_PLATFORM GLM_PLATFORM_UNKNOWN
#endif//
// Report platform detection
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_PLATFORM_DISPLAYED)
# define GLM_MESSAGE_PLATFORM_DISPLAYED
# if(GLM_PLATFORM & GLM_PLATFORM_QNXNTO)
# pragma message("GLM: QNX platform detected")
//# elif(GLM_PLATFORM & GLM_PLATFORM_IOS)
//# pragma message("GLM: iOS platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_APPLE)
# pragma message("GLM: Apple platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_WINCE)
# pragma message("GLM: WinCE platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_WINDOWS)
# pragma message("GLM: Windows platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_CHROME_NACL)
# pragma message("GLM: Native Client detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID)
# pragma message("GLM: Android platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_LINUX)
# pragma message("GLM: Linux platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_UNIX)
# pragma message("GLM: UNIX platform detected")
# elif(GLM_PLATFORM & GLM_PLATFORM_UNKNOWN)
# pragma message("GLM: platform unknown")
# else
# pragma message("GLM: platform not detected")
# endif
#endif//GLM_MESSAGES
///////////////////////////////////////////////////////////////////////////////////
// Compiler
#define GLM_COMPILER_UNKNOWN 0x00000000
// Intel
#define GLM_COMPILER_INTEL 0x00100000
#define GLM_COMPILER_INTEL12 0x00100010
#define GLM_COMPILER_INTEL12_1 0x00100020
#define GLM_COMPILER_INTEL13 0x00100030
#define GLM_COMPILER_INTEL14 0x00100040
#define GLM_COMPILER_INTEL15 0x00100050
#define GLM_COMPILER_INTEL16 0x00100060
// Visual C++ defines
#define GLM_COMPILER_VC 0x01000000
#define GLM_COMPILER_VC10 0x01000090
#define GLM_COMPILER_VC11 0x010000A0
#define GLM_COMPILER_VC12 0x010000B0
#define GLM_COMPILER_VC14 0x010000C0
#define GLM_COMPILER_VC15 0x010000D0
// GCC defines
#define GLM_COMPILER_GCC 0x02000000
#define GLM_COMPILER_GCC44 0x020000B0
#define GLM_COMPILER_GCC45 0x020000C0
#define GLM_COMPILER_GCC46 0x020000D0
#define GLM_COMPILER_GCC47 0x020000E0
#define GLM_COMPILER_GCC48 0x020000F0
#define GLM_COMPILER_GCC49 0x02000100
#define GLM_COMPILER_GCC50 0x02000200
#define GLM_COMPILER_GCC51 0x02000300
#define GLM_COMPILER_GCC52 0x02000400
#define GLM_COMPILER_GCC53 0x02000500
#define GLM_COMPILER_GCC54 0x02000600
#define GLM_COMPILER_GCC60 0x02000700
#define GLM_COMPILER_GCC61 0x02000800
#define GLM_COMPILER_GCC62 0x02000900
#define GLM_COMPILER_GCC70 0x02000A00
#define GLM_COMPILER_GCC71 0x02000B00
#define GLM_COMPILER_GCC72 0x02000C00
#define GLM_COMPILER_GCC80 0x02000D00
// CUDA
#define GLM_COMPILER_CUDA 0x10000000
#define GLM_COMPILER_CUDA40 0x10000040
#define GLM_COMPILER_CUDA41 0x10000050
#define GLM_COMPILER_CUDA42 0x10000060
#define GLM_COMPILER_CUDA50 0x10000070
#define GLM_COMPILER_CUDA60 0x10000080
#define GLM_COMPILER_CUDA65 0x10000090
#define GLM_COMPILER_CUDA70 0x100000A0
#define GLM_COMPILER_CUDA75 0x100000B0
#define GLM_COMPILER_CUDA80 0x100000C0
// Clang
#define GLM_COMPILER_CLANG 0x20000000
#define GLM_COMPILER_CLANG32 0x20000030
#define GLM_COMPILER_CLANG33 0x20000040
#define GLM_COMPILER_CLANG34 0x20000050
#define GLM_COMPILER_CLANG35 0x20000060
#define GLM_COMPILER_CLANG36 0x20000070
#define GLM_COMPILER_CLANG37 0x20000080
#define GLM_COMPILER_CLANG38 0x20000090
#define GLM_COMPILER_CLANG39 0x200000A0
#define GLM_COMPILER_CLANG40 0x200000B0
#define GLM_COMPILER_CLANG41 0x200000C0
#define GLM_COMPILER_CLANG42 0x200000D0
// Build model
#define GLM_MODEL_32 0x00000010
#define GLM_MODEL_64 0x00000020
// Force generic C++ compiler
#ifdef GLM_FORCE_COMPILER_UNKNOWN
# define GLM_COMPILER GLM_COMPILER_UNKNOWN
#elif defined(__INTEL_COMPILER)
# if __INTEL_COMPILER == 1200
# define GLM_COMPILER GLM_COMPILER_INTEL12
# elif __INTEL_COMPILER == 1210
# define GLM_COMPILER GLM_COMPILER_INTEL12_1
# elif __INTEL_COMPILER == 1300
# define GLM_COMPILER GLM_COMPILER_INTEL13
# elif __INTEL_COMPILER == 1400
# define GLM_COMPILER GLM_COMPILER_INTEL14
# elif __INTEL_COMPILER == 1500
# define GLM_COMPILER GLM_COMPILER_INTEL15
# elif __INTEL_COMPILER >= 1600
# define GLM_COMPILER GLM_COMPILER_INTEL16
# else
# define GLM_COMPILER GLM_COMPILER_INTEL
# endif
// CUDA
#elif defined(__CUDACC__)
# if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA)
# include <cuda.h> // make sure version is defined since nvcc does not define it itself!
# endif
# if CUDA_VERSION < 3000
# error "GLM requires CUDA 3.0 or higher"
# else
# define GLM_COMPILER GLM_COMPILER_CUDA
# endif
// Clang
#elif defined(__clang__)
# if GLM_PLATFORM & GLM_PLATFORM_APPLE
# if __clang_major__ == 5 && __clang_minor__ == 0
# define GLM_COMPILER GLM_COMPILER_CLANG33
# elif __clang_major__ == 5 && __clang_minor__ == 1
# define GLM_COMPILER GLM_COMPILER_CLANG34
# elif __clang_major__ == 6 && __clang_minor__ == 0
# define GLM_COMPILER GLM_COMPILER_CLANG35
# elif __clang_major__ == 6 && __clang_minor__ >= 1
# define GLM_COMPILER GLM_COMPILER_CLANG36
# elif __clang_major__ >= 7
# define GLM_COMPILER GLM_COMPILER_CLANG37
# else
# define GLM_COMPILER GLM_COMPILER_CLANG
# endif
# else
# if __clang_major__ == 3 && __clang_minor__ == 0
# define GLM_COMPILER GLM_COMPILER_CLANG30
# elif __clang_major__ == 3 && __clang_minor__ == 1
# define GLM_COMPILER GLM_COMPILER_CLANG31
# elif __clang_major__ == 3 && __clang_minor__ == 2
# define GLM_COMPILER GLM_COMPILER_CLANG32
# elif __clang_major__ == 3 && __clang_minor__ == 3
# define GLM_COMPILER GLM_COMPILER_CLANG33
# elif __clang_major__ == 3 && __clang_minor__ == 4
# define GLM_COMPILER GLM_COMPILER_CLANG34
# elif __clang_major__ == 3 && __clang_minor__ == 5
# define GLM_COMPILER GLM_COMPILER_CLANG35
# elif __clang_major__ == 3 && __clang_minor__ == 6
# define GLM_COMPILER GLM_COMPILER_CLANG36
# elif __clang_major__ == 3 && __clang_minor__ == 7
# define GLM_COMPILER GLM_COMPILER_CLANG37
# elif __clang_major__ == 3 && __clang_minor__ == 8
# define GLM_COMPILER GLM_COMPILER_CLANG38
# elif __clang_major__ == 3 && __clang_minor__ >= 9
# define GLM_COMPILER GLM_COMPILER_CLANG39
# elif __clang_major__ == 4 && __clang_minor__ == 0
# define GLM_COMPILER GLM_COMPILER_CLANG40
# elif __clang_major__ == 4 && __clang_minor__ == 1
# define GLM_COMPILER GLM_COMPILER_CLANG41
# elif __clang_major__ == 4 && __clang_minor__ >= 2
# define GLM_COMPILER GLM_COMPILER_CLANG42
# elif __clang_major__ >= 4
# define GLM_COMPILER GLM_COMPILER_CLANG42
# else
# define GLM_COMPILER GLM_COMPILER_CLANG
# endif
# endif
// Visual C++
#elif defined(_MSC_VER)
# if _MSC_VER < 1600
# error "GLM requires Visual C++ 10 - 2010 or higher"
# elif _MSC_VER == 1600
# define GLM_COMPILER GLM_COMPILER_VC11
# elif _MSC_VER == 1700
# define GLM_COMPILER GLM_COMPILER_VC11
# elif _MSC_VER == 1800
# define GLM_COMPILER GLM_COMPILER_VC12
# elif _MSC_VER == 1900
# define GLM_COMPILER GLM_COMPILER_VC14
# elif _MSC_VER >= 1910
# define GLM_COMPILER GLM_COMPILER_VC15
# else//_MSC_VER
# define GLM_COMPILER GLM_COMPILER_VC
# endif//_MSC_VER
// G++
#elif defined(__GNUC__) || defined(__MINGW32__)
# if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC42)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 3)
# define GLM_COMPILER (GLM_COMPILER_GCC43)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
# define GLM_COMPILER (GLM_COMPILER_GCC44)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 5)
# define GLM_COMPILER (GLM_COMPILER_GCC45)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6)
# define GLM_COMPILER (GLM_COMPILER_GCC46)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7)
# define GLM_COMPILER (GLM_COMPILER_GCC47)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
# define GLM_COMPILER (GLM_COMPILER_GCC48)
# elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
# define GLM_COMPILER (GLM_COMPILER_GCC49)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 0)
# define GLM_COMPILER (GLM_COMPILER_GCC50)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 1)
# define GLM_COMPILER (GLM_COMPILER_GCC51)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC52)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ == 3)
# define GLM_COMPILER (GLM_COMPILER_GCC53)
# elif (__GNUC__ == 5) && (__GNUC_MINOR__ >= 4)
# define GLM_COMPILER (GLM_COMPILER_GCC54)
# elif (__GNUC__ == 6) && (__GNUC_MINOR__ == 0)
# define GLM_COMPILER (GLM_COMPILER_GCC60)
# elif (__GNUC__ == 6) && (__GNUC_MINOR__ == 1)
# define GLM_COMPILER (GLM_COMPILER_GCC61)
# elif (__GNUC__ == 6) && (__GNUC_MINOR__ >= 2)
# define GLM_COMPILER (GLM_COMPILER_GCC62)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 0)
# define GLM_COMPILER (GLM_COMPILER_GCC70)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 1)
# define GLM_COMPILER (GLM_COMPILER_GCC71)
# elif (__GNUC__ == 7) && (__GNUC_MINOR__ == 2)
# define GLM_COMPILER (GLM_COMPILER_GCC72)
# elif (__GNUC__ >= 8)
# define GLM_COMPILER (GLM_COMPILER_GCC80)
# else
# define GLM_COMPILER (GLM_COMPILER_GCC)
# endif
#else
# define GLM_COMPILER GLM_COMPILER_UNKNOWN
#endif
#ifndef GLM_COMPILER
# error "GLM_COMPILER undefined, your compiler may not be supported by GLM. Add #define GLM_COMPILER 0 to ignore this message."
#endif//GLM_COMPILER
///////////////////////////////////////////////////////////////////////////////////
// Instruction sets
// User defines: GLM_FORCE_PURE GLM_FORCE_SSE2 GLM_FORCE_SSE3 GLM_FORCE_AVX GLM_FORCE_AVX2 GLM_FORCE_AVX2
#define GLM_ARCH_X86_BIT 0x00000001
#define GLM_ARCH_SSE2_BIT 0x00000002
#define GLM_ARCH_SSE3_BIT 0x00000004
#define GLM_ARCH_SSSE3_BIT 0x00000008
#define GLM_ARCH_SSE41_BIT 0x00000010
#define GLM_ARCH_SSE42_BIT 0x00000020
#define GLM_ARCH_AVX_BIT 0x00000040
#define GLM_ARCH_AVX2_BIT 0x00000080
#define GLM_ARCH_AVX512_BIT 0x00000100 // Skylake subset
#define GLM_ARCH_ARM_BIT 0x00000100
#define GLM_ARCH_NEON_BIT 0x00000200
#define GLM_ARCH_MIPS_BIT 0x00010000
#define GLM_ARCH_PPC_BIT 0x01000000
#define GLM_ARCH_PURE (0x00000000)
#define GLM_ARCH_X86 (GLM_ARCH_X86_BIT)
#define GLM_ARCH_SSE2 (GLM_ARCH_SSE2_BIT | GLM_ARCH_X86)
#define GLM_ARCH_SSE3 (GLM_ARCH_SSE3_BIT | GLM_ARCH_SSE2)
#define GLM_ARCH_SSSE3 (GLM_ARCH_SSSE3_BIT | GLM_ARCH_SSE3)
#define GLM_ARCH_SSE41 (GLM_ARCH_SSE41_BIT | GLM_ARCH_SSSE3)
#define GLM_ARCH_SSE42 (GLM_ARCH_SSE42_BIT | GLM_ARCH_SSE41)
#define GLM_ARCH_AVX (GLM_ARCH_AVX_BIT | GLM_ARCH_SSE42)
#define GLM_ARCH_AVX2 (GLM_ARCH_AVX2_BIT | GLM_ARCH_AVX)
#define GLM_ARCH_AVX512 (GLM_ARCH_AVX512_BIT | GLM_ARCH_AVX2) // Skylake subset
#define GLM_ARCH_ARM (GLM_ARCH_ARM_BIT)
#define GLM_ARCH_NEON (GLM_ARCH_NEON_BIT | GLM_ARCH_ARM)
#define GLM_ARCH_MIPS (GLM_ARCH_MIPS_BIT)
#define GLM_ARCH_PPC (GLM_ARCH_PPC_BIT)
#if defined(GLM_FORCE_PURE)
# define GLM_ARCH GLM_ARCH_PURE
#elif defined(GLM_FORCE_MIPS)
# define GLM_ARCH (GLM_ARCH_MIPS)
#elif defined(GLM_FORCE_PPC)
# define GLM_ARCH (GLM_ARCH_PPC)
#elif defined(GLM_FORCE_NEON)
# define GLM_ARCH (GLM_ARCH_NEON)
#elif defined(GLM_FORCE_AVX512)
# define GLM_ARCH (GLM_ARCH_AVX512)
#elif defined(GLM_FORCE_AVX2)
# define GLM_ARCH (GLM_ARCH_AVX2)
#elif defined(GLM_FORCE_AVX)
# define GLM_ARCH (GLM_ARCH_AVX)
#elif defined(GLM_FORCE_SSE42)
# define GLM_ARCH (GLM_ARCH_SSE42)
#elif defined(GLM_FORCE_SSE41)
# define GLM_ARCH (GLM_ARCH_SSE41)
#elif defined(GLM_FORCE_SSSE3)
# define GLM_ARCH (GLM_ARCH_SSSE3)
#elif defined(GLM_FORCE_SSE3)
# define GLM_ARCH (GLM_ARCH_SSE3)
#elif defined(GLM_FORCE_SSE2)
# define GLM_ARCH (GLM_ARCH_SSE2)
#elif (GLM_COMPILER & (GLM_COMPILER_CLANG | GLM_COMPILER_GCC)) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_LINUX))
// This is Skylake set of instruction set
# if defined(__AVX512BW__) && defined(__AVX512F__) && defined(__AVX512CD__) && defined(__AVX512VL__) && defined(__AVX512DQ__)
# define GLM_ARCH (GLM_ARCH_AVX512)
# elif defined(__AVX2__)
# define GLM_ARCH (GLM_ARCH_AVX2)
# elif defined(__AVX__)
# define GLM_ARCH (GLM_ARCH_AVX)
# elif defined(__SSE4_2__)
# define GLM_ARCH (GLM_ARCH_SSE42)
# elif defined(__SSE4_1__)
# define GLM_ARCH (GLM_ARCH_SSE41)
# elif defined(__SSSE3__)
# define GLM_ARCH (GLM_ARCH_SSSE3)
# elif defined(__SSE3__)
# define GLM_ARCH (GLM_ARCH_SSE3)
# elif defined(__SSE2__)
# define GLM_ARCH (GLM_ARCH_SSE2)
# elif defined(__i386__) || defined(__x86_64__)
# define GLM_ARCH (GLM_ARCH_X86)
# elif defined(__ARM_NEON)
# define GLM_ARCH (GLM_ARCH_ARM | GLM_ARCH_NEON)
# elif defined(__arm__ )
# define GLM_ARCH (GLM_ARCH_ARM)
# elif defined(__mips__ )
# define GLM_ARCH (GLM_ARCH_MIPS)
# elif defined(__powerpc__ )
# define GLM_ARCH (GLM_ARCH_PPC)
# else
# define GLM_ARCH (GLM_ARCH_PURE)
# endif
#elif (GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))
# if defined(_M_ARM)
# define GLM_ARCH (GLM_ARCH_ARM)
# elif defined(__AVX2__)
# define GLM_ARCH (GLM_ARCH_AVX2)
# elif defined(__AVX__)
# define GLM_ARCH (GLM_ARCH_AVX)
# elif defined(_M_X64)
# define GLM_ARCH (GLM_ARCH_SSE2)
# elif defined(_M_IX86_FP)
# if _M_IX86_FP >= 2
# define GLM_ARCH (GLM_ARCH_SSE2)
# else
# define GLM_ARCH (GLM_ARCH_PURE)
# endif
# elif defined(_M_PPC)
# define GLM_ARCH (GLM_ARCH_PPC)
# else
# define GLM_ARCH (GLM_ARCH_PURE)
# endif
#else
# define GLM_ARCH GLM_ARCH_PURE
#endif
// With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is
// that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems.
// To fix, we just explicitly include intrin.h here.
#if defined(__MINGW64__) && (GLM_ARCH != GLM_ARCH_PURE)
# include <intrin.h>
#endif
#if GLM_ARCH & GLM_ARCH_AVX2_BIT
# include <immintrin.h>
#elif GLM_ARCH & GLM_ARCH_AVX_BIT
# include <immintrin.h>
#elif GLM_ARCH & GLM_ARCH_SSE42_BIT
# if GLM_COMPILER & GLM_COMPILER_CLANG
# include <popcntintrin.h>
# endif
# include <nmmintrin.h>
#elif GLM_ARCH & GLM_ARCH_SSE41_BIT
# include <smmintrin.h>
#elif GLM_ARCH & GLM_ARCH_SSSE3_BIT
# include <tmmintrin.h>
#elif GLM_ARCH & GLM_ARCH_SSE3_BIT
# include <pmmintrin.h>
#elif GLM_ARCH & GLM_ARCH_SSE2_BIT
# include <emmintrin.h>
#endif//GLM_ARCH
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
typedef __m128 glm_vec4;
typedef __m128i glm_ivec4;
typedef __m128i glm_uvec4;
#endif
#if GLM_ARCH & GLM_ARCH_AVX_BIT
typedef __m256d glm_dvec4;
#endif
#if GLM_ARCH & GLM_ARCH_AVX2_BIT
typedef __m256i glm_i64vec4;
typedef __m256i glm_u64vec4;
#endif
+9
View File
@@ -0,0 +1,9 @@
/// @ref simd
/// @file glm/simd/trigonometric.h
#pragma once
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
+8
View File
@@ -0,0 +1,8 @@
/// @ref simd
/// @file glm/simd/vector_relational.h
#pragma once
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT