Marshalling in C# can be extremely slow. Thus, now that .NET 6 has come with NativeMemory, it is preferrable to use unsafe operations as much as we can.
One first step has been done: instead of using Unity's NativeArray for the ImageFrame class, we have used a raw byte* pointer and the tests worked flawlessly.
Nothing has been benchmarked so far, but we can infer from how marshalling works that using unsafe will benefit us in the long run.
Marshalling in C# can be extremely slow. Thus, now that .NET 6 has come with
NativeMemory
, it is preferrable to useunsafe
operations as much as we can.One first step has been done: instead of using Unity's
NativeArray
for theImageFrame
class, we have used a rawbyte*
pointer and the tests worked flawlessly.Nothing has been benchmarked so far, but we can infer from how marshalling works that using
unsafe
will benefit us in the long run.