|
|
|
@ -37,7 +37,7 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
/// <summary>
|
|
|
|
/// Gets a value indicating whether vectorization is supported.
|
|
|
|
/// </summary>
|
|
|
|
public static bool SupportsVectorization |
|
|
|
public static bool IsHardwareAccelerated |
|
|
|
{ |
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
get => Vector256.IsHardwareAccelerated; |
|
|
|
@ -92,7 +92,7 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
[MethodImpl(InliningOptions.ShortMethod)] |
|
|
|
public Vector4 ConvolveCore(ref Vector4 rowStartRef) |
|
|
|
{ |
|
|
|
if (SupportsVectorization) |
|
|
|
if (IsHardwareAccelerated) |
|
|
|
{ |
|
|
|
if (Vector512.IsHardwareAccelerated) |
|
|
|
{ |
|
|
|
@ -106,8 +106,8 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
Vector512<float> pixels512_0 = Unsafe.As<Vector4, Vector512<float>>(ref rowStartRef); |
|
|
|
Vector512<float> pixels512_1 = Unsafe.As<Vector4, Vector512<float>>(ref Unsafe.Add(ref rowStartRef, (nuint)4)); |
|
|
|
|
|
|
|
result512_0 = Vector512Utilities.MultiplyAddEstimate(Vector512.Load(bufferStart), pixels512_0, result512_0); |
|
|
|
result512_1 = Vector512Utilities.MultiplyAddEstimate(Vector512.Load(bufferStart + 16), pixels512_1, result512_1); |
|
|
|
result512_0 = Vector512_.MultiplyAdd(result512_0, Vector512.Load(bufferStart), pixels512_0); |
|
|
|
result512_1 = Vector512_.MultiplyAdd(result512_1, Vector512.Load(bufferStart + 16), pixels512_1); |
|
|
|
|
|
|
|
bufferStart += 32; |
|
|
|
rowStartRef = ref Unsafe.Add(ref rowStartRef, (nuint)8); |
|
|
|
@ -118,7 +118,7 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
if ((this.Length & 7) >= 4) |
|
|
|
{ |
|
|
|
Vector512<float> pixels512_0 = Unsafe.As<Vector4, Vector512<float>>(ref rowStartRef); |
|
|
|
result512_0 = Vector512Utilities.MultiplyAddEstimate(Vector512.Load(bufferStart), pixels512_0, result512_0); |
|
|
|
result512_0 = Vector512_.MultiplyAdd(result512_0, Vector512.Load(bufferStart), pixels512_0); |
|
|
|
|
|
|
|
bufferStart += 16; |
|
|
|
rowStartRef = ref Unsafe.Add(ref rowStartRef, (nuint)4); |
|
|
|
@ -129,7 +129,7 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
if ((this.Length & 3) >= 2) |
|
|
|
{ |
|
|
|
Vector256<float> pixels256_0 = Unsafe.As<Vector4, Vector256<float>>(ref rowStartRef); |
|
|
|
result256 = Vector256Utilities.MultiplyAddEstimate(Vector256.Load(bufferStart), pixels256_0, result256); |
|
|
|
result256 = Vector256_.MultiplyAdd(result256, Vector256.Load(bufferStart), pixels256_0); |
|
|
|
|
|
|
|
bufferStart += 8; |
|
|
|
rowStartRef = ref Unsafe.Add(ref rowStartRef, (nuint)2); |
|
|
|
@ -140,10 +140,10 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
if ((this.Length & 1) != 0) |
|
|
|
{ |
|
|
|
Vector128<float> pixels128 = Unsafe.As<Vector4, Vector128<float>>(ref rowStartRef); |
|
|
|
result128 = Vector128Utilities.MultiplyAddEstimate(Vector128.Load(bufferStart), pixels128, result128); |
|
|
|
result128 = Vector128_.MultiplyAdd(result128, Vector128.Load(bufferStart), pixels128); |
|
|
|
} |
|
|
|
|
|
|
|
return *(Vector4*)&result128; |
|
|
|
return result128.AsVector4(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
@ -157,8 +157,8 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
Vector256<float> pixels256_0 = Unsafe.As<Vector4, Vector256<float>>(ref rowStartRef); |
|
|
|
Vector256<float> pixels256_1 = Unsafe.As<Vector4, Vector256<float>>(ref Unsafe.Add(ref rowStartRef, (nuint)2)); |
|
|
|
|
|
|
|
result256_0 = Vector256Utilities.MultiplyAddEstimate(Vector256.Load(bufferStart), pixels256_0, result256_0); |
|
|
|
result256_1 = Vector256Utilities.MultiplyAddEstimate(Vector256.Load(bufferStart + 8), pixels256_1, result256_1); |
|
|
|
result256_0 = Vector256_.MultiplyAdd(result256_0, Vector256.Load(bufferStart), pixels256_0); |
|
|
|
result256_1 = Vector256_.MultiplyAdd(result256_1, Vector256.Load(bufferStart + 8), pixels256_1); |
|
|
|
|
|
|
|
bufferStart += 16; |
|
|
|
rowStartRef = ref Unsafe.Add(ref rowStartRef, (nuint)4); |
|
|
|
@ -169,7 +169,7 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
if ((this.Length & 3) >= 2) |
|
|
|
{ |
|
|
|
Vector256<float> pixels256_0 = Unsafe.As<Vector4, Vector256<float>>(ref rowStartRef); |
|
|
|
result256_0 = Vector256Utilities.MultiplyAddEstimate(Vector256.Load(bufferStart), pixels256_0, result256_0); |
|
|
|
result256_0 = Vector256_.MultiplyAdd(result256_0, Vector256.Load(bufferStart), pixels256_0); |
|
|
|
|
|
|
|
bufferStart += 8; |
|
|
|
rowStartRef = ref Unsafe.Add(ref rowStartRef, (nuint)2); |
|
|
|
@ -180,10 +180,10 @@ internal readonly unsafe struct ResizeKernel |
|
|
|
if ((this.Length & 1) != 0) |
|
|
|
{ |
|
|
|
Vector128<float> pixels128 = Unsafe.As<Vector4, Vector128<float>>(ref rowStartRef); |
|
|
|
result128 = Vector128Utilities.MultiplyAddEstimate(Vector128.Load(bufferStart), pixels128, result128); |
|
|
|
result128 = Vector128_.MultiplyAdd(result128, Vector128.Load(bufferStart), pixels128); |
|
|
|
} |
|
|
|
|
|
|
|
return *(Vector4*)&result128; |
|
|
|
return result128.AsVector4(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|