Closed Shawdooow closed 2 years ago
Actually to my extreme amazement testing in .net6.0
has revealed that the crazy if
statements were as fast as an Unsafe.As
cast and MemoryMarshal is slower.
Could be different for the version of net this project is compiled against, definitely warrants further investigation...
Using Unsafe.As
wasn't any faster than all those crazy if statements because the JIT was working overtime on it. The if statements are slower when the JIT can't guarantee that an array with 3 or greater items is being fed into it.
Note the bottom function shown is using floats NOT bytes
I can't actually compile this repo to test how these changes interact with each other but I can say that I tested them individually and they all appear to work.
Why can't you compile the repo? I can help surely.
Can you guaranty that Vector structs and Quaternion Lenght (sizeof) is always correct. (see https://stackoverflow.com/questions/42695067/unsafe-as-from-byte-array-to-ulong-array).
I have already implemented modifications in other project of mine with Span and ReadOnlySpan, and I've not yet optimized vke. I knew it was to be done, thanks for the time you spend on this.
The size and layout of Vector
s and Quaternion
s in memory shouldn't ever change.
It should also be noted that despite W
at the top of those structs in code in memory they are last (which I only learned doing this pr)
On a semi-unrelated note, do you have a slack or discord server related to your vulkan repos?
I have just invited you into my Gitter channel (https://gitter.im/CSharpRapidOpenWidgets/) (I should rename it)
Use unsafe magic to cast memory for free!
Also added new
SubArray
function