Add extensions for 1D textures
このコミットが含まれているのは:
1 親
892e5f17f7
コミット
8c5ce3a1d7
6ファイル変更
+1454
-1
検索条件に一致するファイルはありません
@@ -160,6 +160,196 @@ partial class GraphicsDeviceExtensions
|
||||
return readWriteBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A zeroed <see cref="ReadOnlyTexture1D{T}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T>(source.AsSpan(0, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T>(source.AsSpan(offset, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
ReadOnlyTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
public static ReadOnlyTexture1D<T> AllocateReadOnlyTexture1D<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
ReadOnlyTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A zeroed <see cref="ReadOnlyTexture1D{T, TPixel}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static ReadOnlyTexture1D<T, TPixel> AllocateReadOnlyTexture1D<T, TPixel>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T, TPixel> AllocateReadOnlyTexture1D<T, TPixel>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T, TPixel>(source.AsSpan(0, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T, TPixel> AllocateReadOnlyTexture1D<T, TPixel>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadOnlyTexture1D<T, TPixel>(source.AsSpan(offset, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadOnlyTexture1D<T, TPixel> AllocateReadOnlyTexture1D<T, TPixel>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
ReadOnlyTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture1D{T, TPixel}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
public static ReadOnlyTexture1D<T, TPixel> AllocateReadOnlyTexture1D<T, TPixel>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
ReadOnlyTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 2D texture with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -651,6 +841,196 @@ partial class GraphicsDeviceExtensions
|
||||
return readWriteBuffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A zeroed <see cref="ReadWriteTexture1D{T}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T>(source.AsSpan(0, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T>(source.AsSpan(offset, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadWriteTexture1D{T}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
ReadWriteTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
public static ReadWriteTexture1D<T> AllocateReadWriteTexture1D<T>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
ReadWriteTexture1D<T> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A zeroed <see cref="ReadWriteTexture1D{T, TPixel}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static ReadWriteTexture1D<T, TPixel> AllocateReadWriteTexture1D<T, TPixel>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T, TPixel> AllocateReadWriteTexture1D<T, TPixel>(this GraphicsDevice device, T[] source, int width)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T, TPixel>(source.AsSpan(0, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T, TPixel> AllocateReadWriteTexture1D<T, TPixel>(this GraphicsDevice device, T[] source, int offset, int width)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
return device.AllocateReadWriteTexture1D<T, TPixel>(source.AsSpan(offset, width));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadWriteTexture1D{T, TPixel}"/> instance with the contents of the input array.</returns>
|
||||
public static ReadWriteTexture1D<T, TPixel> AllocateReadWriteTexture1D<T, TPixel>(this GraphicsDevice device, T[] source)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
ReadWriteTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 1D texture with the specified parameters.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture1D{T, TPixel}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
public static ReadWriteTexture1D<T, TPixel> AllocateReadWriteTexture1D<T, TPixel>(this GraphicsDevice device, ReadOnlySpan<T> source)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
ReadWriteTexture1D<T, TPixel> texture = new(device, source.Length, AllocationMode.Default);
|
||||
|
||||
texture.CopyFrom(source);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 2D texture with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -1084,6 +1464,22 @@ partial class GraphicsDeviceExtensions
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new upload 1D texture 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="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A <see cref="UploadTexture1D{T}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static UploadTexture1D<T> AllocateUploadTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new upload 2D texture with the specified parameters.
|
||||
/// </summary>
|
||||
@@ -1136,6 +1532,22 @@ partial class GraphicsDeviceExtensions
|
||||
return new(device, length, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readback 1D texture 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="width">The width of the texture.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <returns>A <see cref="ReadBackTexture1D{T}"/> instance of size [<paramref name="width"/>].</returns>
|
||||
public static ReadBackTexture1D<T> AllocateReadBackTexture1D<T>(this GraphicsDevice device, int width, AllocationMode allocationMode = AllocationMode.Default)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(device);
|
||||
|
||||
return new(device, width, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readback 2D texture with the specified parameters.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="ReadBackTexture1D{T}"/> type.
|
||||
/// </summary>
|
||||
public static class ReadBackTexture1DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this ReadBackTexture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="ReadWriteTexture1D{T}"/> and <see cref="ReadWriteTexture1D{T, TPixel}"/> types.
|
||||
/// </summary>
|
||||
public static class ReadWriteTexture1DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture1D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture1D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture1D{float}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<float> AsReadOnly(this ReadWriteTexture1D<float> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture1D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture1D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture1D{Float2}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float2> AsReadOnly(this ReadWriteTexture1D<Float2> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture1D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture1D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture1D{Float3}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float3> AsReadOnly(this ReadWriteTexture1D<Float3> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture1D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture1D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture1D{Float4}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture1D<Float4> AsReadOnly(this ReadWriteTexture1D<Float4> texture)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyNormalizedTexture1D{TPixel}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T, TPixel}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyNormalizedTexture1D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture1D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyNormalizedTexture1D<TPixel> AsReadOnly<T, TPixel>(this ReadWriteTexture1D<T, TPixel> texture)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="Texture1D{T}"/> type.
|
||||
/// </summary>
|
||||
public static class Texture1DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="Texture1D{T}"/> instance and returns an array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <returns>A <typeparamref name="T"/> array with the contents of the current texture.</returns>
|
||||
public static T[] ToArray<T>(this Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
T[] data = new T[source.Width];
|
||||
|
||||
source.CopyTo(data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="Texture1D{T}"/> instance and returns an array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="x">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
/// <returns>A <typeparamref name="T"/> array with the contents of the current texture.</returns>
|
||||
public static unsafe T[] ToArray<T>(this Texture1D<T> source, int x, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsGreaterThanOrEqualTo(width, 0);
|
||||
|
||||
T[] data = new T[width];
|
||||
|
||||
fixed (T* p = data)
|
||||
{
|
||||
source.CopyTo(new Span<T>(p, width), x, width);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), 0, source.Width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
/// <param name="x">The horizontal range of items to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(), sourceOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, source.Width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
|
||||
/// <param name="x">The horizontal range of items to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input array to write data to.</param>
|
||||
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, T[] destination, int destinationOffset, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the current <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
/// The input data will be read from the start of the texture.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, source.Width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
|
||||
/// <param name="x">The horizontal range of items to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
var (offsetX, width) = x.GetOffsetAndLength(source.Width);
|
||||
|
||||
source.CopyTo(destination, offsetX, width);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The input <see cref="Span{T}"/> to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Span<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="ReadBackTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="ReadBackTexture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this Texture1D<T> source, ReadBackTexture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), 0, destination.Width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
|
||||
/// <param name="x">The horizontal range of items to write.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
|
||||
/// <param name="sourceOffset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="x">The horizontal range of items to write.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int sourceOffset, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
|
||||
/// <param name="sourceOffset">The starting offset within <paramref name="source"/> to read data from.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, T[] source, int sourceOffset, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture1D{T}"/> instance.
|
||||
/// The input data will be written to the start of the texture, and all input items will be copied.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, destination.Width);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
|
||||
/// <param name="x">The horizontal range of items to write.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source, Range x)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
var (offsetX, width) = x.GetOffsetAndLength(destination.Width);
|
||||
|
||||
destination.CopyFrom(source, offsetX, width);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="ReadOnlySpan{T}"/> to read data from.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to write to.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, ReadOnlySpan<T> source, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="Texture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="Texture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, Texture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
source.CopyTo(destination, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of an <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyFrom<T>(this Texture1D<T> destination, UploadTexture1D<T> source, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(destination);
|
||||
Guard.IsNotNull(source);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.Resources;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="UploadTexture1D{T}"/> type.
|
||||
/// </summary>
|
||||
public static class UploadTexture1DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
destination.CopyFrom(source, 0, 0, source.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, 0, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of a <see cref="UploadTexture1D{T}"/> instance and writes them into a target <see cref="Texture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="source">The input <see cref="UploadTexture1D{T}"/> instance to read data from.</param>
|
||||
/// <param name="destination">The target <see cref="Texture1D{T}"/> instance to write data to.</param>
|
||||
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
|
||||
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
|
||||
/// <param name="width">The width of the memory area to copy.</param>
|
||||
public static void CopyTo<T>(this UploadTexture1D<T> source, Texture1D<T> destination, int sourceOffsetX, int destinationOffsetX, int width)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(source);
|
||||
Guard.IsNotNull(destination);
|
||||
|
||||
destination.CopyFrom(source, sourceOffsetX, destinationOffsetX, width);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,22 @@ public static class ComputeContextExtensions
|
||||
context.Barrier(buffer.ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to insert the barrier for.</param>
|
||||
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture1D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
@@ -62,6 +78,24 @@ public static class ComputeContextExtensions
|
||||
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T,TPixel}"/> instance to insert the barrier for.</param>
|
||||
public static unsafe void Barrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture1D<T, TPixel> texture)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
@@ -98,6 +132,22 @@ public static class ComputeContextExtensions
|
||||
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture1D{TPixel}"/> instance to insert the barrier for.</param>
|
||||
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
context.Barrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a resource barrier for a specific resource.
|
||||
/// </summary>
|
||||
@@ -146,6 +196,22 @@ public static class ComputeContextExtensions
|
||||
context.Clear(buffer.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to clear the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to clear.</param>
|
||||
public static unsafe void Clear<T>(this in ComputeContext context, ReadWriteTexture1D<T> texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized);
|
||||
|
||||
context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
@@ -178,6 +244,24 @@ public static class ComputeContextExtensions
|
||||
context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to clear the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T,TPixel}"/> instance to clear.</param>
|
||||
public static unsafe void Clear<T, TPixel>(this in ComputeContext context, ReadWriteTexture1D<T, TPixel> texture)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
@@ -214,6 +298,24 @@ public static class ComputeContextExtensions
|
||||
context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to clear the resource.</param>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture1D{TPixel}"/> instance to clear.</param>
|
||||
public static unsafe void Clear<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
context.Clear(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a specific resource.
|
||||
/// </summary>
|
||||
@@ -250,6 +352,25 @@ public static class ComputeContextExtensions
|
||||
context.Clear(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a specific texture with a given value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to fill the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T,TPixel}"/> instance to fill.</param>
|
||||
/// <param name="value">The value to use to fill <paramref name="texture"/>.</param>
|
||||
public static unsafe void Fill<T, TPixel>(this in ComputeContext context, ReadWriteTexture1D<T, TPixel> texture, T value)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
context.Fill(texture.D3D12Resource, handles.Gpu, handles.Cpu, DXGIFormatHelper.ExtendToNormalizedValue(value.ToPixel()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a specific texture with a given value.
|
||||
/// </summary>
|
||||
@@ -288,6 +409,29 @@ public static class ComputeContextExtensions
|
||||
context.Fill(texture.D3D12Resource, handles.Gpu, handles.Cpu, DXGIFormatHelper.ExtendToNormalizedValue(value.ToPixel()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a specific texture with a given value.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to fill the resource.</param>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture1D{TPixel}"/> instance to fill.</param>
|
||||
/// <param name="value">The value to use to fill <paramref name="texture"/>.</param>
|
||||
public static unsafe void Fill<TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture1D<TPixel> texture, TPixel value)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
context.Fill(
|
||||
((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
handles.Gpu,
|
||||
handles.Cpu,
|
||||
DXGIFormatHelper.ExtendToNormalizedValue(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a specific texture with a given value.
|
||||
/// </summary>
|
||||
@@ -427,6 +571,95 @@ public static class ComputeContextExtensions
|
||||
context.Run(texture, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease));
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease));
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease));
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture1D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease));
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T,TPixel}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition<T, TPixel>(this in ComputeContext context, ReadWriteTexture1D<T, TPixel> texture, ResourceState resourceState)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(texture);
|
||||
|
||||
using NativeObject.Lease lease = default;
|
||||
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease));
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
@@ -590,7 +823,7 @@ public static class ComputeContextExtensions
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to transition.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T,TPixel}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture, ResourceState resourceState)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする