diff --git a/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs index 79fccef8..e00d9301 100644 --- a/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs +++ b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs @@ -4,7 +4,6 @@ /// A simple shader to get started with based on shadertoy new shader template. /// Ported from . /// - /// [AutoConstructor] internal readonly partial struct HelloWorld : IPixelShader { diff --git a/tests/ComputeSharp.Tests/Assets/HelloWorld.png b/tests/ComputeSharp.Tests/Assets/HelloWorld.png new file mode 100644 index 00000000..3595906a Binary files /dev/null and b/tests/ComputeSharp.Tests/Assets/HelloWorld.png differ diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj index b67a7de8..51b40973 100644 --- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj +++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj @@ -27,6 +27,7 @@ + @@ -45,6 +46,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs b/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs new file mode 100644 index 00000000..93f2b8cf --- /dev/null +++ b/tests/ComputeSharp.Tests/Shaders/Compute/HelloWorld.cs @@ -0,0 +1,28 @@ +namespace ComputeSharp.SwapChain.Shaders.Compute +{ + /// + /// A simple shader to get started with based on shadertoy new shader template. + /// Ported from . + /// + [AutoConstructor] + internal readonly partial struct HelloWorld : IPixelShader + { + /// + /// The current time since the start of the application. + /// + public readonly float time; + + /// + public Float4 Execute() + { + // Normalized screen space UV coordinates from 0.0f to 1.0f + Float2 uv = ThreadIds.Normalized.XY; + + // Time varying pixel color + Float3 col = 0.5f + 0.5f * Hlsl.Cos(time + new Float3(uv, uv.X) + new Float3(0, 2, 4)); + + // Output to screen + return new(col, 1f); + } + } +} diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs index 7300fd6f..e40d336e 100644 --- a/tests/ComputeSharp.Tests/ShadersTests.cs +++ b/tests/ComputeSharp.Tests/ShadersTests.cs @@ -16,6 +16,15 @@ namespace ComputeSharp.Tests [TestCategory("Shaders")] public class ShadersTests { + [CombinatorialTestMethod] + [AllDevices] + [Data(typeof(HelloWorld))] + [Data(typeof(SwapChain.Shaders.Compute.HelloWorld))] + public void HelloWorld(Device device, Type shaderType) + { + RunAndCompareShader(device, shaderType, 0.0000004f); + } + [CombinatorialTestMethod] [AllDevices] [Data(typeof(ColorfulInfinity))]