-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of System.Numerics.VectorX #64
Comments
Hi @nikeee! Thanks for the suggestions! I think it's a nice idea! The You may consider performing calculations using @drewnoakes Any suggestions will be helpful! |
Using the
I doubt the layout would change though. It looks identical to Implicit conversions can be convenient but can also be suprising. They can also result in redundant copying of values, compared to reusing |
I tried this one out (with Vector2 and Matrix3x2) and it works pretty well: |
Is it possible to tackle this or find any solution? I see that the library was ported to .NET 6, which was one of my core goals for nud2dlib (though at that time, it was .NET 5). They both do basically the same, the only difference for now being that nud2dlib uses Vector2/Vector3 and Matrix3x2 in in some places where D2DPoint or D2DSize is used. However, the projects start to diverge in some ways. For example, d2dlib recently enhanced the text rendering capabilities. While I'm fine with backporting stuff, I'd also like to give back some of my efforts (like #30, #65 and #82). One non-breaking solution would be to add a some overloads to the functions recieving I that something you'd see in the scope of this project? |
@jingwood would it be feasible to remove |
@nikeee @drewnoakes OK, use |
@nikeee @drewnoakes If possible please have a review for #97 |
Very cool! I'll do a review tomorrow! :) |
Fixed in #97. |
I love this library.
One thing I noticed:
I often need to convert the structs
D2DPoint
toVector2
.One reason being that VectorX structs have operator overloading. The other reason is that they support JIT intrinsics and take advantage of SIMD extensions of the CPU, so math operations are much faster with them.
Is it possible to use them directly with this library? Vector2 is basically this struct:
Notice: It does not have the SequentialLayout attribute, so it might be padded during runtime. However, the .NET docs state:
To get an idea, this is the Vector2 implementation:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs
If these structs are ABI compatible, one could just pass them instead of D2DPoint etc. Ist would eliminate conversions as well as increase performance due to hardware acceleration.
Edit:
Matrix3x2 also seems that it has the same binary layout as the one in System.Numerics:
https://github.com/dotnet/runtime/blob/01b7e73cd378145264a7cb7a09365b41ed42b240/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix3x2.cs#L82
Any chances on something in that direction?
The text was updated successfully, but these errors were encountered: