diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
index 33e0fe69..2f3c0ae3 100644
--- a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers;
+using ComputeSharp.Graphics.Buffers.Abstract;
namespace ComputeSharp
{
@@ -74,6 +75,23 @@ namespace ComputeSharp
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, HlslBuffer buffer) where T : unmanaged
+ {
+ ReadWriteBuffer readWriteBuffer = new ReadWriteBuffer(device, buffer.Size);
+ readWriteBuffer.SetData(buffer);
+
+ return readWriteBuffer;
+ }
+
///
/// Allocates a new constant buffer with the specified parameters
///
@@ -122,5 +140,22 @@ namespace ComputeSharp
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 ReadOnlyBuffer AllocateReadOnlyBuffer(this GraphicsDevice device, HlslBuffer buffer) where T : unmanaged
+ {
+ ReadOnlyBuffer readOnlyBuffer = new ReadOnlyBuffer(device, buffer.Size);
+ readOnlyBuffer.SetData(buffer);
+
+ return readOnlyBuffer;
+ }
}
}