Browse Source
Merge pull request #1548 from SixLabors/bp/fix1546
Add check for Avx2 in ResizeKernel
pull/1554/head
Brian Popow
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
25 additions and
4 deletions
-
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs
-
tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs
-
tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs
|
|
|
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
|
public Vector4 ConvolveCore(ref Vector4 rowStartRef) |
|
|
|
{ |
|
|
|
#if SUPPORTS_RUNTIME_INTRINSICS
|
|
|
|
if (Fma.IsSupported) |
|
|
|
if (Avx2.IsSupported && Fma.IsSupported) |
|
|
|
{ |
|
|
|
float* bufferStart = this.bufferPtr; |
|
|
|
float* bufferEnd = bufferStart + (this.Length & ~3); |
|
|
|
|
|
|
|
@ -1,8 +1,10 @@ |
|
|
|
// Copyright (c) Six Labors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
using SixLabors.ImageSharp.Processing; |
|
|
|
using SixLabors.ImageSharp.Processing.Processors.Transforms; |
|
|
|
using SixLabors.ImageSharp.Tests.TestUtilities; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
|
|
|
@ -85,5 +87,24 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
|
|
|
Assert.Equal(compand, resizeOptions.Compand); |
|
|
|
Assert.Equal(mode, resizeOptions.Mode); |
|
|
|
} |
|
|
|
|
|
|
|
#if SUPPORTS_RUNTIME_INTRINSICS
|
|
|
|
[Fact] |
|
|
|
public void HwIntrinsics_Resize() |
|
|
|
{ |
|
|
|
static void RunTest() |
|
|
|
{ |
|
|
|
using var image = new Image<Rgba32>(50, 50); |
|
|
|
image.Mutate(img => img.Resize(25, 25)); |
|
|
|
|
|
|
|
Assert.Equal(25, image.Width); |
|
|
|
Assert.Equal(25, image.Height); |
|
|
|
} |
|
|
|
|
|
|
|
FeatureTestRunner.RunWithHwIntrinsicsFeature( |
|
|
|
RunTest, |
|
|
|
HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableFMA); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -25,9 +25,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[MemberData(nameof(Intrinsics))] |
|
|
|
public void ToFeatureCollectionReturnsExpectedResult(HwIntrinsics expectedItrinsics, string[] expectedValues) |
|
|
|
public void ToFeatureCollectionReturnsExpectedResult(HwIntrinsics expectedIntrinsics, string[] expectedValues) |
|
|
|
{ |
|
|
|
Dictionary<HwIntrinsics, string> features = expectedItrinsics.ToFeatureKeyValueCollection(); |
|
|
|
Dictionary<HwIntrinsics, string> features = expectedIntrinsics.ToFeatureKeyValueCollection(); |
|
|
|
HwIntrinsics[] keys = features.Keys.ToArray(); |
|
|
|
|
|
|
|
HwIntrinsics actualIntrinsics = keys[0]; |
|
|
|
@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests |
|
|
|
actualIntrinsics |= keys[i]; |
|
|
|
} |
|
|
|
|
|
|
|
Assert.Equal(expectedItrinsics, actualIntrinsics); |
|
|
|
Assert.Equal(expectedIntrinsics, actualIntrinsics); |
|
|
|
|
|
|
|
IEnumerable<string> actualValues = features.Select(x => x.Value); |
|
|
|
Assert.Equal(expectedValues, actualValues); |
|
|
|
|