From 28cb770d14d998689ae14e510dd8a59dc596e2cc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 29 May 2016 19:14:39 +0200 Subject: [PATCH] SIMD common functions optimizations --- glm/detail/func_common.inl | 36 ++++++++++++++++++++++----------- glm/detail/func_common_simd.inl | 24 ++++++++++++++++++++-- test/core/core_func_common.cpp | 2 +- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 02468cc1..3e3a0b77 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -283,6 +283,26 @@ namespace detail return min(max(x, minVal), maxVal); } }; + + template class vecType> + struct compute_step_vector + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & edge, vecType const & x) + { + return mix(vecType(1), vecType(0), glm::lessThan(x, edge)); + } + }; + + template class vecType> + struct compute_smoothstep_vector + { + GLM_FUNC_QUALIFIER static vecType call(vecType const & edge0, vecType const & edge1, vecType const & x) + { + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'step' only accept floating-point inputs"); + vecType const tmp(clamp((x - edge0) / (edge1 - edge0), static_cast(0), static_cast(1))); + return tmp * tmp * (static_cast(3) - static_cast(2) * tmp); + } + }; }//namespace detail template @@ -561,15 +581,13 @@ namespace detail template