Browse Source

Added rect SIMD optimization

Christophe Riccio 9 years ago
parent
commit
c8c298fef4
2 changed files with 25 additions and 4 deletions
  1. 12 3
      glm/detail/func_geometric.inl
  2. 13 1
      glm/detail/func_geometric_simd.inl

+ 12 - 3
glm/detail/func_geometric.inl

@@ -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

+ 13 - 1
glm/detail/func_geometric_simd.inl

@@ -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