Added Texture2D<T> unit tests
このコミットが含まれているのは:
1 親
6904416d0b
コミット
eef8e41899
4ファイル変更
+202
-4
検索条件に一致するファイルはありません
@@ -31,6 +31,27 @@ namespace ComputeSharp.Tests.Extensions
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new <see cref="Texture2D{T}"/> instance of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the texture.</typeparam>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
|
||||
/// <param name="type">The type of texture to allocate.</param>
|
||||
/// <param name="width">The width of the texture to create.</param>
|
||||
/// <param name="height">The height of the texture to create.</param>
|
||||
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested size.</returns>
|
||||
[Pure]
|
||||
public static Texture2D<T> AllocateTexture2D<T>(this GraphicsDevice device, Type type, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
_ when type == typeof(ReadOnlyTexture2D<>) => device.AllocateReadOnlyTexture2D<T>(width, height),
|
||||
_ when type == typeof(ReadWriteTexture2D<>) => device.AllocateReadWriteTexture2D<T>(width, height),
|
||||
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new <see cref="Buffer{T}"/> instance of the specified type.
|
||||
/// </summary>
|
||||
@@ -52,6 +73,28 @@ namespace ComputeSharp.Tests.Extensions
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new <see cref="Texture2D{T}"/> instance of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the texture.</typeparam>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance to allocate the texture for.</param>
|
||||
/// <param name="type">The type of buffer to allocate.</param>
|
||||
/// <param name="data">The data to load on the texture.</param>
|
||||
/// <param name="width">The width of the texture to create.</param>
|
||||
/// <param name="height">The height of the texture to create.</param>
|
||||
/// <returns>A <see cref="Texture2D{T}"/> instance of the requested type.</returns>
|
||||
[Pure]
|
||||
public static Texture2D<T> AllocateTexture2D<T>(this GraphicsDevice device, Type type, T[] data, int width, int height)
|
||||
where T : unmanaged
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
_ when type == typeof(ReadOnlyTexture2D<>) => device.AllocateReadOnlyTexture2D(data, width, height),
|
||||
_ when type == typeof(ReadWriteTexture2D<>) => device.AllocateReadWriteTexture2D(data, width, height),
|
||||
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates a new <see cref="Buffer{T}"/> instance of the specified type.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする