diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.cs index 957cacd7..0ee94a6b 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1InteropServices.cs @@ -79,6 +79,19 @@ public static unsafe class D2D1InteropServices return new ReadOnlySpan(bytecodePtr, bytecodeSize).ToArray(); } + /// + /// Gets the number of inputs from an input D2D1 pixel shader. + /// + /// The type of D2D1 pixel shader to get the input count for. + /// The number of inputs for the D2D1 pixel shader of type . + public static uint GetPixelShaderInputCount() + where T : unmanaged, ID2D1PixelShader + { + Unsafe.SkipInit(out T shader); + + return shader.GetInputCount(); + } + /// /// Gets the constant buffer from an input D2D1 pixel shader. /// diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs new file mode 100644 index 00000000..0e8ef2d8 --- /dev/null +++ b/tests/ComputeSharp.D2D1.Tests/D2D1InteropServicesTests.cs @@ -0,0 +1,18 @@ +using ComputeSharp.D2D1.Interop; +using ComputeSharp.D2D1.Tests.Effects; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ComputeSharp.D2D1.Tests; + +[TestClass] +[TestCategory("D2D1InteropServices")] +public class D2D1InteropServicesTests +{ + [TestMethod] + public unsafe void GetInputCount() + { + Assert.AreEqual(D2D1InteropServices.GetPixelShaderInputCount(), 1u); + Assert.AreEqual(D2D1InteropServices.GetPixelShaderInputCount(), 1u); + Assert.AreEqual(D2D1InteropServices.GetPixelShaderInputCount(), 0u); + } +} \ No newline at end of file