Skip to content

Commit a7ca1b0

Browse files
committed
Workaround for incorrect codegen on .NET 5
See Vector256.Create issue: dotnet/runtime#47236
1 parent 407c2d9 commit a7ca1b0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Numerics;
66
using System.Runtime.CompilerServices;
77
#if SUPPORTS_RUNTIME_INTRINSICS
8+
using System.Runtime.InteropServices;
89
using System.Runtime.Intrinsics;
910
using System.Runtime.Intrinsics.X86;
1011
#endif
@@ -77,7 +78,14 @@ public Vector4 ConvolveCore(ref Vector4 rowStartRef)
7778
float* bufferEnd = bufferStart + (this.Length & ~3);
7879
Vector256<float> result256_0 = Vector256<float>.Zero;
7980
Vector256<float> result256_1 = Vector256<float>.Zero;
80-
var mask = Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1);
81+
ReadOnlySpan<byte> maskBytes = new byte[]
82+
{
83+
0, 0, 0, 0, 0, 0, 0, 0,
84+
0, 0, 0, 0, 0, 0, 0, 0,
85+
1, 0, 0, 0, 1, 0, 0, 0,
86+
1, 0, 0, 0, 1, 0, 0, 0,
87+
};
88+
Vector256<int> mask = Unsafe.ReadUnaligned<Vector256<int>>(ref MemoryMarshal.GetReference(maskBytes));
8189

8290
while (bufferStart < bufferEnd)
8391
{

0 commit comments

Comments
 (0)