Added more transfer extensions to/from GPU

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-31 23:21:38 +01:00
1 親 1a4aac6f9f
コミット da19f87276
4ファイル変更
+96 -6

検索条件に一致するファイルはありません

+16 -4
ファイルの表示
@@ -80,8 +80,14 @@ namespace ComputeSharp.Resources
}
}
/// <inheritdoc/>
public unsafe void GetData(ReadBackBuffer<T> destination, int destinationOffset, int length, int offset)
/// <summary>
/// Reads the contents of the specified range from the current <see cref="StructuredBuffer{T}"/> instance and writes them into a target <see cref="ReadBackBuffer{T}"/> instance.
/// </summary>
/// <param name="destination">The target <see cref="ReadBackBuffer{T}"/> instance to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="length">The number of items to read.</param>
/// <param name="offset">The offset to start reading data from.</param>
internal unsafe void GetData(ReadBackBuffer<T> destination, int destinationOffset, int length, int offset)
{
GraphicsDevice.ThrowIfDisposed();
@@ -156,8 +162,14 @@ namespace ComputeSharp.Resources
}
}
/// <inheritdoc/>
public unsafe void SetData(UploadBuffer<T> source, int sourceOffset, int length, int offset)
/// <summary>
/// Reads the contents of the specified range from an input <see cref="ReadBackBuffer{T}"/> instance and writes them to the current the current <see cref="StructuredBuffer{T}"/> instance.
/// </summary>
/// <param name="source">The input <see cref="UploadBuffer{T}"/> instance to read data from.</param>
/// <param name="sourceOffset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="length">The number of items to read.</param>
/// <param name="offset">The offset to start reading writing data to.</param>
internal unsafe void SetData(UploadBuffer<T> source, int sourceOffset, int length, int offset)
{
GraphicsDevice.ThrowIfDisposed();
+2 -2
ファイルの表示
@@ -46,7 +46,7 @@ namespace ComputeSharp
}
/// <summary>
/// Reads the contents of s <see cref="Buffer{T}"/> instance and writes them into a target array.
/// Reads the contents of a <see cref="Buffer{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
@@ -58,7 +58,7 @@ namespace ComputeSharp
}
/// <summary>
/// Reads the contents of the specified range from s <see cref="Buffer{T}"/> instance and writes them into a target array.
/// Reads the contents of the specified range from a <see cref="Buffer{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to read data from.</param>
+39
ファイルの表示
@@ -0,0 +1,39 @@
using System.Diagnostics.Contracts;
using ComputeSharp.Resources;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="StructuredBuffer{T}"/> type.
/// </summary>
public static class StructuredBufferExtensions
{
/// <summary>
/// Reads the contents of a <see cref="StructuredBuffer{T}"/> instance and writes them into a target <see cref="ReadBackBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="StructuredBuffer{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="ReadBackBuffer{T}"/> instance to write data to.</param>
[Pure]
public static void CopyTo<T>(this StructuredBuffer<T> buffer, ReadBackBuffer<T> destination)
where T : unmanaged
{
buffer.GetData(destination, 0, buffer.Length, 0);
}
/// <summary>
/// Reads the contents of a <see cref="StructuredBuffer{T}"/> instance and writes them into a target <see cref="ReadBackBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="StructuredBuffer{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="ReadBackBuffer{T}"/> instance to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="bufferOffset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
public static void CopyTo<T>(this StructuredBuffer<T> buffer, ReadBackBuffer<T> destination, int destinationOffset, int bufferOffset, int count)
where T : unmanaged
{
buffer.GetData(destination, destinationOffset, count, bufferOffset);
}
}
}
+39
ファイルの表示
@@ -0,0 +1,39 @@
using System.Diagnostics.Contracts;
using ComputeSharp.Resources;
namespace ComputeSharp
{
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="UploadBuffer{T}"/> type.
/// </summary>
public static class UploadBufferExtensions
{
/// <summary>
/// Reads the contents of a <see cref="UploadBuffer{T}"/> instance and writes them into a target <see cref="StructuredBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="UploadBuffer{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="StructuredBuffer{T}"/> instance to write data to.</param>
[Pure]
public static void CopyTo<T>(this UploadBuffer<T> buffer, StructuredBuffer<T> destination)
where T : unmanaged
{
destination.SetData(buffer, 0, buffer.Length, 0);
}
/// <summary>
/// Reads the contents of a <see cref="UploadBuffer{T}"/> instance and writes them into a target <see cref="StructuredBuffer{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="buffer">The input <see cref="UploadBuffer{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="StructuredBuffer{T}"/> instance to write data to.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="bufferOffset">The offset to start reading data from.</param>
/// <param name="count">The number of items to read.</param>
public static void CopyTo<T>(this UploadBuffer<T> buffer, StructuredBuffer<T> destination, int destinationOffset, int bufferOffset, int count)
where T : unmanaged
{
destination.SetData(buffer, bufferOffset, count, destinationOffset);
}
}
}