Add mirrored Texture3D<T> extensions for transfers

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-12 14:27:33 +01:00
1 親 453eec3366
コミット 391c809f8d
3ファイル変更
+162 -9

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

+60
ファイルの表示
@@ -0,0 +1,60 @@
using ComputeSharp.Resources;
namespace ComputeSharp;
/// <summary>
/// A <see langword="class"/> that contains extension methods for the <see cref="ReadBackTexture3D{T}"/> type.
/// </summary>
public static class ReadBackTexture3DExtensions
{
/// <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="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture3D{T}"/> instance to read data from.</param>
public static void CopyFrom<T>(this ReadBackTexture3D<T> destination, Texture3D<T> source)
where T : unmanaged
{
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="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture3D{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="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 ReadBackTexture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
where T : unmanaged
{
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, 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="destination">The target <see cref="ReadBackTexture3D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture3D{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 ReadBackTexture3D<T> destination, Texture3D<T> source, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
where T : unmanaged
{
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
}
}
+72
ファイルの表示
@@ -180,6 +180,27 @@ public static class Texture3DExtensions
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, 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="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="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 Texture3D<T> source, ReadBackTexture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int destinationOffsetX, int destinationOffsetY, int destinationOffsetZ, int width, int height, int depth)
where T : unmanaged
{
source.CopyTo(destination, 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>
@@ -329,4 +350,55 @@ public static class Texture3DExtensions
{
destination.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, 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>
public static void CopyFrom<T>(this Texture3D<T> destination, UploadTexture3D<T> source)
where T : unmanaged
{
destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.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="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 width, int height, int depth)
where T : unmanaged
{
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, width, height, 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
{
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
}
}
+30 -9
ファイルの表示
@@ -11,29 +11,50 @@ public static class UploadTexture3DExtensions
/// 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="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>
public static void CopyTo<T>(this UploadTexture3D<T> texture, Texture3D<T> destination)
public static void CopyTo<T>(this UploadTexture3D<T> source, Texture3D<T> destination)
where T : unmanaged
{
destination.CopyFrom(texture, 0, 0, 0, 0, 0, 0, texture.Width, texture.Height, texture.Depth);
destination.CopyFrom(source, 0, 0, 0, 0, 0, 0, source.Width, source.Height, source.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="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="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 UploadTexture3D<T> texture, Texture3D<T> destination, int x, int y, int z, int width, int height, int depth)
public static void CopyTo<T>(this UploadTexture3D<T> source, Texture3D<T> destination, int sourceOffsetX, int sourceOffsetY, int sourceOffsetZ, int width, int height, int depth)
where T : unmanaged
{
destination.CopyFrom(texture, x, y, z, 0, 0, 0, width, height, depth);
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, sourceOffsetZ, 0, 0, 0, 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);
}
}