Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Vector4 Convolve(Span<Vector4> rowSpan)
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);
Expand Down
21 changes: 21 additions & 0 deletions tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -85,5 +87,24 @@ public void ResizeWithOptions()
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! ❤️

}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class FeatureTestRunnerTests

[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];
Expand All @@ -36,7 +36,7 @@ public void ToFeatureCollectionReturnsExpectedResult(HwIntrinsics expectedItrins
actualIntrinsics |= keys[i];
}

Assert.Equal(expectedItrinsics, actualIntrinsics);
Assert.Equal(expectedIntrinsics, actualIntrinsics);

IEnumerable<string> actualValues = features.Select(x => x.Value);
Assert.Equal(expectedValues, actualValues);
Expand Down