Added SIMD optimization for geometric functions
This commit is contained in:
parent
fb66c79ca4
commit
f6810a9c0e
@ -76,6 +76,17 @@ namespace detail
|
|||||||
return v * inversesqrt(dot(v, v));
|
return v * inversesqrt(dot(v, v));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
|
struct compute_faceforward
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & N, vecType<T, P> const & I, vecType<T, P> const & Nref)
|
||||||
|
{
|
||||||
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
|
||||||
|
|
||||||
|
return dot(Nref, I) < static_cast<T>(0) ? N : -N;
|
||||||
|
}
|
||||||
|
};
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
|
|
||||||
// length
|
// length
|
||||||
@ -146,7 +157,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'normalize' accepts only floating-point inputs");
|
||||||
|
|
||||||
return x * inversesqrt(dot(x, x));
|
return detail::compute_normalize<T, P, vecType>::call(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// faceforward
|
// faceforward
|
||||||
@ -159,7 +170,7 @@ namespace detail
|
|||||||
template <typename T, precision P, template <typename, precision> class vecType>
|
template <typename T, precision P, template <typename, precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> faceforward(vecType<T, P> const & N, vecType<T, P> const & I, vecType<T, P> const & Nref)
|
GLM_FUNC_QUALIFIER vecType<T, P> faceforward(vecType<T, P> const & N, vecType<T, P> const & I, vecType<T, P> const & Nref)
|
||||||
{
|
{
|
||||||
return dot(Nref, I) < static_cast<T>(0) ? N : -N;
|
return detail::compute_faceforward<T, P, vecType>::call(N, I, Nref);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reflect
|
// reflect
|
||||||
|
@ -42,6 +42,18 @@ namespace detail
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <precision P>
|
||||||
|
struct compute_faceforward<float, P, tvec4>
|
||||||
|
{
|
||||||
|
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & N, tvec4<float, P> const & I, tvec4<float, P> const & Nref)
|
||||||
|
{
|
||||||
|
__m128 const ffd0 = glm_f32v4_ffd(v.data);
|
||||||
|
tvec4<float, P> result(uninitialize);
|
||||||
|
result.data = ffd0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
}//namespace detail
|
}//namespace detail
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user