Skip to content

Commit 3541a4e

Browse files
committed
Use less tolerant comparer when Fma.IsSupported for resize tests
1 parent 6ab4b10 commit 3541a4e

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
using System.Runtime.InteropServices;
4+
using System.Runtime.Intrinsics.X86;
55
using Microsoft.DotNet.RemoteExecutor;
66
using SixLabors.ImageSharp.Formats;
77
using SixLabors.ImageSharp.Formats.Gif;
@@ -51,10 +51,11 @@ public void GifDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider)
5151

5252
image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false);
5353

54-
// Floating point differences result in minor pixel differences.
54+
// Floating point differences in FMA used in the ResizeKernel result in minor pixel differences.
5555
// Output have been manually verified.
56+
// For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594
5657
image.CompareToReferenceOutput(
57-
ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0002F : 0.0001F),
58+
ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0001F : 0.0002F),
5859
provider,
5960
testOutputDetails: details,
6061
appendPixelTypeToFileName: false);

tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
using System.Runtime.InteropServices;
4+
using System.Runtime.Intrinsics.X86;
55
using Microsoft.DotNet.RemoteExecutor;
66
using SixLabors.ImageSharp.Formats;
77
using SixLabors.ImageSharp.Formats.Png;
@@ -122,10 +122,11 @@ public void PngDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider)
122122

123123
image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false);
124124

125-
// Floating point differences result in minor pixel differences.
125+
// Floating point differences in FMA used in the ResizeKernel result in minor pixel differences.
126126
// Output have been manually verified.
127+
// For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594
127128
image.CompareToReferenceOutput(
128-
ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0005F : 0.0003F),
129+
ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0003F : 0.0005F),
129130
provider,
130131
testOutputDetails: details,
131132
appendPixelTypeToFileName: false);

tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using System.Runtime.InteropServices;
5+
using System.Runtime.Intrinsics.X86;
56
using Microsoft.DotNet.RemoteExecutor;
67
using SixLabors.ImageSharp.Formats;
78
using SixLabors.ImageSharp.Formats.Tga;
@@ -760,10 +761,11 @@ public void TgaDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider)
760761

761762
image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false);
762763

763-
// Floating point differences result in minor pixel differences.
764+
// Floating point differences in FMA used in the ResizeKernel result in minor pixel differences.
764765
// Output have been manually verified.
766+
// For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594
765767
image.CompareToReferenceOutput(
766-
ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0016F : 0.0001F),
768+
ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0001F : 0.0016F),
767769
provider,
768770
testOutputDetails: details,
769771
appendPixelTypeToFileName: false);

tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// ReSharper disable InconsistentNaming
55
using System.Runtime.InteropServices;
6+
using System.Runtime.Intrinsics.X86;
67
using SixLabors.ImageSharp.Formats;
78
using SixLabors.ImageSharp.Formats.Tiff;
89
using SixLabors.ImageSharp.Metadata;
@@ -695,10 +696,11 @@ public void TiffDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider
695696

696697
image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false);
697698

698-
// Floating point differences result in minor pixel differences.
699+
// Floating point differences in FMA used in the ResizeKernel result in minor pixel differences.
699700
// Output have been manually verified.
701+
// For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594
700702
image.CompareToReferenceOutput(
701-
TestEnvironment.OSArchitecture == Architecture.Arm64 ? ImageComparer.TolerantPercentage(0.0006F) : ImageComparer.Exact,
703+
Fma.IsSupported ? ImageComparer.Exact : ImageComparer.TolerantPercentage(0.0006F),
702704
provider,
703705
testOutputDetails: details,
704706
appendPixelTypeToFileName: false);

tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Six Labors Split License.
33

44
using System.Runtime.InteropServices;
5+
using System.Runtime.Intrinsics.X86;
56
using SixLabors.ImageSharp.Formats;
67
using SixLabors.ImageSharp.Formats.Webp;
78
using SixLabors.ImageSharp.PixelFormats;
@@ -367,10 +368,11 @@ public void WebpDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider
367368

368369
image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false);
369370

370-
// Floating point differences result in minor pixel differences.
371+
// Floating point differences in FMA used in the ResizeKernel result in minor pixel differences.
371372
// Output have been manually verified.
373+
// For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594
372374
image.CompareToReferenceOutput(
373-
ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0156F : 0.0007F),
375+
ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0007F : 0.0156F),
374376
provider,
375377
testOutputDetails: details,
376378
appendPixelTypeToFileName: false);

0 commit comments

Comments
 (0)