diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
deleted file mode 100644
index 00945403..00000000
--- a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-using System;
-using System.Diagnostics.Contracts;
-using System.Runtime.CompilerServices;
-using ComputeSharp.Graphics;
-using ComputeSharp.Graphics.Buffers.Abstract;
-
-namespace ComputeSharp
-{
- ///
- /// A with extension methods for the type to allocate buffers.
- ///
- public static class BufferExtensions
- {
- ///
- /// Allocates a new constant buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input array with the data to copy on the allocated buffer.
- /// A constant instance with the contents of the input array.
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, T[] array)
- where T : unmanaged
- {
- return device.AllocateConstantBuffer(array.AsSpan());
- }
-
- ///
- /// Allocates a new constant buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A constant instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Span span)
- where T : unmanaged
- {
- ConstantBuffer buffer = new(device, span.Length);
-
- buffer.SetData(span);
-
- return buffer;
- }
-
- ///
- /// Allocates a new constant buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A constant instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Buffer buffer)
- where T : unmanaged
- {
- ConstantBuffer constantBuffer = new(device, buffer.Size);
-
- constantBuffer.SetData(buffer);
-
- return constantBuffer;
- }
-
- ///
- /// Allocates a new readonly buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The size of the buffer to allocate.
- /// A zeroed instance of size .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, int size)
- where T : unmanaged
- {
- return new(device, size);
- }
-
- ///
- /// Allocates a new readonly buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input array with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input array.
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, T[] array)
- where T : unmanaged
- {
- return device.AllocateReadOnlyBuffer(array.AsSpan());
- }
-
- ///
- /// Allocates a new readonly buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Span span)
- where T : unmanaged
- {
- ReadOnlyBuffer buffer = new(device, span.Length);
-
- buffer.SetData(span);
-
- return buffer;
- }
-
- ///
- /// Allocates a new readonly buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Buffer buffer)
- where T : unmanaged
- {
- ReadOnlyBuffer readWriteBuffer = new(device, buffer.Size);
-
- readWriteBuffer.SetData(buffer);
-
- return readWriteBuffer;
- }
-
- ///
- /// Allocates a new read write buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The size of the buffer to allocate.
- /// A zeroed instance of size .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int size)
- where T : unmanaged
- {
- return new(device, size);
- }
-
- ///
- /// Allocates a new read write buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input array with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input array.
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, T[] array)
- where T : unmanaged
- {
- return device.AllocateReadWriteBuffer(array.AsSpan());
- }
-
- ///
- /// Allocates a new read write buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span)
- where T : unmanaged
- {
- ReadWriteBuffer buffer = new(device, span.Length);
-
- buffer.SetData(span);
-
- return buffer;
- }
-
- ///
- /// Allocates a new read write buffer with the specified parameters.
- ///
- /// The type of items to store in the buffer.
- /// The instance to use to allocate the buffer.
- /// The input with the data to copy on the allocated buffer.
- /// A read write instance with the contents of the input .
- [Pure]
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Buffer buffer)
- where T : unmanaged
- {
- ReadWriteBuffer readWriteBuffer = new (device, buffer.Size);
-
- readWriteBuffer.SetData(buffer);
-
- return readWriteBuffer;
- }
- }
-}
diff --git a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
index 30b91186..d202f181 100644
--- a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
+++ b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
@@ -1,4 +1,7 @@
-using ComputeSharp.Graphics;
+using System;
+using System.Diagnostics.Contracts;
+using ComputeSharp.Graphics;
+using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Shaders;
namespace ComputeSharp
@@ -8,6 +11,184 @@ namespace ComputeSharp
///
public static class GraphicsDevice2Extensions
{
+ ///
+ /// Allocates a new constant buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input array with the data to copy on the allocated buffer.
+ /// A constant instance with the contents of the input array.
+ [Pure]
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, T[] array)
+ where T : unmanaged
+ {
+ return device.AllocateConstantBuffer(array.AsSpan());
+ }
+
+ ///
+ /// Allocates a new constant buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A constant instance with the contents of the input .
+ [Pure]
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Span span)
+ where T : unmanaged
+ {
+ ConstantBuffer buffer = new(device, span.Length);
+
+ buffer.SetData(span);
+
+ return buffer;
+ }
+
+ ///
+ /// Allocates a new constant buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A constant instance with the contents of the input .
+ [Pure]
+ public static ConstantBuffer AllocateConstantBuffer(this GraphicsDevice device, Buffer buffer)
+ where T : unmanaged
+ {
+ ConstantBuffer constantBuffer = new(device, buffer.Size);
+
+ constantBuffer.SetData(buffer);
+
+ return constantBuffer;
+ }
+
+ ///
+ /// Allocates a new readonly buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The size of the buffer to allocate.
+ /// A zeroed instance of size .
+ [Pure]
+ public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, int size)
+ where T : unmanaged
+ {
+ return new(device, size);
+ }
+
+ ///
+ /// Allocates a new readonly buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input array with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input array.
+ [Pure]
+ public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, T[] array)
+ where T : unmanaged
+ {
+ return device.AllocateReadOnlyBuffer(array.AsSpan());
+ }
+
+ ///
+ /// Allocates a new readonly buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input .
+ [Pure]
+ public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Span span)
+ where T : unmanaged
+ {
+ ReadOnlyBuffer buffer = new(device, span.Length);
+
+ buffer.SetData(span);
+
+ return buffer;
+ }
+
+ ///
+ /// Allocates a new readonly buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input .
+ [Pure]
+ public static ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, Buffer buffer)
+ where T : unmanaged
+ {
+ ReadOnlyBuffer readWriteBuffer = new(device, buffer.Size);
+
+ readWriteBuffer.SetData(buffer);
+
+ return readWriteBuffer;
+ }
+
+ ///
+ /// Allocates a new read write buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The size of the buffer to allocate.
+ /// A zeroed instance of size .
+ [Pure]
+ public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int size)
+ where T : unmanaged
+ {
+ return new(device, size);
+ }
+
+ ///
+ /// Allocates a new read write buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input array with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input array.
+ [Pure]
+ public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, T[] array)
+ where T : unmanaged
+ {
+ return device.AllocateReadWriteBuffer(array.AsSpan());
+ }
+
+ ///
+ /// Allocates a new read write buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input .
+ [Pure]
+ public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span)
+ where T : unmanaged
+ {
+ ReadWriteBuffer buffer = new(device, span.Length);
+
+ buffer.SetData(span);
+
+ return buffer;
+ }
+
+ ///
+ /// Allocates a new read write buffer with the specified parameters.
+ ///
+ /// The type of items to store in the buffer.
+ /// The instance to use to allocate the buffer.
+ /// The input with the data to copy on the allocated buffer.
+ /// A read write instance with the contents of the input .
+ [Pure]
+ public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Buffer buffer)
+ where T : unmanaged
+ {
+ ReadWriteBuffer readWriteBuffer = new(device, buffer.Size);
+
+ readWriteBuffer.SetData(buffer);
+
+ return readWriteBuffer;
+ }
+
///
/// Compiles and runs the input shader on a target instance, with the specified parameters.
///
@@ -62,11 +243,7 @@ namespace ComputeSharp
/// The number of threads in each thread group for the Y axis.
/// The number of threads in each thread group for the Z axis.
/// The input instance representing the compute shader to run.
- public static void For(
- this GraphicsDevice device,
- int x, int y, int z,
- int threadsX, int threadsY, int threadsZ,
- in T shader)
+ public static void For(this GraphicsDevice device, int x, int y, int z, int threadsX, int threadsY, int threadsZ, in T shader)
where T : struct, IComputeShader
{
ShaderRunner.Run(device, x, y, z, threadsX, threadsY, threadsZ, in shader);