diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index b4facfa3fe..376bb4a06f 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Gif; @@ -51,10 +51,11 @@ public void GifDecoder_Decode_Resize(TestImageProvider provider) image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); - // Floating point differences result in minor pixel differences. + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. // Output have been manually verified. + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 image.CompareToReferenceOutput( - ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0002F : 0.0001F), + ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0001F : 0.0002F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index afd33608ce..97d7b02bea 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -1,7 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; @@ -122,15 +122,52 @@ public void PngDecoder_Decode_Resize(TestImageProvider provider) image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); - // Floating point differences result in minor pixel differences. + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. // Output have been manually verified. + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 image.CompareToReferenceOutput( - ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0005F : 0.0003F), + ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0003F : 0.0005F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); } + [Theory] + [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] + public void PngDecoder_Decode_Resize_ScalarResizeKernel(TestImageProvider provider) + { + HwIntrinsics intrinsicsFilter = HwIntrinsics.DisableHWIntrinsic; + + FeatureTestRunner.RunWithHwIntrinsicsFeature( + RunTest, + intrinsicsFilter, + provider, + string.Empty); + + static void RunTest(string arg1, string notUsed) + { + TestImageProvider provider = + FeatureTestRunner.DeserializeForXunit>(arg1); + + DecoderOptions options = new() + { + TargetSize = new() { Width = 150, Height = 150 } + }; + + using Image image = provider.GetImage(PngDecoder.Instance, options); + + FormattableString details = $"{options.TargetSize.Value.Width}_{options.TargetSize.Value.Height}"; + + image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); + + image.CompareToReferenceOutput( + ImageComparer.TolerantPercentage(0.0005F), + provider, + testOutputDetails: details, + appendPixelTypeToFileName: false); + } + } + [Theory] [WithFile(TestImages.Png.AverageFilter3BytesPerPixel, PixelTypes.Rgba32)] [WithFile(TestImages.Png.AverageFilter4BytesPerPixel, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index 0bbe1984f0..da5de8e898 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Tga; @@ -760,10 +761,11 @@ public void TgaDecoder_Decode_Resize(TestImageProvider provider) image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); - // Floating point differences result in minor pixel differences. + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. // Output have been manually verified. + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 image.CompareToReferenceOutput( - ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0016F : 0.0001F), + ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0001F : 0.0016F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 1f664cf646..a9e2b75c02 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -3,6 +3,7 @@ // ReSharper disable InconsistentNaming using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Tiff; using SixLabors.ImageSharp.Metadata; @@ -695,10 +696,11 @@ public void TiffDecoder_Decode_Resize(TestImageProvider provider image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); - // Floating point differences result in minor pixel differences. + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. // Output have been manually verified. + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 image.CompareToReferenceOutput( - TestEnvironment.OSArchitecture == Architecture.Arm64 ? ImageComparer.TolerantPercentage(0.0006F) : ImageComparer.Exact, + Fma.IsSupported ? ImageComparer.Exact : ImageComparer.TolerantPercentage(0.0006F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 010af3fbbe..f95b003d0a 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.PixelFormats; @@ -367,10 +368,11 @@ public void WebpDecoder_Decode_Resize(TestImageProvider provider image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); - // Floating point differences result in minor pixel differences. + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. // Output have been manually verified. + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 image.CompareToReferenceOutput( - ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0156F : 0.0007F), + ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0007F : 0.0156F), provider, testOutputDetails: details, appendPixelTypeToFileName: false); diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/PngDecoder_Decode_Resize_ScalarResizeKernel_splash_150_150.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/PngDecoder_Decode_Resize_ScalarResizeKernel_splash_150_150.png new file mode 100644 index 0000000000..62251f931b --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/PngDecoder_Decode_Resize_ScalarResizeKernel_splash_150_150.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11e8aa44e32ae133914c91cc32a58ecdba1a107d36a0ca252e0e088053e57be1 +size 28129