Added more extensions to copy to transfer buffer
このコミットが含まれているのは:
1 親
ca73b69e5c
コミット
1a4aac6f9f
1ファイル変更
+54
-18
@@ -125,6 +125,24 @@ namespace ComputeSharp
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly buffer with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
|
||||
/// <param name="source">The input <see cref="UploadBuffer{T}"/> with the data to copy on the allocated buffer.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyBuffer{T}"/> instance with the contents of the input <see cref="UploadBuffer{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyBuffer<T> AllocateReadOnlyBuffer<T>(this GraphicsDevice device, UploadBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadOnlyBuffer<T> readWriteBuffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
readWriteBuffer.SetData(source, 0, source.Length, 0);
|
||||
|
||||
return readWriteBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly buffer with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -574,6 +592,24 @@ namespace ComputeSharp
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new read write buffer with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
|
||||
/// <param name="source">The input <see cref="UploadBuffer{T}"/> with the data to copy on the allocated buffer.</param>
|
||||
/// <returns>A read write <see cref="ReadWriteBuffer{T}"/> instance with the contents of the input <see cref="UploadBuffer{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadWriteBuffer<T> AllocateReadWriteBuffer<T>(this GraphicsDevice device, UploadBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadWriteBuffer<T> readWriteBuffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
readWriteBuffer.SetData(source, 0, source.Length, 0);
|
||||
|
||||
return readWriteBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new read write buffer with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -1038,24 +1074,6 @@ namespace ComputeSharp
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly buffer with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
|
||||
/// <param name="source">The input <see cref="Buffer{T}"/> with the data to copy on the allocated buffer.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyBuffer{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadBackBuffer<T> AllocateReadBackBuffer<T>(this GraphicsDevice device, StructuredBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadBackBuffer<T> buffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
source.GetData(buffer, 0, buffer.Length, 0);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly buffer with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -1074,6 +1092,24 @@ namespace ComputeSharp
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly buffer with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the buffer.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the buffer.</param>
|
||||
/// <param name="source">The input <see cref="Buffer{T}"/> with the data to copy on the allocated buffer.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyBuffer{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadBackBuffer<T> AllocateReadBackBuffer<T>(this GraphicsDevice device, StructuredBuffer<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadBackBuffer<T> buffer = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
source.GetData(buffer, 0, buffer.Length, 0);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする