From f7b03ea955b939415dc8a8c2db755d9e0464d353 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 21 Sep 2024 18:04:11 +0200 Subject: [PATCH] Add unit test for D2D pixel shader --- .../ShaderRewriterTests.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs index b1fab05a..6cd13fdf 100644 --- a/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/ShaderRewriterTests.cs @@ -208,4 +208,33 @@ public partial class ShaderRewriterTests return new float4(0.0f, 1.0f, 0.0f, 1.0f); } } + + // See https://github.com/Sergio0694/ComputeSharp/issues/855 + [TestMethod] + public void ExplicitEntryPointMethodPixelShader_IsRewrittenCorrectly() + { + D2D1ShaderInfo shaderInfo = D2D1ReflectionServices.GetShaderInfo(); + + Assert.AreEqual(""" + #define D2D_INPUT_COUNT 0 + + #include "d2d1effecthelpers.hlsli" + + D2D_PS_ENTRY(Execute) + { + return (float4)0; + } + """, shaderInfo.HlslSource); + } + + [D2DInputCount(0)] + [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] + [D2DGeneratedPixelShaderDescriptor] + internal readonly partial struct ExplicitEntryPointMethodPixelShader : ID2D1PixelShader + { + float4 ID2D1PixelShader.Execute() + { + return default; + } + } } \ No newline at end of file