From c6577302495b10b285632c881c900018d3979f83 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 12 Nov 2021 01:56:08 +0100 Subject: [PATCH] Add mirrored StructuredBufferExtensions APIs --- .../Extensions/StructuredBufferExtensions.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs index 3438e4ff..8d97bd5f 100644 --- a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs @@ -33,4 +33,31 @@ public static class StructuredBufferExtensions { source.CopyTo(destination, sourceOffset, destinationOffset, count); } + + /// + /// Reads the contents of an instance and writes them into a target instance. + /// + /// The type of items stored on the buffer. + /// The target instance to write data to. + /// The input instance to read data from. + public static void CopyFrom(this StructuredBuffer destination, UploadBuffer source) + where T : unmanaged + { + source.CopyTo(destination, 0, 0, source.Length); + } + + /// + /// Reads the contents of an instance and writes them into a target instance. + /// + /// The type of items stored on the buffer. + /// The target instance to write data to. + /// The input instance to read data from. + /// The offset to start reading data from. + /// The starting offset within to write data to. + /// The number of items to read. + public static void CopyFrom(this StructuredBuffer destination, UploadBuffer source, int sourceOffset, int destinationOffset, int count) + where T : unmanaged + { + source.CopyTo(destination, sourceOffset, destinationOffset, count); + } }