Add unit tests for input description APIs

このコミットが含まれているのは:
Sergio Pedri committed 2022-05-08 18:40:26 +02:00
1 親 7a5386a55e
コミット ecae463892
1ファイル変更
+68 -1
+68 -1
ファイルの表示
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.Interop;
using System;
using ComputeSharp.D2D1.Interop;
using ComputeSharp.D2D1.Tests.Effects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -99,4 +100,70 @@ public partial class D2D1InteropServicesTests
return 0;
}
}
[TestMethod]
public unsafe void GetInputDescriptions_Empty()
{
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<CheckerboardClipEffect>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<InvertEffect>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<InvertWithThresholdEffect>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<PixelateEffect.Shader>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<ZonePlateEffect>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<ShaderWithMultipleInputs>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<EmptyShader>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<OnlyBufferPrecisionShader>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<OnlyChannelDepthShader>().Length, 0);
Assert.AreEqual(D2D1PixelShader.GetInputDescriptions<CustomBufferOutputShader>().Length, 0);
}
[TestMethod]
public unsafe void GetInputDescriptions_Custom()
{
ReadOnlyMemory<D2D1InputDescription> inputDescriptions = D2D1PixelShader.GetInputDescriptions<ShaderWithInputDescriptions>();
Assert.AreEqual(inputDescriptions.Length, 5);
ReadOnlySpan<D2D1InputDescription> span = inputDescriptions.Span;
Assert.AreEqual(span[0].Index, 0);
Assert.AreEqual(span[0].Filter, D2D1Filter.MinPointMagLinearMipPoint);
Assert.AreEqual(span[0].LevelOfDetail, 0);
Assert.AreEqual(span[1].Index, 1);
Assert.AreEqual(span[1].Filter, D2D1Filter.Anisotropic);
Assert.AreEqual(span[1].LevelOfDetail, 0);
Assert.AreEqual(span[2].Index, 2);
Assert.AreEqual(span[2].Filter, D2D1Filter.MinLinearMagPointMinLinear);
Assert.AreEqual(span[2].LevelOfDetail, 4);
Assert.AreEqual(span[3].Index, 5);
Assert.AreEqual(span[3].Filter, D2D1Filter.MinMagPointMipLinear);
Assert.AreEqual(span[3].LevelOfDetail, 0);
Assert.AreEqual(span[4].Index, 6);
Assert.AreEqual(span[4].Filter, D2D1Filter.MinPointMagMipLinear);
Assert.AreEqual(span[4].LevelOfDetail, 3);
}
[D2DInputCount(7)]
[D2DInputSimple(0)]
[D2DInputSimple(2)]
[D2DInputComplex(1)]
[D2DInputComplex(3)]
[D2DInputComplex(5)]
[D2DInputSimple(6)]
[D2DInputDescription(0, D2D1Filter.MinPointMagLinearMipPoint)]
[D2DInputDescription(1, D2D1Filter.Anisotropic)]
[D2DInputDescription(2, D2D1Filter.MinLinearMagPointMinLinear, LevelOfDetail = 4)]
[D2DInputDescription(5, D2D1Filter.MinMagPointMipLinear)]
[D2DInputDescription(6, D2D1Filter.MinPointMagMipLinear, LevelOfDetail = 3)]
partial struct ShaderWithInputDescriptions : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
}