Browse Source

Added missing SIMD implementations

Christophe Riccio 15 years ago
parent
commit
a511553d8e
3 changed files with 19 additions and 3 deletions
  1. 7 0
      glm/gtx/simd_mat4.hpp
  2. 10 3
      glm/gtx/simd_mat4.inl
  3. 2 0
      test/gtx/gtx-simd-mat4.cpp

+ 7 - 0
glm/gtx/simd_mat4.hpp

@@ -134,6 +134,13 @@ namespace glm
 	{
 		typedef detail::fmat4x4SIMD simd_mat4;
 
+		//! Multiply matrix x by matrix y component-wise, i.e., 
+		//! result[i][j] is the scalar product of x[i][j] and y[i][j].
+		//! (From GLM_GTX_simd_mat4 extension).
+		detail::fmat4x4SIMD simd_matrixCompMult(
+			detail::fmat4x4SIMD const & x,
+			detail::fmat4x4SIMD const & y);
+
 		//! Returns the transposed matrix of x
 		//! (From GLM_GTX_simd_mat4 extension).
 		detail::fmat4x4SIMD simd_transpose(detail::fmat4x4SIMD const & m);

+ 10 - 3
glm/gtx/simd_mat4.inl

@@ -237,13 +237,18 @@ namespace detail
 namespace gtx{
 namespace simd_mat4
 {
-	inline detail::fmat4x4SIMD matrixCompMult
+	inline detail::fmat4x4SIMD simd_matrixCompMult
 	(
 		detail::fmat4x4SIMD const & x,
 		detail::fmat4x4SIMD const & y
 	)
 	{
-		//GLM_STATIC_ASSERT(0, "TODO");
+		detail::fmat4x4SIMD result;
+		result[0] = x[0] * y[0];
+		result[1] = x[1] * y[1];
+		result[2] = x[2] * y[2];
+		result[3] = x[3] * y[3];
+		return result;
 	}
 
 	inline detail::fmat4x4SIMD simd_transpose(detail::fmat4x4SIMD const & m)
@@ -255,7 +260,9 @@ namespace simd_mat4
 
 	inline float simd_determinant(detail::fmat4x4SIMD const & m)
 	{
-		//GLM_STATIC_ASSERT(0, "TODO");
+		float Result;
+		_mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data));
+		return Result;
 	}
 
 	inline detail::fmat4x4SIMD simd_inverse(detail::fmat4x4SIMD const & m)

+ 2 - 0
test/gtx/gtx-simd-mat4.cpp

@@ -274,6 +274,8 @@ int main()
 	Failed += test_compute_glm();
 	Failed += test_compute_gtx();
 	
+	float Det = glm::simd_determinant(glm::simd_mat4(1.0));
+	glm::simd_mat4 B = glm::simd_matrixCompMult(glm::simd_mat4(1.0), glm::simd_mat4(1.0));
 
 	system("pause");