Rename parameters in Texture3D<T> copy APIs

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-12 14:18:18 +01:00
1 親 d657b9cc95
コミット 453eec3366
2ファイル変更
+169 -169

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

+93 -93
ファイルの表示
@@ -15,7 +15,7 @@ public static class Texture3DExtensions
/// Reads the contents of the current <see cref="Texture3D{T}"/> instance and returns an array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <returns>A <typeparamref name="T"/> array with the contents of the current buffer.</returns>
/// <remarks>
/// The returned array will be using the same memory layout as the texture, that is, each 2D plane
@@ -23,12 +23,12 @@ public static class Texture3DExtensions
/// the depth dimension. This means that the resulting 3D array will have a size of [D, H, W].
/// </remarks>
[Pure]
public static T[,,] ToArray<T>(this Texture3D<T> texture)
public static T[,,] ToArray<T>(this Texture3D<T> source)
where T : unmanaged
{
T[,,] data = new T[texture.Depth, texture.Height, texture.Width];
T[,,] data = new T[source.Depth, source.Height, source.Width];
texture.CopyTo(data);
source.CopyTo(data);
return data;
}
@@ -37,247 +37,247 @@ public static class Texture3DExtensions
/// Reads the contents of the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <remarks>
/// The input 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be of shape [depth, height, width].
/// </remarks>
public static void CopyTo<T>(this Texture3D<T> texture, T[,,] destination)
public static void CopyTo<T>(this Texture3D<T> source, T[,,] destination)
where T : unmanaged
{
Guard.IsEqualTo(destination.GetLength(0), texture.Depth, nameof(destination));
Guard.IsEqualTo(destination.GetLength(1), texture.Height, nameof(destination));
Guard.IsEqualTo(destination.GetLength(2), texture.Width, nameof(destination));
Guard.IsEqualTo(destination.GetLength(0), source.Depth, nameof(destination));
Guard.IsEqualTo(destination.GetLength(1), source.Height, nameof(destination));
Guard.IsEqualTo(destination.GetLength(2), source.Width, nameof(destination));
texture.CopyTo(ref destination[0, 0, 0], destination.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
source.CopyTo(ref destination[0, 0, 0], destination.Length, 0, 0, 0, source.Width, source.Height, source.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
public static void CopyTo<T>(this Texture3D<T> texture, T[] destination, int offset)
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int destinationOffset)
where T : unmanaged
{
texture.CopyTo(destination.AsSpan(offset), 0, 0, 0, texture.Width, texture.Height, texture.Depth);
source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> 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>
/// <param name="y">The vertical range of items to copy.</param>
/// <param name="z">The depthwise range of items to copy.</param>
public static void CopyTo<T>(this Texture3D<T> texture, T[] destination, int offset, Range x, Range y, Range z)
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int destinationOffset, Range x, Range y, Range z)
where T : unmanaged
{
texture.CopyTo(destination.AsSpan(offset), x, y, z);
source.CopyTo(destination.AsSpan(destinationOffset), x, y, z);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The input array to write data to.</param>
/// <param name="offset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
/// <param name="sourceOffsetY">The vertical offset in the source texture.</param>
/// <param name="sourceOffsetZ">The depthwise offset in the source texture.</param>
/// <param name="destinationOffset">The starting offset within <paramref name="destination"/> to write data to.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
public static void CopyTo<T>(this Texture3D<T> texture, T[] destination, int offset, int x, int y, int z, int width, int height, int depth)
public static void CopyTo<T>(this Texture3D<T> source, T[] destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffset, int width, int height, int depth)
where T : unmanaged
{
texture.CopyTo(destination.AsSpan(offset), x, y, z, width, height, depth);
source.CopyTo(destination.AsSpan(destinationOffset), sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{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="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{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 Texture3D<T> texture, Span<T> destination)
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination)
where T : unmanaged
{
texture.CopyTo(destination, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{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="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{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 in the source texture.</param>
/// <param name="y">The vertical range in the source texture.</param>
/// <param name="z">The depthwise range in the source texture.</param>
public static void CopyTo<T>(this Texture3D<T> texture, Span<T> destination, Range x, Range y, Range z)
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination, Range x, Range y, Range z)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth);
var (offsetX, width) = x.GetOffsetAndLength(source.Width);
var (offsetY, height) = y.GetOffsetAndLength(source.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(source.Depth);
texture.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth);
source.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth);
}
/// <summary>
/// Reads the contents of the specified range from the current <see cref="Texture3D{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="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{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 offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
/// <param name="sourceOffsetY">The vertical offset in the source texture.</param>
/// <param name="sourceOffsetZ">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
public static void CopyTo<T>(this Texture3D<T> texture, Span<T> destination, int x, int y, int z, int width, int height, int depth)
public static void CopyTo<T>(this Texture3D<T> source, Span<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
where T : unmanaged
{
texture.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, x, y, z, width, height, depth);
source.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, sourceOffsetX, sourceOffsetY, sourceOffsetZ, width, height, depth);
}
/// <summary>
/// Reads the contents of a <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="ReadBackTexture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
public static void CopyTo<T>(this Texture3D<T> texture, ReadBackTexture3D<T> destination)
public static void CopyTo<T>(this Texture3D<T> source, ReadBackTexture3D<T> destination)
where T : unmanaged
{
texture.CopyTo(destination, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
source.CopyTo(destination, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.Depth);
}
/// <summary>
/// Reads the contents of a <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="ReadBackTexture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
/// <param name="sourceOffsetY">The vertical offset in the source texture.</param>
/// <param name="sourceOffsetZ">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
public static void CopyTo<T>(this Texture3D<T> texture, ReadBackTexture3D<T> destination, int x, int y, int z, int width, int height, int depth)
public static void CopyTo<T>(this Texture3D<T> source, ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
where T : unmanaged
{
texture.CopyTo(destination, 0, 0, 0, x, y, z, width, height, depth);
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <remarks>
/// The source 3D array needs to have each 2D plane stacked on the depth axis. That is, the expected
/// layout of the input array has to be of shape [depth, height, width].
/// </remarks>
public static void CopyFrom<T>(this Texture3D<T> texture, T[,,] source)
public static void CopyFrom<T>(this Texture3D<T> destination, T[,,] source)
where T : unmanaged
{
Guard.IsEqualTo(source.GetLength(0), texture.Depth, nameof(source));
Guard.IsEqualTo(source.GetLength(1), texture.Height, nameof(source));
Guard.IsEqualTo(source.GetLength(2), texture.Width, nameof(source));
Guard.IsEqualTo(source.GetLength(0), destination.Depth, nameof(source));
Guard.IsEqualTo(source.GetLength(1), destination.Height, nameof(source));
Guard.IsEqualTo(source.GetLength(2), destination.Width, nameof(source));
texture.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
destination.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, destination.Width, destination.Height, destination.Depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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 Texture3D<T> texture, T[] source)
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source)
where T : unmanaged
{
texture.CopyFrom(source.AsSpan(), 0, 0, 0, texture.Width, texture.Height, texture.Depth);
destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, T[] source, Range x, Range y, Range z)
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, Range x, Range y, Range z)
where T : unmanaged
{
texture.CopyFrom(source.AsSpan(), x, y, z);
destination.CopyFrom(source.AsSpan(), x, y, z);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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 offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical offset in the destination texture.</param>
/// <param name="destinationOffsetZ">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, T[] source, int x, int y, int z, int width, int height, int depth)
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
where T : unmanaged
{
texture.CopyFrom(source.AsSpan(), x, y, z, width, height, depth);
destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> 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>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, T[] source, int offset, Range x, Range y, Range z)
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int sourceOffset, Range x, Range y, Range z)
where T : unmanaged
{
texture.CopyFrom(source.AsSpan(offset), x, y, z);
destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z);
}
/// <summary>
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <typeparamref name="T"/> array to read data from.</param>
/// <param name="offset">The starting offset within <paramref name="source"/> to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</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="destinationOffsetY">The vertical offset in the destination texture.</param>
/// <param name="destinationOffsetZ">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, T[] source, int offset, int x, int y, int z, int width, int height, int depth)
public static void CopyFrom<T>(this Texture3D<T> destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
where T : unmanaged
{
texture.CopyFrom(source.AsSpan(offset), x, y, z, width, height, depth);
destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
}
/// <summary>
@@ -285,48 +285,48 @@ public static class Texture3DExtensions
/// 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="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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 Texture3D<T> texture, ReadOnlySpan<T> source)
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source)
where T : unmanaged
{
texture.CopyFrom(source, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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>
/// <param name="y">The vertical range of items to write.</param>
/// <param name="z">The depthwise range of items to write.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, ReadOnlySpan<T> source, Range x, Range y, Range z)
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source, Range x, Range y, Range z)
where T : unmanaged
{
var (offsetX, width) = x.GetOffsetAndLength(texture.Width);
var (offsetY, height) = y.GetOffsetAndLength(texture.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(texture.Depth);
var (offsetX, width) = x.GetOffsetAndLength(destination.Width);
var (offsetY, height) = y.GetOffsetAndLength(destination.Height);
var (offsetZ, depth) = z.GetOffsetAndLength(destination.Depth);
texture.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth);
destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth);
}
/// <summary>
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="texture">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
/// <param name="destination">The target <see cref="Texture3D{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 offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offseet in the destination texture.</param>
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical offset in the destination texture.</param>
/// <param name="destinationOffsetZ">The depthwise offseet in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
public static void CopyFrom<T>(this Texture3D<T> texture, ReadOnlySpan<T> source, int x, int y, int z, int width, int height, int depth)
public static void CopyFrom<T>(this Texture3D<T> destination, ReadOnlySpan<T> source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
where T : unmanaged
{
texture.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, x, y, z, width, height, depth);
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
}
}
+76 -76
ファイルの表示
@@ -156,27 +156,27 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
/// </summary>
/// <param name="destination">The target memory area to write data to.</param>
/// <param name="size">The size of the memory area to write data to.</param>
/// <param name="x">The horizontal offset in the source texture.</param>
/// <param name="y">The vertical offset in the source texture.</param>
/// <param name="z">The depthwise offset in the source texture.</param>
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
/// <param name="sourceOffsetY">The vertical offset in the source texture.</param>
/// <param name="sourceOffsetZ">The depthwise offset in the source texture.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
internal void CopyTo(ref T destination, int size, int x, int y, int z, int width, int height, int depth)
internal void CopyTo(ref T destination, int size, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsInRange(z, 0, Depth, nameof(z));
Guard.IsInRange(sourceOffsetX, 0, Width, nameof(sourceOffsetX));
Guard.IsInRange(sourceOffsetY, 0, Height, nameof(sourceOffsetY));
Guard.IsInRange(sourceOffsetZ, 0, Depth, nameof(sourceOffsetZ));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
GraphicsDevice.D3D12Device->GetCopyableFootprint(
@@ -210,9 +210,9 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
destinationY: 0,
destinationZ: 0,
d3D12ResourceSource: D3D12Resource,
sourceX: (uint)x,
sourceY: (uint)y,
sourceZ: (ushort)z,
sourceX: (uint)sourceOffsetX,
sourceY: (uint)sourceOffsetY,
sourceZ: (ushort)sourceOffsetZ,
(uint)width,
(uint)height,
(ushort)depth);
@@ -244,16 +244,16 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a <see cref="ReadBackTexture3D{T}"/> instance.
/// </summary>
/// <param name="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
/// <param name="destinationX">The horizontal offset within <paramref name="destination"/>.</param>
/// <param name="destinationY">The vertical offset within <paramref name="destination"/>.</param>
/// <param name="destinationZ">The depthwise offset within <paramref name="destination"/>.</param>
/// <param name="sourceX">The horizontal offset in the source texture.</param>
/// <param name="sourceY">The vertical offset in the source texture.</param>
/// <param name="sourceZ">The depthwise offset in the source texture.</param>
/// <param name="sourceOffsetX">The horizontal offset in the source texture.</param>
/// <param name="sourceOffsetY">The vertical offset in the source texture.</param>
/// <param name="sourceOffsetZ">The depthwise offset in the source texture.</param>
/// <param name="destinationOffsetX">The horizontal offset within <paramref name="destination"/>.</param>
/// <param name="destinationOffsetY">The vertical offset within <paramref name="destination"/>.</param>
/// <param name="destinationOffsetZ">The depthwise offset within <paramref name="destination"/>.</param>
/// <param name="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
/// <param name="depth">The depth of the memory area to copy.</param>
internal void CopyTo(ReadBackTexture3D<T> destination, int destinationX, int destinationY, int destinationZ, int sourceX, int sourceY, int sourceZ, int width, int height, int depth)
internal void CopyTo(ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
@@ -262,24 +262,24 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
destination.ThrowIfDeviceMismatch(GraphicsDevice);
destination.ThrowIfDisposed();
Guard.IsInRange(destinationX, 0, destination.Width, nameof(destinationX));
Guard.IsInRange(destinationY, 0, destination.Height, nameof(destinationY));
Guard.IsInRange(destinationZ, 0, destination.Depth, nameof(destinationZ));
Guard.IsInRange(sourceX, 0, Width, nameof(sourceX));
Guard.IsInRange(sourceY, 0, Height, nameof(sourceY));
Guard.IsInRange(sourceZ, 0, Depth, nameof(sourceZ));
Guard.IsInRange(sourceOffsetX, 0, Width, nameof(sourceOffsetX));
Guard.IsInRange(sourceOffsetY, 0, Height, nameof(sourceOffsetY));
Guard.IsInRange(sourceOffsetZ, 0, Depth, nameof(sourceOffsetZ));
Guard.IsInRange(destinationOffsetX, 0, destination.Width, nameof(destinationOffsetX));
Guard.IsInRange(destinationOffsetY, 0, destination.Height, nameof(destinationOffsetY));
Guard.IsInRange(destinationOffsetZ, 0, destination.Depth, nameof(destinationOffsetZ));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsBetweenOrEqualTo(width, 1, destination.Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, destination.Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, destination.Depth, nameof(depth));
Guard.IsBetweenOrEqualTo(destinationX + width, 1, destination.Width, nameof(destinationX));
Guard.IsBetweenOrEqualTo(destinationY + height, 1, destination.Height, nameof(destinationY));
Guard.IsBetweenOrEqualTo(destinationZ + depth, 1, destination.Depth, nameof(destinationZ));
Guard.IsLessThanOrEqualTo(sourceX + width, Width, nameof(sourceX));
Guard.IsLessThanOrEqualTo(sourceY + height, Height, nameof(sourceY));
Guard.IsLessThanOrEqualTo(sourceZ + depth, Depth, nameof(sourceZ));
Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX));
Guard.IsBetweenOrEqualTo(destinationOffsetY + height, 1, destination.Height, nameof(destinationOffsetY));
Guard.IsBetweenOrEqualTo(destinationOffsetZ + depth, 1, destination.Depth, nameof(destinationOffsetZ));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ));
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
@@ -293,13 +293,13 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
d3D12ResourceDestination: destination.D3D12Resource,
d3D12PlacedSubresourceFootprintDestination,
(uint)destinationX,
(uint)destinationY,
(ushort)destinationZ,
(uint)destinationOffsetX,
(uint)destinationOffsetY,
(ushort)destinationOffsetZ,
d3D12ResourceSource: D3D12Resource,
(uint)sourceX,
(uint)sourceY,
(ushort)sourceZ,
(uint)sourceOffsetX,
(uint)sourceOffsetY,
(ushort)sourceOffsetZ,
(uint)width,
(uint)height,
(ushort)depth);
@@ -318,27 +318,27 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
/// </summary>
/// <param name="source">The input memory area to read data from.</param>
/// <param name="size">The size of the memory area to read data from.</param>
/// <param name="x">The horizontal offset in the destination texture.</param>
/// <param name="y">The vertical offset in the destination texture.</param>
/// <param name="z">The depthwise offset in the destination texture.</param>
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical offset in the destination texture.</param>
/// <param name="destinationOffsetZ">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
internal void CopyFrom(ref T source, int size, int x, int y, int z, int width, int height, int depth)
internal void CopyFrom(ref T source, int size, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
Guard.IsInRange(x, 0, Width, nameof(x));
Guard.IsInRange(y, 0, Height, nameof(y));
Guard.IsInRange(z, 0, Depth, nameof(z));
Guard.IsInRange(destinationOffsetX, 0, Width, nameof(destinationOffsetX));
Guard.IsInRange(destinationOffsetY, 0, Height, nameof(destinationOffsetY));
Guard.IsInRange(destinationOffsetZ, 0, Depth, nameof(destinationOffsetZ));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsLessThanOrEqualTo(x + width, Width, nameof(x));
Guard.IsLessThanOrEqualTo(y + height, Height, nameof(y));
Guard.IsLessThanOrEqualTo(z + depth, Depth, nameof(z));
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth, nameof(size));
GraphicsDevice.D3D12Device->GetCopyableFootprint(
@@ -380,9 +380,9 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
d3D12ResourceDestination: D3D12Resource,
destinationX: (uint)x,
destinationY: (uint)y,
destinationZ: (ushort)z,
destinationX: (uint)destinationOffsetX,
destinationY: (uint)destinationOffsetY,
destinationZ: (ushort)destinationOffsetZ,
d3D12ResourceSource: d3D12Resource.Get(),
&d3D12PlacedSubresourceFootprintSource,
sourceX: 0,
@@ -404,16 +404,16 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
/// Writes the contents of a given <see cref="UploadTexture3D{T}"/> instance to a specified area of the current <see cref="Texture3D{T}"/> instance.
/// </summary>
/// <param name="source">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
/// <param name="sourceX">The horizontal offset within <paramref name="source"/>.</param>
/// <param name="sourceY">The vertical offset within <paramref name="source"/>.</param>
/// <param name="sourceZ">The depthwise offset within <paramref name="source"/>.</param>
/// <param name="destinationX">The horizontal offset in the destination texture.</param>
/// <param name="destinationY">The vertical offset in the destination texture.</param>
/// <param name="destinationZ">The depthwise offset in the destination texture.</param>
/// <param name="sourceOffsetX">The horizontal offset within <paramref name="source"/>.</param>
/// <param name="sourceOffsetY">The vertical offset within <paramref name="source"/>.</param>
/// <param name="sourceOffsetZ">The depthwise offset within <paramref name="source"/>.</param>
/// <param name="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical offset in the destination texture.</param>
/// <param name="destinationOffsetZ">The depthwise offset in the destination texture.</param>
/// <param name="width">The width of the memory area to write to.</param>
/// <param name="height">The height of the memory area to write to.</param>
/// <param name="depth">The depth of the memory area to write to.</param>
internal void CopyFrom(UploadTexture3D<T> source, int sourceX, int sourceY, int sourceZ, int destinationX, int destinationY, int destinationZ, int width, int height, int depth)
internal void CopyFrom(UploadTexture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
{
GraphicsDevice.ThrowIfDisposed();
@@ -422,24 +422,24 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
source.ThrowIfDeviceMismatch(GraphicsDevice);
source.ThrowIfDisposed();
Guard.IsInRange(sourceX, 0, source.Width, nameof(sourceX));
Guard.IsInRange(sourceY, 0, source.Height, nameof(sourceY));
Guard.IsInRange(sourceZ, 0, source.Depth, nameof(sourceZ));
Guard.IsInRange(destinationX, 0, Width, nameof(destinationX));
Guard.IsInRange(destinationY, 0, Height, nameof(destinationY));
Guard.IsInRange(destinationZ, 0, Depth, nameof(destinationZ));
Guard.IsInRange(sourceOffsetX, 0, source.Width, nameof(sourceOffsetX));
Guard.IsInRange(sourceOffsetY, 0, source.Height, nameof(sourceOffsetY));
Guard.IsInRange(sourceOffsetZ, 0, source.Depth, nameof(sourceOffsetZ));
Guard.IsInRange(destinationOffsetX, 0, Width, nameof(destinationOffsetX));
Guard.IsInRange(destinationOffsetY, 0, Height, nameof(destinationOffsetY));
Guard.IsInRange(destinationOffsetZ, 0, Depth, nameof(destinationOffsetZ));
Guard.IsBetweenOrEqualTo(width, 1, Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, Depth, nameof(depth));
Guard.IsBetweenOrEqualTo(width, 1, source.Width, nameof(width));
Guard.IsBetweenOrEqualTo(height, 1, source.Height, nameof(height));
Guard.IsBetweenOrEqualTo(depth, 1, source.Depth, nameof(depth));
Guard.IsLessThanOrEqualTo(sourceX + width, source.Width, nameof(sourceX));
Guard.IsLessThanOrEqualTo(sourceY + height, source.Height, nameof(sourceY));
Guard.IsLessThanOrEqualTo(sourceZ + depth, source.Depth, nameof(sourceZ));
Guard.IsLessThanOrEqualTo(destinationX + width, Width, nameof(destinationX));
Guard.IsLessThanOrEqualTo(destinationY + height, Height, nameof(destinationY));
Guard.IsLessThanOrEqualTo(destinationZ + depth, Depth, nameof(destinationZ));
Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX));
Guard.IsLessThanOrEqualTo(sourceOffsetY + height, source.Height, nameof(sourceOffsetY));
Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, source.Depth, nameof(sourceOffsetZ));
Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX));
Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY));
Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ));
using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType);
@@ -452,14 +452,14 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
{
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
d3D12ResourceDestination: D3D12Resource,
(uint)destinationX,
(uint)destinationY,
(ushort)destinationZ,
(uint)destinationOffsetX,
(uint)destinationOffsetY,
(ushort)destinationOffsetZ,
d3D12ResourceSource: source.D3D12Resource,
d3D12PlacedSubresourceFootprintSource,
(uint)sourceX,
(uint)sourceY,
(ushort)sourceZ,
(uint)sourceOffsetX,
(uint)sourceOffsetY,
(ushort)sourceOffsetZ,
(uint)width,
(uint)height,
(ushort)depth);