diff --git a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs
index 8f08ebb9..8d855bfb 100644
--- a/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/ReadBackTexture2DExtensions.cs
@@ -1,5 +1,6 @@
using System;
using ComputeSharp.Graphics.Helpers;
+using ComputeSharp.Resources;
namespace ComputeSharp;
@@ -8,6 +9,52 @@ namespace ComputeSharp;
///
public static class ReadBackTexture2DExtensions
{
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the texture.
+ /// The target instance to write data to.
+ /// The input instance to read data from.
+ public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
+ }
+
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the texture.
+ /// The target instance to write data to.
+ /// The input instance to read data from.
+ /// The horizontal offset in the source texture.
+ /// The vertical offset in the source texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
+ }
+
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the texture.
+ /// The target instance to write data to.
+ /// The input instance to read data from.
+ /// The horizontal offset in the source texture.
+ /// The vertical offset in the source texture.
+ /// The horizontal offset in the destination texture.
+ /// The vertical offset in the destination texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyFrom(this ReadBackTexture2D destination, Texture2D source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
+ }
+
///
/// Saves a texture to a specified file.
///
diff --git a/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs
index 96599509..675aab5d 100644
--- a/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/UploadTexture2DExtensions.cs
@@ -34,4 +34,22 @@ public static class UploadTexture2DExtensions
{
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
}
+
+ ///
+ /// Reads the contents of a instance and writes them into a target instance.
+ ///
+ /// The type of items stored on the texture.
+ /// The input instance to read data from.
+ /// The target instance to write data to.
+ /// The horizontal offset in the source texture.
+ /// The vertical offset in the source texture.
+ /// The horizontal offset in the destination texture.
+ /// The vertical offset in the destination texture.
+ /// The width of the memory area to copy.
+ /// The height of the memory area to copy.
+ public static void CopyTo(this UploadTexture2D source, Texture2D destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
+ where T : unmanaged
+ {
+ destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
+ }
}