Skip to content

Commit

Permalink
Update GLM to 0.9.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed Mar 3, 2020
1 parent 8f52b98 commit 346b127
Show file tree
Hide file tree
Showing 49 changed files with 2,143 additions and 556 deletions.
8 changes: 6 additions & 2 deletions libs/glm/include/glm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE ../)

if(BUILD_STATIC_LIBS)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
Expand All @@ -52,6 +53,8 @@ add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_static PUBLIC glm)
add_library(glm::glm_static ALIAS glm_static)
endif()

if(BUILD_SHARED_LIBS)
Expand All @@ -62,5 +65,6 @@ add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_shared PUBLIC glm)
add_library(glm::glm_shared ALIAS glm_shared)
endif()

8 changes: 4 additions & 4 deletions libs/glm/include/glm/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ namespace glm
///
/// @see <a href="https://www.opengl.org/sdk/docs/manglsl/xhtml/frexp.xml">GLSL frexp man page</a>
/// @see <a href="https://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType frexp(genType const& x, genIType& exp);
template<typename genType>
GLM_FUNC_DECL genType frexp(genType x, int& exp);

template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> frexp(vec<L, T, Q> const& v, vec<L, int, Q>& exp);
Expand All @@ -526,8 +526,8 @@ namespace glm
///
/// @see <a href="https://www.opengl.org/sdk/docs/manglsl/xhtml/ldexp.xml">GLSL ldexp man page</a>;
/// @see <a href="https://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genType, typename genIType>
GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp);
template<typename genType>
GLM_FUNC_DECL genType ldexp(genType const& x, int const& exp);

template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL vec<L, T, Q> ldexp(vec<L, T, Q> const& v, vec<L, int, Q> const& exp);
Expand Down
39 changes: 39 additions & 0 deletions libs/glm/include/glm/detail/_vectorize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,44 @@ namespace detail
return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
}
};

template<length_t L, typename T, qualifier Q>
struct functor2_vec_int {};

template<typename T, qualifier Q>
struct functor2_vec_int<1, T, Q>
{
GLM_FUNC_QUALIFIER static vec<1, int, Q> call(int (*Func) (T x, int y), vec<1, T, Q> const& a, vec<1, int, Q> const& b)
{
return vec<1, int, Q>(Func(a.x, b.x));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<2, T, Q>
{
GLM_FUNC_QUALIFIER static vec<2, int, Q> call(int (*Func) (T x, int y), vec<2, T, Q> const& a, vec<2, int, Q> const& b)
{
return vec<2, int, Q>(Func(a.x, b.x), Func(a.y, b.y));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<3, T, Q>
{
GLM_FUNC_QUALIFIER static vec<3, int, Q> call(int (*Func) (T x, int y), vec<3, T, Q> const& a, vec<3, int, Q> const& b)
{
return vec<3, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
}
};

template<typename T, qualifier Q>
struct functor2_vec_int<4, T, Q>
{
GLM_FUNC_QUALIFIER static vec<4, int, Q> call(int (*Func) (T x, int y), vec<4, T, Q> const& a, vec<4, int, Q> const& b)
{
return vec<4, int, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
}
};
}//namespace detail
}//namespace glm
19 changes: 12 additions & 7 deletions libs/glm/include/glm/detail/func_common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace detail
{
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& edge0, vec<L, T, Q> const& edge1, vec<L, T, Q> const& x)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'step' only accept floating-point inputs");
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'smoothstep' only accept floating-point inputs");
vec<L, T, Q> const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast<T>(0), static_cast<T>(1)));
return tmp * tmp * (static_cast<T>(3) - static_cast<T>(2) * tmp);
}
Expand Down Expand Up @@ -287,7 +287,8 @@ namespace detail
std::numeric_limits<genFIType>::is_iec559 || (std::numeric_limits<genFIType>::is_signed && std::numeric_limits<genFIType>::is_integer),
"'sign' only accept signed inputs");

return detail::compute_sign<1, genFIType, defaultp, std::numeric_limits<genFIType>::is_iec559, highp>::call(vec<1, genFIType>(x)).x;
return detail::compute_sign<1, genFIType, defaultp,
std::numeric_limits<genFIType>::is_iec559, detail::is_aligned<highp>::value>::call(vec<1, genFIType>(x)).x;
}

template<length_t L, typename T, qualifier Q>
Expand Down Expand Up @@ -737,11 +738,15 @@ namespace detail
return reinterpret_cast<vec<L, float, Q>&>(const_cast<vec<L, uint, Q>&>(v));
}

template<typename genType>
GLM_FUNC_QUALIFIER genType fma(genType const& a, genType const& b, genType const& c)
{
return a * b + c;
}
# if GLM_HAS_CXX11_STL
using std::fma;
# else
template<typename genType>
GLM_FUNC_QUALIFIER genType fma(genType const& a, genType const& b, genType const& c)
{
return a * b + c;
}
# endif

template<typename genType>
GLM_FUNC_QUALIFIER genType frexp(genType x, int& exp)
Expand Down
66 changes: 66 additions & 0 deletions libs/glm/include/glm/detail/func_geometric_simd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,70 @@ namespace detail
}//namespace detail
}//namespace glm

#elif GLM_ARCH & GLM_ARCH_NEON_BIT
namespace glm{
namespace detail
{
template<qualifier Q>
struct compute_length<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& v)
{
return compute_dot<vec<4, float, Q>, float, true>::call(v, v);
}
};

template<qualifier Q>
struct compute_distance<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& p0, vec<4, float, Q> const& p1)
{
return compute_length<4, float, Q, true>::call(p1 - p0);
}
};


template<qualifier Q>
struct compute_dot<vec<4, float, Q>, float, true>
{
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& x, vec<4, float, Q> const& y)
{
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
float32x4_t v = vmulq_f32(x.data, y.data);
v = vpaddq_f32(v, v);
v = vpaddq_f32(v, v);
return vgetq_lane_f32(v, 0);
#else // Armv7a with Neon
float32x4_t p = vmulq_f32(x.data, y.data);
float32x2_t v = vpadd_f32(vget_low_f32(p), vget_high_f32(p));
v = vpadd_f32(v, v);
return vget_lane_f32(v, 0);
#endif
}
};

template<qualifier Q>
struct compute_normalize<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
float32x4_t p = vmulq_f32(v.data, v.data);
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
p = vpaddq_f32(p, p);
p = vpaddq_f32(p, p);
#else
float32x2_t t = vpadd_f32(vget_low_f32(p), vget_high_f32(p));
t = vpadd_f32(t, t);
p = vcombine_f32(t, t);
#endif

float32x4_t vd = vrsqrteq_f32(p);
vec<4, float, Q> Result;
Result.data = vmulq_f32(v.data, vd);
return Result;
}
};
}//namespace detail
}//namespace glm

#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
22 changes: 16 additions & 6 deletions libs/glm/include/glm/detail/func_integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ namespace detail
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType bitfieldInsert(genIUType const& Base, genIUType const& Insert, int Offset, int Bits)
{
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldInsert' only accept integer values");

return bitfieldInsert(vec<1, genIUType>(Base), vec<1, genIUType>(Insert), Offset, Bits).x;
}

Expand All @@ -273,15 +275,19 @@ namespace detail
}

// bitfieldReverse
template<typename genType>
GLM_FUNC_QUALIFIER genType bitfieldReverse(genType x)
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType x)
{
return bitfieldReverse(glm::vec<1, genType, glm::defaultp>(x)).x;
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitfieldReverse' only accept integer values");

return bitfieldReverse(glm::vec<1, genIUType, glm::defaultp>(x)).x;
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> bitfieldReverse(vec<L, T, Q> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldReverse' only accept integer values");

vec<L, T, Q> x(v);
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 2>::call(x, static_cast<T>(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, Q, detail::is_aligned<Q>::value, sizeof(T) * 8>= 4>::call(x, static_cast<T>(0x3333333333333333ull), static_cast<T>( 2));
Expand All @@ -293,15 +299,19 @@ namespace detail
}

// bitCount
template<typename genType>
GLM_FUNC_QUALIFIER int bitCount(genType x)
template<typename genIUType>
GLM_FUNC_QUALIFIER int bitCount(genIUType x)
{
return bitCount(glm::vec<1, genType, glm::defaultp>(x)).x;
GLM_STATIC_ASSERT(std::numeric_limits<genIUType>::is_integer, "'bitCount' only accept integer values");

return bitCount(glm::vec<1, genIUType, glm::defaultp>(x)).x;
}

template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, int, Q> bitCount(vec<L, T, Q> const& v)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitCount' only accept integer values");

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4310) //cast truncates constant value
Expand Down
Loading

0 comments on commit 346b127

Please sign in to comment.