Added public APIs to allocate Texture3D<T>-s
このコミットが含まれているのは:
1 親
1de7a7c9c0
コミット
7d85f7b6af
1ファイル変更
+188
@@ -375,6 +375,194 @@ namespace ComputeSharp
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 3D 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="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A zeroed <see cref="ReadOnlyTexture3D{T}"/> instance of size [<paramref name="width"/>, <paramref name="height"/>, <paramref name="depth"/>].</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return new(device, width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 3D 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="array">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>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] array, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return device.AllocateReadOnlyTexture3D<T>(array.AsSpan(), width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 3D 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="array">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>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return device.AllocateReadOnlyTexture3D<T>(array.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 3D 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="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
/// <remarks>
|
||||
/// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, unlike .NET arrays
|
||||
/// which are traditionally of size [H, W, D], the input one needs to have a layout of [D, H, W].
|
||||
/// </remarks>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, T[,,] array)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadOnlyTexture3D<T> texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
|
||||
|
||||
texture.SetData(array);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new readonly 3D 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="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture3D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture3D<T> AllocateReadOnlyTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> span, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadOnlyTexture3D<T> texture = new(device, width, height, depth);
|
||||
|
||||
texture.SetData(span);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 3D 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="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A zeroed <see cref="ReadWriteTexture3D{T}"/> instance of size [<paramref name="width"/>, <paramref name="height"/>].</returns>
|
||||
[Pure]
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return new(device, width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 3D 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="array">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>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] array, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return device.AllocateReadWriteTexture3D<T>(array.AsSpan(), width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 3D 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="array">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>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
[Pure]
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[] array, int offset, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
return device.AllocateReadWriteTexture3D<T>(array.AsSpan(offset), width, height, depth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 3D 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="array">The input <typeparamref name="T"/> array with the data to copy on the allocated texture.</param>
|
||||
/// <returns>A read write <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input array.</returns>
|
||||
/// <remarks>
|
||||
/// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, unlike .NET arrays
|
||||
/// which are traditionally of size [H, W, D], the input one needs to have a layout of [D, H, W].
|
||||
/// </remarks>
|
||||
[Pure]
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, T[,,] array)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadWriteTexture3D<T> texture = new(device, array.GetLength(2), array.GetLength(1), array.GetLength(0));
|
||||
|
||||
texture.SetData(array);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new writeable 3D 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="span">The input <see cref="ReadOnlySpan{T}"/> with the data to copy on the allocated texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture3D{T}"/> instance with the contents of the input <see cref="ReadOnlySpan{T}"/>.</returns>
|
||||
[Pure]
|
||||
public static ReadWriteTexture3D<T> AllocateReadWriteTexture3D<T>(this GraphicsDevice device, ReadOnlySpan<T> span, int width, int height, int depth)
|
||||
where T : unmanaged
|
||||
{
|
||||
ReadWriteTexture3D<T> texture = new(device, width, height, depth);
|
||||
|
||||
texture.SetData(span);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする