Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thresholds for Resize kernel tests #2440

Merged
merged 2 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -51,10 +51,11 @@ public void GifDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> 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);
Expand Down
43 changes: 40 additions & 3 deletions tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -122,15 +122,52 @@ public void PngDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> 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<Rgba32> provider)
{
HwIntrinsics intrinsicsFilter = HwIntrinsics.DisableHWIntrinsic;

FeatureTestRunner.RunWithHwIntrinsicsFeature(
RunTest,
intrinsicsFilter,
provider,
string.Empty);

static void RunTest(string arg1, string notUsed)
{
TestImageProvider<Rgba32> provider =
FeatureTestRunner.DeserializeForXunit<TestImageProvider<Rgba32>>(arg1);

DecoderOptions options = new()
{
TargetSize = new() { Width = 150, Height = 150 }
};

using Image<Rgba32> 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)]
Expand Down
6 changes: 4 additions & 2 deletions tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -760,10 +761,11 @@ public void TgaDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> 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);
Expand Down
6 changes: 4 additions & 2 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -695,10 +696,11 @@ public void TiffDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> 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);
Expand Down
6 changes: 4 additions & 2 deletions tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -367,10 +368,11 @@ public void WebpDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> 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);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.