diff --git a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
index 9b675154..10e9e0ee 100644
--- a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
+++ b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
@@ -203,6 +203,178 @@ namespace ComputeSharp
return readWriteBuffer;
}
+ ///
+ /// Allocates a new readonly 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A zeroed instance of size [, ].
+ [Pure]
+ public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, int width, int height)
+ where T : unmanaged
+ {
+ return new(device, width, height);
+ }
+
+ ///
+ /// Allocates a new readonly 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[] array, int width, int height)
+ where T : unmanaged
+ {
+ return device.AllocateReadOnlyTexture2D(array, width, height);
+ }
+
+ ///
+ /// Allocates a new readonly 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// The starting offset within to read data from.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[] array, int offset, int width, int height)
+ where T : unmanaged
+ {
+ return device.AllocateReadOnlyTexture2D(array.AsSpan(offset), width, height);
+ }
+
+ ///
+ /// Allocates a new readonly 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// A read write instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, T[,] array)
+ where T : unmanaged
+ {
+ ReadOnlyTexture2D texture = new(device, array.GetLength(1), array.GetLength(0));
+
+ texture.SetData(array);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new readonly 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input with the data to copy on the allocated texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input span.
+ [Pure]
+ public static ReadOnlyTexture2D AllocateReadOnlyTexture2D(this GraphicsDevice device, ReadOnlySpan span, int width, int height)
+ where T : unmanaged
+ {
+ ReadOnlyTexture2D texture = new(device, width, height);
+
+ texture.SetData(span);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new writeable 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A zeroed instance of size [, ].
+ [Pure]
+ public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, int width, int height)
+ where T : unmanaged
+ {
+ return new(device, width, height);
+ }
+
+ ///
+ /// Allocates a new writeable 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[] array, int width, int height)
+ where T : unmanaged
+ {
+ return device.AllocateReadWriteTexture2D(array, width, height);
+ }
+
+ ///
+ /// Allocates a new writeable 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// The starting offset within to read data from.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[] array, int offset, int width, int height)
+ where T : unmanaged
+ {
+ return device.AllocateReadWriteTexture2D(array.AsSpan(offset), width, height);
+ }
+
+ ///
+ /// Allocates a new writeable 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input array with the data to copy on the allocated texture.
+ /// A read write instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, T[,] array)
+ where T : unmanaged
+ {
+ ReadWriteTexture2D texture = new(device, array.GetLength(1), array.GetLength(0));
+
+ texture.SetData(array);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new writeable 2D texture with the specified parameters.
+ ///
+ /// The type of items to store in the texture.
+ /// The instance to use to allocate the texture.
+ /// The input with the data to copy on the allocated texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// A instance with the contents of the input span.
+ [Pure]
+ public static ReadWriteTexture2D AllocateReadWriteTexture2D(this GraphicsDevice device, ReadOnlySpan span, int width, int height)
+ where T : unmanaged
+ {
+ ReadWriteTexture2D texture = new(device, width, height);
+
+ texture.SetData(span);
+
+ return texture;
+ }
+
///
/// Compiles and runs the input shader on a target instance, with the specified parameters.
///