diff --git a/src/DirectX12GameEngine.Core/MemoryHelper.cs b/src/DirectX12GameEngine.Core/MemoryHelper.cs index 4fef2426..908799e0 100644 --- a/src/DirectX12GameEngine.Core/MemoryHelper.cs +++ b/src/DirectX12GameEngine.Core/MemoryHelper.cs @@ -3,31 +3,33 @@ using System.Runtime.CompilerServices; namespace DirectX12GameEngine.Core { + /// + /// A with some helper methods to copy data between memory areas + /// public static class MemoryHelper { - public static unsafe void Copy(IntPtr source, IntPtr destination, int sizeInBytesToCopy) - { - Copy(new Span(source.ToPointer(), sizeInBytesToCopy), destination); - } - + /// + /// Copies the content of a to the area pointed by an input value + /// + /// The type of values in the input + /// The source to read + /// The for the destination memory area + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(Span source, IntPtr destination) where T : unmanaged { source.CopyTo(new Span(destination.ToPointer(), source.Length)); } + /// + /// Copies a memory area pointed by an value to a target + /// + /// The type of values to read + /// The that indicates the memory area to read from + /// The destination to write + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(IntPtr source, Span destination) where T : unmanaged { new Span(source.ToPointer(), destination.Length).CopyTo(destination); } - - public static unsafe void Copy(in T source, IntPtr destination) where T : unmanaged - { - Unsafe.Copy(destination.ToPointer(), ref Unsafe.AsRef(source)); - } - - public static unsafe void Copy(IntPtr source, ref T destination) where T : unmanaged - { - Unsafe.Copy(ref destination, source.ToPointer()); - } } }