Hi all,
i started making 2D engine based on SFML.Net and i came to point where i started handling Mouse events.
Soon i ended up in Transform.cs file and saw that is calling C++ implementation. And i was wondering how costy is Managed <-> Unmanaged barrier for something like TransformPoint so i started checking and found out following:
Transform TransformPoint:1111
MyTransform TransformPoint:119
Transform TransformRect:1312
MyTransform TransformRect:419
Transform Multiply(Identity):1603
MyTransform Multiply(Identity):401
Transform Multiply:553
MyTransform Multiply:545
Transform Rotate:1823
MyTransform Rotate:1043
Transform Translate:1389
MyTransform Translate:262
Transform Scale:524
MyTransform Scale:513
Transform Inverse:1913
MyTransform Inverse:897
Program used for comparison:
https://gist.github.com/DavidKarlas/c3abb1fcb5a26fd1c5e4MyTransform:
https://gist.github.com/DavidKarlas/931b090e2c8a05c52aa9What i found out during testing this code is that C# is slower then C++ when it comes to wierd float values like mutiplying NaN or Infinity values. That is why Scale and Multiply are so close. Because after few loops Infinity numbers appear and C# goes slower but that probably wont happend in real case but speedup wont be better then 4x(Multiply(Identity)) either.
Most important to me is TransformPoint 10x speed up because i will have alot of nested drawables and will have to calculate mouse hit point.
I also tested what this means in general rendering...
I created 188.000 small sprites with random rotation, scale and positions(doesn't matter but wanted abit more complex matrix) and i came from 16 fps to 20fps just by switching Transform to MyTransform inside SFML.net.
I also noticed that GetInverse and Rotate could use double instead of float for better accurarcy without any speed loss.
Laurent is there any chance you could take a look at this and implement it?