OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkCpu_DEFINED | 8 #ifndef SkCpu_DEFINED |
9 #define SkCpu_DEFINED | 9 #define SkCpu_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 | 12 |
13 struct SkCpu { | 13 struct SkCpu { |
14 enum { | 14 enum { |
15 SSE1 = 1 << 0, | 15 SSE1 = 1 << 0, |
16 SSE2 = 1 << 1, | 16 SSE2 = 1 << 1, |
17 SSE3 = 1 << 2, | 17 SSE3 = 1 << 2, |
18 SSSE3 = 1 << 3, | 18 SSSE3 = 1 << 3, |
19 SSE41 = 1 << 4, | 19 SSE41 = 1 << 4, |
20 SSE42 = 1 << 5, | 20 SSE42 = 1 << 5, |
21 AVX = 1 << 6, | 21 AVX = 1 << 6, |
22 F16C = 1 << 7, | 22 F16C = 1 << 7, |
23 FMA = 1 << 8, | 23 FMA = 1 << 8, |
24 AVX2 = 1 << 9, | 24 AVX2 = 1 << 9, |
25 }; | 25 }; |
26 enum { | 26 enum { |
27 NEON = 1 << 0, | 27 NEON = 1 << 0, |
28 NEON_FMA = 1 << 1, | 28 NEON_FMA = 1 << 1, |
29 VFP_FP16 = 1 << 2, | 29 VFP_FP16 = 1 << 2, |
| 30 CRC32 = 1 << 3, |
30 }; | 31 }; |
31 | 32 |
32 static void CacheRuntimeFeatures(); | 33 static void CacheRuntimeFeatures(); |
33 static bool Supports(uint32_t); | 34 static bool Supports(uint32_t); |
34 private: | 35 private: |
35 static uint32_t gCachedFeatures; | 36 static uint32_t gCachedFeatures; |
36 }; | 37 }; |
37 | 38 |
38 inline bool SkCpu::Supports(uint32_t mask) { | 39 inline bool SkCpu::Supports(uint32_t mask) { |
39 uint32_t features = gCachedFeatures; | 40 uint32_t features = gCachedFeatures; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 73 |
73 #else | 74 #else |
74 #if defined(SK_ARM_HAS_NEON) | 75 #if defined(SK_ARM_HAS_NEON) |
75 features |= NEON; | 76 features |= NEON; |
76 #endif | 77 #endif |
77 | 78 |
78 #if defined(SK_CPU_ARM64) | 79 #if defined(SK_CPU_ARM64) |
79 features |= NEON|NEON_FMA|VFP_FP16; | 80 features |= NEON|NEON_FMA|VFP_FP16; |
80 #endif | 81 #endif |
81 | 82 |
| 83 #if defined(__ARM_FEATURE_CRC32) |
| 84 features |= CRC32; |
| 85 #endif |
| 86 |
82 #endif | 87 #endif |
83 return (features & mask) == mask; | 88 return (features & mask) == mask; |
84 } | 89 } |
85 | 90 |
86 #endif//SkCpu_DEFINED | 91 #endif//SkCpu_DEFINED |
OLD | NEW |