/// <summary>
    /// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture3D{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="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> destination, ReadOnlySpan <T> source)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);

        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="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="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> destination, ReadOnlySpan <T> source, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);

        destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, 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="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="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> destination, T[] source, int sourceOffset, Range x, Range y, Range z)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);
        Guard.IsNotNull(source);

        destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z);
    }
    /// <summary>
    /// Reads the contents of an <see cref="UploadTexture3D{T}"/> instance and writes them into a target <see cref="Texture3D{T}"/> instance.
    /// </summary>
    /// <typeparam name="T">The type of items stored on the texture.</typeparam>
    /// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
    /// <param name="source">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
    public static void CopyFrom <T>(this Texture3D <T> destination, UploadTexture3D <T> source)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);
        Guard.IsNotNull(source);

        destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.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="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> destination, T[] source)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);
        Guard.IsNotNull(source);

        destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth);
    }
    /// <summary>
    /// Reads the contents of an <see cref="UploadTexture3D{T}"/> instance and writes them into a target <see cref="Texture3D{T}"/> instance.
    /// </summary>
    /// <typeparam name="T">The type of items stored on the texture.</typeparam>
    /// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
    /// <param name="source">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</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 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 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 CopyFrom <T>(this Texture3D <T> destination, UploadTexture3D <T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);
        Guard.IsNotNull(source);

        destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, 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="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)
            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));

            texture.CopyFrom(ref source[0, 0, 0], source.Length, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
        }
示例#8
0
    /// <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="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> destination, T[,,] source)
        where T : unmanaged
    {
        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));

        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 <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="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)
            where T : unmanaged
        {
            var(offsetX, width)  = x.GetOffsetAndLength(texture.Width);
            var(offsetY, height) = y.GetOffsetAndLength(texture.Height);
            var(offsetZ, depth)  = z.GetOffsetAndLength(texture.Depth);

            texture.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth);
        }
示例#10
0
    /// <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="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> destination, ReadOnlySpan <T> source, Range x, Range y, Range z)
        where T : unmanaged
    {
        Guard.IsNotNull(destination);

        var(offsetX, width)  = x.GetOffsetAndLength(destination.Width);
        var(offsetY, height) = y.GetOffsetAndLength(destination.Height);
        var(offsetZ, depth)  = z.GetOffsetAndLength(destination.Depth);

        destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth);
    }
 /// <summary>
 /// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to the current <see cref="Texture3D{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="texture">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)
     where T : unmanaged
 {
     texture.CopyFrom(source, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
 }
示例#12
0
 /// <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="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="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> destination, T[] source, int sourceOffset, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
     where T : unmanaged
 {
     destination.CopyFrom(source.AsSpan(sourceOffset), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
 }
 /// <summary>
 /// Reads the contents of a <see cref="UploadTexture3D{T}"/> instance and writes them into a target <see cref="Texture3D{T}"/> instance.
 /// </summary>
 /// <typeparam name="T">The type of items stored on the texture.</typeparam>
 /// <param name="source">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
 /// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</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 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 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 UploadTexture3D <T> source, Texture3D <T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
     where T : unmanaged
 {
     destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
 }
 /// <summary>
 /// Reads the contents of a <see cref="UploadTexture3D{T}"/> instance and writes them into a target <see cref="Texture3D{T}"/> instance.
 /// </summary>
 /// <typeparam name="T">The type of items stored on the texture.</typeparam>
 /// <param name="texture">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
 /// <param name="destination">The target <see cref="Texture3D{T}"/> instance to write data to.</param>
 public static void CopyTo <T>(this UploadTexture3D <T> texture, Texture3D <T> destination)
     where T : unmanaged
 {
     destination.CopyFrom(texture, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
 }
 /// <summary>
 /// Reads the contents of a <see cref="UploadTexture3D{T}"/> instance and writes them into a target <see cref="Texture3D{T}"/> instance.
 /// </summary>
 /// <typeparam name="T">The type of items stored on the texture.</typeparam>
 /// <param name="texture">The input <see cref="UploadTexture3D{T}"/> instance to read data from.</param>
 /// <param name="destination">The target <see cref="Texture3D{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="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 UploadTexture3D <T> texture, Texture3D <T> destination, int x, int y, int z, int width, int height, int depth)
     where T : unmanaged
 {
     destination.CopyFrom(texture, x, y, z, 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="source">The input <typeparamref name="T"/> array to read data from.</param>
 public static void CopyFrom <T>(this Texture3D <T> texture, T[] source)
     where T : unmanaged
 {
     texture.CopyFrom(source.AsSpan(), 0, 0, 0, texture.Width, texture.Height, texture.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="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="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)
     where T : unmanaged
 {
     texture.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, x, y, z, width, height, depth);
 }
示例#18
0
 /// <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="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> destination, T[] source, Range x, Range y, Range z)
     where T : unmanaged
 {
     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="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="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)
     where T : unmanaged
 {
     texture.CopyFrom(source.AsSpan(offset), x, y, z, 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="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 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)
     where T : unmanaged
 {
     texture.CopyFrom(source.AsSpan(offset), x, y, z);
 }