diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/StructuredBuffer{T}.cs
index a2ce007c..45658a3f 100644
--- a/src/ComputeSharp.Graphics/Resources/Abstract/StructuredBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Resources/Abstract/StructuredBuffer{T}.cs
@@ -80,8 +80,14 @@ namespace ComputeSharp.Resources
}
}
- ///
- public unsafe void GetData(ReadBackBuffer destination, int destinationOffset, int length, int offset)
+ ///
+ /// Reads the contents of the specified range from the current instance and writes them into a target instance.
+ ///
+ /// The target instance to write data to.
+ /// The starting offset within to write data to.
+ /// The number of items to read.
+ /// The offset to start reading data from.
+ internal unsafe void GetData(ReadBackBuffer destination, int destinationOffset, int length, int offset)
{
GraphicsDevice.ThrowIfDisposed();
@@ -156,8 +162,14 @@ namespace ComputeSharp.Resources
}
}
- ///
- public unsafe void SetData(UploadBuffer source, int sourceOffset, int length, int offset)
+ ///
+ /// Reads the contents of the specified range from an input instance and writes them to the current the current instance.
+ ///
+ /// The input instance to read data from.
+ /// The starting offset within to read data from.
+ /// The number of items to read.
+ /// The offset to start reading writing data to.
+ internal unsafe void SetData(UploadBuffer source, int sourceOffset, int length, int offset)
{
GraphicsDevice.ThrowIfDisposed();
diff --git a/src/ComputeSharp/Extensions/Resources/BufferExtensions.cs b/src/ComputeSharp/Extensions/Resources/BufferExtensions.cs
index 5fe675bc..6c1fd022 100644
--- a/src/ComputeSharp/Extensions/Resources/BufferExtensions.cs
+++ b/src/ComputeSharp/Extensions/Resources/BufferExtensions.cs
@@ -46,7 +46,7 @@ namespace ComputeSharp
}
///
- /// Reads the contents of s instance and writes them into a target array.
+ /// Reads the contents of a instance and writes them into a target array.
///
/// The type of items stored on the buffer.
/// The input instance to read data from.
@@ -58,7 +58,7 @@ namespace ComputeSharp
}
///
- /// Reads the contents of the specified range from s instance and writes them into a target array.
+ /// Reads the contents of the specified range from a instance and writes them into a target array.
///
/// The type of items stored on the buffer.
/// The input instance to read data from.
diff --git a/src/ComputeSharp/Extensions/Resources/StructuredBufferExtensions.cs b/src/ComputeSharp/Extensions/Resources/StructuredBufferExtensions.cs
new file mode 100644
index 00000000..488ab3ba
--- /dev/null
+++ b/src/ComputeSharp/Extensions/Resources/StructuredBufferExtensions.cs
@@ -0,0 +1,39 @@
+using System.Diagnostics.Contracts;
+using ComputeSharp.Resources;
+
+namespace ComputeSharp
+{
+ ///
+ /// A that contains extension methods for the type.
+ ///
+ public static class StructuredBufferExtensions
+ {
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the buffer.
+ /// The input instance to read data from.
+ /// The target instance to write data to.
+ [Pure]
+ public static void CopyTo(this StructuredBuffer buffer, ReadBackBuffer destination)
+ where T : unmanaged
+ {
+ buffer.GetData(destination, 0, buffer.Length, 0);
+ }
+
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the buffer.
+ /// The input instance to read data from.
+ /// The target instance to write data to.
+ /// The starting offset within to write data to.
+ /// The offset to start reading data from.
+ /// The number of items to read.
+ public static void CopyTo(this StructuredBuffer buffer, ReadBackBuffer destination, int destinationOffset, int bufferOffset, int count)
+ where T : unmanaged
+ {
+ buffer.GetData(destination, destinationOffset, count, bufferOffset);
+ }
+ }
+}
diff --git a/src/ComputeSharp/Extensions/Resources/UploadBufferExtensions.cs b/src/ComputeSharp/Extensions/Resources/UploadBufferExtensions.cs
new file mode 100644
index 00000000..00ebdef6
--- /dev/null
+++ b/src/ComputeSharp/Extensions/Resources/UploadBufferExtensions.cs
@@ -0,0 +1,39 @@
+using System.Diagnostics.Contracts;
+using ComputeSharp.Resources;
+
+namespace ComputeSharp
+{
+ ///
+ /// A that contains extension methods for the type.
+ ///
+ public static class UploadBufferExtensions
+ {
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the buffer.
+ /// The input instance to read data from.
+ /// The target instance to write data to.
+ [Pure]
+ public static void CopyTo(this UploadBuffer buffer, StructuredBuffer destination)
+ where T : unmanaged
+ {
+ destination.SetData(buffer, 0, buffer.Length, 0);
+ }
+
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the buffer.
+ /// The input instance to read data from.
+ /// The target instance to write data to.
+ /// The starting offset within to write data to.
+ /// The offset to start reading data from.
+ /// The number of items to read.
+ public static void CopyTo(this UploadBuffer buffer, StructuredBuffer destination, int destinationOffset, int bufferOffset, int count)
+ where T : unmanaged
+ {
+ destination.SetData(buffer, bufferOffset, count, destinationOffset);
+ }
+ }
+}