Add Texture2D<T>.ToArray overload
このコミットが含まれているのは:
1 親
aef6630709
コミット
d657b9cc95
2ファイル変更
+77
検索条件に一致するファイルはありません
@@ -112,6 +112,56 @@ public partial class Texture2DTests
|
||||
texture.Dispose();
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
[Resource(typeof(ReadWriteTexture2D<>))]
|
||||
[Data(0, 0, 64, 64)]
|
||||
[Data(0, 14, 64, 50)]
|
||||
[Data(14, 0, 50, 64)]
|
||||
[Data(10, 10, 54, 54)]
|
||||
[Data(20, 20, 32, 27)]
|
||||
[Data(60, 0, 4, 64)]
|
||||
[Data(0, 60, 64, 4)]
|
||||
[Data(63, 2, 1, 60)]
|
||||
[Data(2, 63, 60, 1)]
|
||||
public void GetData_RangeToArray_Ok(Device device, Type textureType, int x, int y, int width, int height)
|
||||
{
|
||||
float[] array = Enumerable.Range(0, 4096).Select(static i => (float)i).ToArray();
|
||||
|
||||
using Texture2D<float> texture = device.Get().AllocateTexture2D(textureType, array, 64, 64);
|
||||
|
||||
float[,] result = texture.ToArray(x, y, width, height);
|
||||
|
||||
Assert.AreEqual(height, result.GetLength(0));
|
||||
Assert.AreEqual(width, result.GetLength(1));
|
||||
|
||||
Span2D<float> expected = new Span2D<float>(array, 64, 64).Slice(y, x, height, width);
|
||||
Span2D<float> data = new(result);
|
||||
|
||||
CollectionAssert.AreEqual(expected.ToArray(), data.ToArray());
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
[Resource(typeof(ReadWriteTexture2D<>))]
|
||||
[Data(0, -1, 50, 50)]
|
||||
[Data(-1, 0, 50, 50)]
|
||||
[Data(12, 0, -1, 50)]
|
||||
[Data(12, 0, 20, -1)]
|
||||
[Data(12, 20, 20, 50)]
|
||||
[Data(12, 20, 60, 20)]
|
||||
[Data(80, 20, 40, 20)]
|
||||
[Data(0, 80, 40, 20)]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void GetData_RangeToArray_Fail(Device device, Type textureType, int x, int y, int width, int height)
|
||||
{
|
||||
using Texture2D<float> texture = device.Get().AllocateTexture2D<float>(textureType, 64, 64);
|
||||
|
||||
_ = texture.ToArray(x, y, width, height);
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Resource(typeof(ReadOnlyTexture2D<>))]
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする