From e292eb6d9d96fd55ca72f819cca771c9577f5fd1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 7 May 2022 20:18:20 +0200 Subject: [PATCH] Add unit tests for new buffer output APIs --- .../D2D1InteropServicesTests.cs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs index c797a527..fa89d21e 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs @@ -42,4 +42,61 @@ public partial class D2D1InteropServicesTests return 0; } } + + [TestMethod] + public unsafe void GetOutputBufferPrecision() + { + Assert.AreEqual(D2D1PixelShader.GetOutputBufferPrecision(), D2D1BufferPrecision.Unknown); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferPrecision(), D2D1BufferPrecision.Int16Normalized); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferPrecision(), D2D1BufferPrecision.Unknown); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferPrecision(), D2D1BufferPrecision.Int8NormalizedSRGB); + } + + [TestMethod] + public unsafe void GetOutputBufferChannelDepth() + { + Assert.AreEqual(D2D1PixelShader.GetOutputBufferChannelDepth(), D2D1ChannelDepth.Default); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferChannelDepth(), D2D1ChannelDepth.Default); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferChannelDepth(), D2D1ChannelDepth.Four); + Assert.AreEqual(D2D1PixelShader.GetOutputBufferChannelDepth(), D2D1ChannelDepth.One); + } + + [D2DInputCount(0)] + partial struct EmptyShader : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + + [D2DInputCount(0)] + [D2DOutputBuffer(D2D1BufferPrecision.Int16Normalized)] + partial struct OnlyBufferPrecisionShader : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + + [D2DInputCount(0)] + [D2DOutputBuffer(D2D1ChannelDepth.Four)] + partial struct OnlyChannelDepthShader : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } + + [D2DInputCount(0)] + [D2DOutputBuffer(D2D1BufferPrecision.Int8NormalizedSRGB, D2D1ChannelDepth.One)] + partial struct CustomBufferOutputShader : ID2D1PixelShader + { + public Float4 Execute() + { + return 0; + } + } } \ No newline at end of file