77using System . Numerics ;
88#if SUPPORTS_RUNTIME_INTRINSICS
99using System . Runtime . Intrinsics . X86 ;
10+ using Aes = System . Runtime . Intrinsics . X86 . Aes ;
11+ #if NET5_0_OR_GREATER
12+ using System . Runtime . Intrinsics . Arm ;
13+ #endif
1014#endif
1115using Xunit ;
1216using Xunit . Abstractions ;
@@ -16,11 +20,11 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
1620 public class FeatureTestRunnerTests
1721 {
1822 public static TheoryData < HwIntrinsics , string [ ] > Intrinsics =>
19- new TheoryData < HwIntrinsics , string [ ] >
23+ new ( )
2024 {
21- { HwIntrinsics . DisableAES | HwIntrinsics . AllowAll , new string [ ] { "EnableAES" , "AllowAll" } } ,
22- { HwIntrinsics . DisableSIMD | HwIntrinsics . DisableHWIntrinsic , new string [ ] { "FeatureSIMD" , "EnableHWIntrinsic" } } ,
23- { HwIntrinsics . DisableSSE42 | HwIntrinsics . DisableAVX , new string [ ] { "EnableSSE42" , "EnableAVX" } }
25+ { HwIntrinsics . DisableAES | HwIntrinsics . AllowAll , new [ ] { "EnableAES" , "AllowAll" } } ,
26+ { HwIntrinsics . DisableSIMD | HwIntrinsics . DisableHWIntrinsic , new [ ] { "FeatureSIMD" , "EnableHWIntrinsic" } } ,
27+ { HwIntrinsics . DisableSSE42 | HwIntrinsics . DisableAVX , new [ ] { "EnableSSE42" , "EnableAVX" } }
2428 } ;
2529
2630 [ Theory ]
@@ -56,12 +60,9 @@ public void AllowsAllHwIntrinsicFeatures()
5660 }
5761
5862 [ Fact ]
59- public void CanLimitHwIntrinsicSIMDFeatures ( )
60- {
61- FeatureTestRunner . RunWithHwIntrinsicsFeature (
63+ public void CanLimitHwIntrinsicSIMDFeatures ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature (
6264 ( ) => Assert . False ( Vector . IsHardwareAccelerated ) ,
6365 HwIntrinsics . DisableSIMD ) ;
64- }
6566
6667#if SUPPORTS_RUNTIME_INTRINSICS
6768 [ Fact ]
@@ -121,6 +122,14 @@ static void AssertHwIntrinsicsFeatureDisabled(string intrinsic)
121122 Assert . False ( Bmi1 . IsSupported ) ;
122123 Assert . False ( Bmi2 . IsSupported ) ;
123124 Assert . False ( Lzcnt . IsSupported ) ;
125+ #if NET5_0_OR_GREATER
126+ Assert . False ( AdvSimd . IsSupported ) ;
127+ Assert . False ( System . Runtime . Intrinsics . Arm . Aes . IsSupported ) ;
128+ Assert . False ( Crc32 . IsSupported ) ;
129+ Assert . False ( Dp . IsSupported ) ;
130+ Assert . False ( Sha1 . IsSupported ) ;
131+ Assert . False ( Sha256 . IsSupported ) ;
132+ #endif
124133 break ;
125134 case HwIntrinsics . DisableSSE:
126135 Assert. False( Sse . IsSupported ) ;
@@ -167,6 +176,26 @@ static void AssertHwIntrinsicsFeatureDisabled(string intrinsic)
167176 case HwIntrinsics . DisableLZCNT:
168177 Assert. False( Lzcnt . IsSupported ) ;
169178 break ;
179+ #if NET5_0_OR_GREATER
180+ case HwIntrinsics . DisableArm64AdvSimd:
181+ Assert. False( AdvSimd . IsSupported ) ;
182+ break ;
183+ case HwIntrinsics . DisableArm64Aes:
184+ Assert. False( System . Runtime . Intrinsics . Arm . Aes . IsSupported ) ;
185+ break ;
186+ case HwIntrinsics . DisableArm64Crc32:
187+ Assert. False( Crc32 . IsSupported ) ;
188+ break ;
189+ case HwIntrinsics . DisableArm64Dp:
190+ Assert. False( Dp . IsSupported ) ;
191+ break ;
192+ case HwIntrinsics . DisableArm64Sha1:
193+ Assert. False( Sha1 . IsSupported ) ;
194+ break ;
195+ case HwIntrinsics . DisableArm64Sha256:
196+ Assert. False( Sha256 . IsSupported ) ;
197+ break ;
198+ #endif
170199#endif
171200 }
172201 }
@@ -226,6 +255,14 @@ static void AssertHwIntrinsicsFeatureDisabled(string serializable, string intrin
226255 Assert . False ( Bmi1 . IsSupported ) ;
227256 Assert . False ( Bmi2 . IsSupported ) ;
228257 Assert . False ( Lzcnt . IsSupported ) ;
258+ #if NET5_0_OR_GREATER
259+ Assert . False ( AdvSimd . IsSupported ) ;
260+ Assert . False ( System . Runtime . Intrinsics . Arm . Aes . IsSupported ) ;
261+ Assert . False ( Crc32 . IsSupported ) ;
262+ Assert . False ( Dp . IsSupported ) ;
263+ Assert . False ( Sha1 . IsSupported ) ;
264+ Assert . False ( Sha256 . IsSupported ) ;
265+ #endif
229266 break ;
230267 case HwIntrinsics . DisableSSE:
231268 Assert. False( Sse . IsSupported ) ;
@@ -272,6 +309,26 @@ static void AssertHwIntrinsicsFeatureDisabled(string serializable, string intrin
272309 case HwIntrinsics . DisableLZCNT:
273310 Assert. False( Lzcnt . IsSupported ) ;
274311 break ;
312+ #if NET5_0_OR_GREATER
313+ case HwIntrinsics . DisableArm64AdvSimd:
314+ Assert. False( AdvSimd . IsSupported ) ;
315+ break ;
316+ case HwIntrinsics . DisableArm64Aes:
317+ Assert. False( System . Runtime . Intrinsics . Arm . Aes . IsSupported ) ;
318+ break ;
319+ case HwIntrinsics . DisableArm64Crc32:
320+ Assert. False( Crc32 . IsSupported ) ;
321+ break ;
322+ case HwIntrinsics . DisableArm64Dp:
323+ Assert. False( Dp . IsSupported ) ;
324+ break ;
325+ case HwIntrinsics . DisableArm64Sha1:
326+ Assert. False( Sha1 . IsSupported ) ;
327+ break ;
328+ case HwIntrinsics . DisableArm64Sha256:
329+ Assert. False( Sha256 . IsSupported ) ;
330+ break ;
331+ #endif
275332#endif
276333 }
277334 }
0 commit comments