diff --git a/samples/ComputeSharp.SwapChain/Program.cs b/samples/ComputeSharp.SwapChain/Program.cs index 7e7332f2..c44c7992 100644 --- a/samples/ComputeSharp.SwapChain/Program.cs +++ b/samples/ComputeSharp.SwapChain/Program.cs @@ -20,6 +20,7 @@ namespace ComputeSharp.SwapChain /// private static readonly Win32Application[] Samples = new Win32Application[] { + new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), new SwapChainApplication(static time => new((float)time.TotalSeconds)), diff --git a/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs new file mode 100644 index 00000000..1a38675b --- /dev/null +++ b/samples/ComputeSharp.SwapChain/Shaders/HelloWorld.cs @@ -0,0 +1,28 @@ +namespace ComputeSharp.SwapChain.Shaders +{ + /// + /// 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.0 to 1.0 + 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/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..5393f89b 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..f12adcdb --- /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.0 to 1.0 + 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))]