diff --git a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
index 303397c2..9e889be2 100644
--- a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
+++ b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
@@ -375,6 +375,194 @@ namespace ComputeSharp
return texture;
}
+ ///
+ /// Allocates a new readonly 3D 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.
+ /// The depth of the texture.
+ /// A zeroed instance of size [, , ].
+ [Pure]
+ public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return new(device, width, height, depth);
+ }
+
+ ///
+ /// Allocates a new readonly 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[] array, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return device.AllocateReadOnlyTexture3D(array.AsSpan(), width, height, depth);
+ }
+
+ ///
+ /// Allocates a new readonly 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return device.AllocateReadOnlyTexture3D(array.AsSpan(offset), width, height, depth);
+ }
+
+ ///
+ /// Allocates a new readonly 3D 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.
+ ///
+ /// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, unlike .NET arrays
+ /// which are traditionally of size [H, W, D], the input one needs to have a layout of [D, H, W].
+ ///
+ [Pure]
+ public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, T[,,] array)
+ where T : unmanaged
+ {
+ ReadOnlyTexture3D texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
+
+ texture.SetData(array);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new readonly 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input .
+ [Pure]
+ public static ReadOnlyTexture3D AllocateReadOnlyTexture3D(this GraphicsDevice device, ReadOnlySpan span, int width, int height, int depth)
+ where T : unmanaged
+ {
+ ReadOnlyTexture3D texture = new(device, width, height, depth);
+
+ texture.SetData(span);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new writeable 3D 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.
+ /// The depth of the texture.
+ /// A zeroed instance of size [, ].
+ [Pure]
+ public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return new(device, width, height, depth);
+ }
+
+ ///
+ /// Allocates a new writeable 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[] array, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return device.AllocateReadWriteTexture3D(array.AsSpan(), width, height, depth);
+ }
+
+ ///
+ /// Allocates a new writeable 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
+ where T : unmanaged
+ {
+ return device.AllocateReadWriteTexture3D(array.AsSpan(offset), width, height, depth);
+ }
+
+ ///
+ /// Allocates a new writeable 3D 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.
+ ///
+ /// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, unlike .NET arrays
+ /// which are traditionally of size [H, W, D], the input one needs to have a layout of [D, H, W].
+ ///
+ [Pure]
+ public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, T[,,] array)
+ where T : unmanaged
+ {
+ ReadWriteTexture3D texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
+
+ texture.SetData(array);
+
+ return texture;
+ }
+
+ ///
+ /// Allocates a new writeable 3D 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.
+ /// The depth of the texture.
+ /// A instance with the contents of the input .
+ [Pure]
+ public static ReadWriteTexture3D AllocateReadWriteTexture3D(this GraphicsDevice device, ReadOnlySpan span, int width, int height, int depth)
+ where T : unmanaged
+ {
+ ReadWriteTexture3D texture = new(device, width, height, depth);
+
+ texture.SetData(span);
+
+ return texture;
+ }
+
///
/// Compiles and runs the input shader on a target instance, with the specified parameters.
///