Ver Fonte

Optimizations

Panagiotis Christopoulos Charitos há 14 anos atrás
pai
commit
347db5b280

+ 3 - 0
docs/todo

@@ -0,0 +1,3 @@
+- The light passes in IS should produce 1, 0, 1 and the play with the scene ambient color to see the results of the blending
+- Create n working threads with n contexts and make the IS parallel
+- Put uniform buffers in skinning 

BIN
engine-rsrc/pyramid.blend1


BIN
engine-rsrc/shpere.blend1


+ 0 - 0
engine-rsrc/shpere.blend → engine-rsrc/sphere.blend


+ 4 - 0
src/Math/Mat4.h

@@ -38,6 +38,10 @@ class Mat4
 		const float& operator()(const uint i, const uint j) const;
 		float& operator[](const uint i);
 		const float& operator[](const uint i) const;
+		#if defined(MATH_INTEL_SIMD)
+			__m128& getMm(uint i);
+			const __m128& getMm(uint i) const;
+		#endif
 		/// @}
 
 		/// @name Operators with same type

+ 11 - 0
src/Math/Mat4.inl.h

@@ -190,6 +190,17 @@ inline const float& Mat4::operator[](const uint i) const
 	return arr1[i];
 }
 
+#if defined(MATH_INTEL_SIMD)
+	const __m128& Mat4::getMm(uint i) const
+	{
+		return arrMm[i];
+	}
+	
+	__m128& Mat4::getMm(uint i)
+	{
+		return arrMm[i];
+	}
+#endif
 
 //======================================================================================================================
 // Operators with same                                                                                                 =

+ 15 - 5
src/Math/Vec3.inl.h

@@ -413,11 +413,21 @@ inline void Vec3::transform(const Vec3& translate, const Quat& rotate, float sca
 // Mat4
 inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 {
-	return Vec3(
-		transform(0, 0) * x() + transform(0, 1) * y() + transform(0, 2) * z() + transform(0, 3),
-		transform(1, 0) * x() + transform(1, 1) * y() + transform(1, 2) * z() + transform(1, 3),
-		transform(2, 0) * x() + transform(2, 1) * y() + transform(2, 2) * z() + transform(2, 3)
-	);
+	#if defined(MATH_INTEL_SIMD)
+		Vec3 out;
+		Vec4 v4(SELF, 1.0);
+		for(int i = 0; i < 3; i++)
+		{
+			_mm_store_ss(&out[i], _mm_dp_ps(transform.getMm(i), v4.getMm(), 0xF1));
+		}
+		return out;
+	#else
+		return Vec3(
+			transform(0, 0) * x() + transform(0, 1) * y() + transform(0, 2) * z() + transform(0, 3),
+			transform(1, 0) * x() + transform(1, 1) * y() + transform(1, 2) * z() + transform(1, 3),
+			transform(2, 0) * x() + transform(2, 1) * y() + transform(2, 2) * z() + transform(2, 3)
+		);
+	#endif
 }
 
 // Mat4