Added rect SIMD optimization

This commit is contained in:
Christophe Riccio 2016-05-28 22:09:30 +02:00
parent f6810a9c0e
commit c8c298fef4
2 changed files with 25 additions and 4 deletions

View File

@ -87,6 +87,15 @@ namespace detail
return dot(Nref, I) < static_cast<T>(0) ? N : -N;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_reflect
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const & I, vecType<T, P> const & N)
{
return I - N * dot(N, I) * static_cast<T>(2);
}
};
}//namespace detail
// length
@ -174,10 +183,10 @@ namespace detail
}
// reflect
template <typename genType>
GLM_FUNC_QUALIFIER genType reflect(genType const & I, genType const & N)
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> reflect(vecType<T, P> const & I, vecType<T, P> const & N)
{
return I - N * dot(N, I) * static_cast<genType>(2);
return detail::compute_reflect<T, P, vecType>::call(I, N);
}
// refract

View File

@ -48,12 +48,24 @@ namespace detail
{
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);
__m128 const ffd0 = glm_f32v4_ffd(N.data. I.data, Nref.data);
tvec4<float, P> result(uninitialize);
result.data = ffd0;
return result;
}
};
template <precision P>
struct compute_reflect<float, P, tvec4>
{
GLM_FUNC_QUALIFIER static tvec4<float, P> call(tvec4<float, P> const & I, tvec4<float, P> const & N)
{
__m128 const rfe0 = glm_f32v4_rfe(I.data, N.data);
tvec4<float, P> result(uninitialize);
result.data = rfe0;
return result;
}
};
}//namespace detail
}//namespace glm