diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
index 79407efe..60c4f5bb 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
@@ -61,7 +61,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
///
/// The pointer to the mapped resource.
///
- public readonly IntPtr Pointer;
+ public readonly void* Pointer;
///
/// Creates a new instance for a given value.
diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
index b15fbaaa..32d1772c 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
@@ -38,7 +38,7 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
using MappedResource resource = transferBuffer.MapResource();
- MemoryHelper.Copy(resource.Pointer, 0, span, 0, count);
+ MemoryHelper.Copy(resource.Pointer, 0, span, count);
}
///
diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
index 415af033..6de580b6 100644
--- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
@@ -68,7 +68,7 @@ namespace ComputeSharp
Unsafe.Add(ref spanRef, i) = Unsafe.As(ref targetRef);
}
}
- else MemoryHelper.Copy(resource.Pointer, offset, span, 0, count);
+ else MemoryHelper.Copy(resource.Pointer, offset, span, count);
}
///
diff --git a/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs b/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs
index a2011a6a..4f1b286d 100644
--- a/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs
+++ b/src/ComputeSharp.Graphics/Extensions/ID3D12ResourceExtensions.cs
@@ -15,13 +15,13 @@ namespace ComputeSharp.Graphics.Extensions
/// The target to map.
/// A pointer to the mapped area for .
/// Thrown when the mapping operation fails.
- public static IntPtr Map(this ref ID3D12Resource d3d12resource)
+ public static void* Map(this ref ID3D12Resource d3d12resource)
{
- IntPtr ptr;
+ void* pointer;
- d3d12resource.Map(0, null, (void**)&ptr).Assert();
+ d3d12resource.Map(0, null, &pointer).Assert();
- return ptr;
+ return pointer;
}
///
diff --git a/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs b/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs
index b9911acb..252f0463 100644
--- a/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs
+++ b/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs
@@ -4,41 +4,39 @@ using System.Runtime.CompilerServices;
namespace ComputeSharp.Graphics.Helpers
{
///
- /// A with some helper methods to copy data between memory areas
+ /// A with some helper methods to copy data between memory areas.
///
internal static class MemoryHelper
{
///
- /// Copies the content of a to the area pointed by an input value
+ /// 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
- /// The destination offset to start writing data to
- /// The total number of items to copy
+ /// The type of values in the input .
+ /// The source to read.
+ /// The pointer for the destination memory area.
+ /// The destination offset to start writing data to.
+ /// The total number of items to copy.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe void Copy(ReadOnlySpan source, IntPtr destination, int destinationOffset, int count) where T : unmanaged
+ public static unsafe void Copy(ReadOnlySpan source, void* destination, int destinationOffset, int count)
+ where T : unmanaged
{
- T* p = (T*)destination.ToPointer() + destinationOffset;
-
- source.CopyTo(new Span(p, count));
+ source.CopyTo(new Span((T*)destination + destinationOffset, count));
}
///
- /// Copies a memory area pointed by an value to a target
+ /// 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 source offset to start reading data from
- /// The destination to write
- /// The destination offset to start writing data to
- /// The total number of items to copy
+ /// The type of values to read.
+ /// The that indicates the memory area to read from.
+ /// The source offset to start reading data from.
+ /// The destination to write.
+ /// The destination offset to start writing data to.
+ /// The total number of items to copy.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe void Copy(IntPtr source, int sourceOffset, Span destination, int destinationOffset, int count) where T : unmanaged
+ public static unsafe void Copy(void* source, int sourceOffset, Span destination, int count)
+ where T : unmanaged
{
- ref T rin = ref Unsafe.AsRef(source.ToPointer());
- void* target = Unsafe.AsPointer(ref Unsafe.Add(ref rin, sourceOffset));
- new Span(target, count).CopyTo(destination.Slice(destinationOffset, count));
+ new Span((T*)source + sourceOffset, count).CopyTo(destination.Slice(0, count));
}
}
}