Added rect SIMD optimization

master
Christophe Riccio ago%!(EXTRA string=9 years)
parent f6810a9c0e
commit c8c298fef4
  1. 15
      glm/detail/func_geometric.inl
  2. 14
      glm/detail/func_geometric_simd.inl

@ -87,6 +87,15 @@ namespace detail
return dot(Nref, I) < static_cast<T>(0) ? N : -N; 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 }//namespace detail
// length // length
@ -174,10 +183,10 @@ namespace detail
} }
// reflect // reflect
template <typename genType> template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER genType reflect(genType const & I, genType const & N) 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 // refract

@ -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) 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); tvec4<float, P> result(uninitialize);
result.data = ffd0; result.data = ffd0;
return result; 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 detail
}//namespace glm }//namespace glm

Loading…
Cancel
Save