Add missing transfer 2D texture copy APIs

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-12 02:48:15 +01:00
1 親 2abd19bd22
コミット 16c067ed34
2ファイル変更
+65

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

+47
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.Resources;
namespace ComputeSharp;
@@ -8,6 +9,52 @@ namespace ComputeSharp;
/// </summary>
public static class ReadBackTexture2DExtensions
{
/// <summary>
/// Reads the contents of a <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="ReadBackTexture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="destination">The target <see cref="ReadBackTexture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture2D{T}"/> instance to read data from.</param>
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source)
where T : unmanaged
{
source.CopyTo(destination, 0, 0, 0, 0, source.Width, source.Height);
}
/// <summary>
/// Reads the contents of a <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="ReadBackTexture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="destination">The target <see cref="ReadBackTexture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture2D{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="width">The width of the memory area to copy.</param>
/// <param name="height">The height of the memory area to copy.</param>
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int width, int height)
where T : unmanaged
{
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
}
/// <summary>
/// Reads the contents of a <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="ReadBackTexture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="destination">The target <see cref="ReadBackTexture2D{T}"/> instance to write data to.</param>
/// <param name="source">The input <see cref="Texture2D{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="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical 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>
public static void CopyFrom<T>(this ReadBackTexture2D<T> destination, Texture2D<T> source, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
where T : unmanaged
{
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
}
/// <summary>
/// Saves a texture to a specified file.
/// </summary>
+18
ファイルの表示
@@ -34,4 +34,22 @@ public static class UploadTexture2DExtensions
{
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, 0, 0, width, height);
}
/// <summary>
/// Reads the contents of a <see cref="UploadTexture2D{T}"/> instance and writes them into a target <see cref="Texture2D{T}"/> instance.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="source">The input <see cref="UploadTexture2D{T}"/> instance to read data from.</param>
/// <param name="destination">The target <see cref="Texture2D{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="destinationOffsetX">The horizontal offset in the destination texture.</param>
/// <param name="destinationOffsetY">The vertical 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>
public static void CopyTo<T>(this UploadTexture2D<T> source, Texture2D<T> destination, int sourceOffsetX, int sourceOffsetY, int destinationOffsetX, int destinationOffsetY, int width, int height)
where T : unmanaged
{
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
}
}