diff --git a/samples/ComputeSharp.SwapChain/Shaders/FractalTiling.cs b/samples/ComputeSharp.SwapChain/Shaders/FractalTiling.cs
index ee97ff2e..db12f72d 100644
--- a/samples/ComputeSharp.SwapChain/Shaders/FractalTiling.cs
+++ b/samples/ComputeSharp.SwapChain/Shaders/FractalTiling.cs
@@ -43,6 +43,7 @@
}
color.XYZ = Hlsl.Pow(color.XYZ, new Float3(0.7f, 0.8f, 0.5f));
+ color.W = 1.0f;
texture[ThreadIds.XY] = color;
}
diff --git a/tests/ComputeSharp.Tests/Assets/ColorfulInfinity.jpg b/tests/ComputeSharp.Tests/Assets/ColorfulInfinity.jpg
new file mode 100644
index 00000000..50e964e2
Binary files /dev/null and b/tests/ComputeSharp.Tests/Assets/ColorfulInfinity.jpg differ
diff --git a/tests/ComputeSharp.Tests/Assets/FractalTiling.jpg b/tests/ComputeSharp.Tests/Assets/FractalTiling.jpg
new file mode 100644
index 00000000..8926cf69
Binary files /dev/null and b/tests/ComputeSharp.Tests/Assets/FractalTiling.jpg differ
diff --git a/tests/ComputeSharp.Tests/Assets/MengerJourney.jpg b/tests/ComputeSharp.Tests/Assets/MengerJourney.jpg
new file mode 100644
index 00000000..ee41ffe1
Binary files /dev/null and b/tests/ComputeSharp.Tests/Assets/MengerJourney.jpg differ
diff --git a/tests/ComputeSharp.Tests/Assets/TwoTiledTruchet.jpg b/tests/ComputeSharp.Tests/Assets/TwoTiledTruchet.jpg
new file mode 100644
index 00000000..fb107ddc
Binary files /dev/null and b/tests/ComputeSharp.Tests/Assets/TwoTiledTruchet.jpg differ
diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
index 69ea6dec..8b157cb4 100644
--- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
+++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
@@ -27,6 +27,10 @@
+
+
+
+
@@ -34,6 +38,18 @@
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
TextTemplatingFileGenerator
Texture2DTests.Pixels.g.cs
diff --git a/tests/ComputeSharp.Tests/ImagingTests.cs b/tests/ComputeSharp.Tests/ImagingTests.cs
index c51cb09a..ef68773d 100644
--- a/tests/ComputeSharp.Tests/ImagingTests.cs
+++ b/tests/ComputeSharp.Tests/ImagingTests.cs
@@ -67,7 +67,7 @@ namespace ComputeSharp.Tests
///
/// An tolerant image comparer type, from ImageSharp.
///
- private static class TolerantImageComparer
+ internal static class TolerantImageComparer
{
///
/// Asserts that two images are equal.
diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs
new file mode 100644
index 00000000..f16e267c
--- /dev/null
+++ b/tests/ComputeSharp.Tests/ShadersTests.cs
@@ -0,0 +1,82 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using ComputeSharp.SwapChain.Shaders;
+using ComputeSharp.Tests.Attributes;
+using ComputeSharp.Tests.Extensions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SixLabors.ImageSharp;
+using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
+
+namespace ComputeSharp.Tests
+{
+ [TestClass]
+ [TestCategory("Shaders")]
+ public class ShadersTests
+ {
+ [CombinatorialTestMethod]
+ [AllDevices]
+ public void ColorfulInfinity(Device device)
+ {
+ RunAndCompareShader(device, static texture => new ColorfulInfinity(texture, 0), 0.0000193f);
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ public void FractalTiling(Device device)
+ {
+ RunAndCompareShader(device, static texture => new FractalTiling(texture, 0), 0.0000282f);
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ public void MengerJourney(Device device)
+ {
+ RunAndCompareShader(device, static texture => new MengerJourney(texture, 0), 0.0000864f);
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ public void TwoTiledTruchet(Device device)
+ {
+ RunAndCompareShader(device, static texture => new TwoTiledTruchet(texture, 0), 0.00033f);
+ }
+
+ ///
+ /// Executes a given test for a specified shader.
+ ///
+ /// The type of shader to test.
+ /// The device to use.
+ /// A producer to create an instance of the shader to run.
+ /// The comparison delta.
+ private static void RunAndCompareShader(Device device, Func, T> factory, float delta)
+ where T : struct, IComputeShader
+ {
+ _ = device.Get();
+
+ string expectedPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets", $"{typeof(T).Name}.jpg");
+
+ IImageInfo imageInfo = Image.Identify(expectedPath);
+
+ using Image image = new(imageInfo.Width, imageInfo.Height);
+
+ using (ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(imageInfo.Width, imageInfo.Height))
+ {
+ device.Get().For(texture.Width, texture.Height, factory(texture));
+
+ _ = image.TryGetSinglePixelSpan(out Span span);
+
+ texture.CopyTo(MemoryMarshal.Cast(span));
+ }
+
+ string actualPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Shaders", $"{typeof(T).Name}.jpg");
+
+ _ = Directory.CreateDirectory(Path.GetDirectoryName(actualPath)!);
+
+ image.Save(actualPath);
+
+ ImagingTests.TolerantImageComparer.AssertEqual(expectedPath, actualPath, delta);
+ }
+ }
+}