From ef6f153f382ec4b990597feb96ac2b95a3a6d669 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 11 Aug 2019 01:46:23 +0200 Subject: [PATCH] Added missing documentation --- src/DirectX12GameEngine.Core/MemoryHelper.cs | 32 +++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) 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()); - } } }