|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | 3 |
|
4 | | -using System.Runtime.InteropServices; |
| 4 | +using System.Runtime.Intrinsics.X86; |
5 | 5 | using Microsoft.DotNet.RemoteExecutor; |
6 | 6 | using SixLabors.ImageSharp.Formats; |
7 | 7 | using SixLabors.ImageSharp.Formats.Png; |
@@ -122,15 +122,52 @@ public void PngDecoder_Decode_Resize<TPixel>(TestImageProvider<TPixel> provider) |
122 | 122 |
|
123 | 123 | image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); |
124 | 124 |
|
125 | | - // Floating point differences result in minor pixel differences. |
| 125 | + // Floating point differences in FMA used in the ResizeKernel result in minor pixel differences. |
126 | 126 | // Output have been manually verified. |
| 127 | + // For more details see discussion: https://github.com/SixLabors/ImageSharp/pull/1513#issuecomment-763643594 |
127 | 128 | image.CompareToReferenceOutput( |
128 | | - ImageComparer.TolerantPercentage(TestEnvironment.OSArchitecture == Architecture.Arm64 ? 0.0005F : 0.0003F), |
| 129 | + ImageComparer.TolerantPercentage(Fma.IsSupported ? 0.0003F : 0.0005F), |
129 | 130 | provider, |
130 | 131 | testOutputDetails: details, |
131 | 132 | appendPixelTypeToFileName: false); |
132 | 133 | } |
133 | 134 |
|
| 135 | + [Theory] |
| 136 | + [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] |
| 137 | + public void PngDecoder_Decode_Resize_ScalarResizeKernel(TestImageProvider<Rgba32> provider) |
| 138 | + { |
| 139 | + HwIntrinsics intrinsicsFilter = HwIntrinsics.DisableHWIntrinsic; |
| 140 | + |
| 141 | + FeatureTestRunner.RunWithHwIntrinsicsFeature( |
| 142 | + RunTest, |
| 143 | + intrinsicsFilter, |
| 144 | + provider, |
| 145 | + string.Empty); |
| 146 | + |
| 147 | + static void RunTest(string arg1, string notUsed) |
| 148 | + { |
| 149 | + TestImageProvider<Rgba32> provider = |
| 150 | + FeatureTestRunner.DeserializeForXunit<TestImageProvider<Rgba32>>(arg1); |
| 151 | + |
| 152 | + DecoderOptions options = new() |
| 153 | + { |
| 154 | + TargetSize = new() { Width = 150, Height = 150 } |
| 155 | + }; |
| 156 | + |
| 157 | + using Image<Rgba32> image = provider.GetImage(PngDecoder.Instance, options); |
| 158 | + |
| 159 | + FormattableString details = $"{options.TargetSize.Value.Width}_{options.TargetSize.Value.Height}"; |
| 160 | + |
| 161 | + image.DebugSave(provider, testOutputDetails: details, appendPixelTypeToFileName: false); |
| 162 | + |
| 163 | + image.CompareToReferenceOutput( |
| 164 | + ImageComparer.TolerantPercentage(0.0005F), |
| 165 | + provider, |
| 166 | + testOutputDetails: details, |
| 167 | + appendPixelTypeToFileName: false); |
| 168 | + } |
| 169 | + } |
| 170 | + |
134 | 171 | [Theory] |
135 | 172 | [WithFile(TestImages.Png.AverageFilter3BytesPerPixel, PixelTypes.Rgba32)] |
136 | 173 | [WithFile(TestImages.Png.AverageFilter4BytesPerPixel, PixelTypes.Rgba32)] |
|
0 commit comments