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 |
(...skipping 14 matching lines...) Expand all Loading... |
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 }; | 30 }; |
31 | 31 |
32 static void CacheRuntimeFeatures(); | 32 static void CacheRuntimeFeatures(); |
33 static bool Supports(uint32_t); | 33 static bool Supports(uint32_t); |
34 private: | 34 private: |
35 #if defined(_MSC_VER) || !defined(SkCpu_IMPL) | 35 static uint32_t gCachedFeatures; |
36 static const uint32_t gCachedFeatures; | |
37 #else | |
38 static uint32_t gCachedFeatures; | |
39 #endif | |
40 }; | 36 }; |
41 | 37 |
42 inline bool SkCpu::Supports(uint32_t mask) { | 38 inline bool SkCpu::Supports(uint32_t mask) { |
43 uint32_t features = gCachedFeatures; | 39 uint32_t features = gCachedFeatures; |
44 | 40 |
45 // If we mask in compile-time known lower limits, the compiler can | 41 // If we mask in compile-time known lower limits, the compiler can |
46 // often compile away this entire function. | 42 // often compile away this entire function. |
47 #if SK_CPU_X86 | 43 #if SK_CPU_X86 |
48 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1 | 44 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1 |
49 features |= SSE1; | 45 features |= SSE1; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 77 |
82 #if defined(SK_CPU_ARM64) | 78 #if defined(SK_CPU_ARM64) |
83 features |= NEON|NEON_FMA|VFP_FP16; | 79 features |= NEON|NEON_FMA|VFP_FP16; |
84 #endif | 80 #endif |
85 | 81 |
86 #endif | 82 #endif |
87 return (features & mask) == mask; | 83 return (features & mask) == mask; |
88 } | 84 } |
89 | 85 |
90 #endif//SkCpu_DEFINED | 86 #endif//SkCpu_DEFINED |
OLD | NEW |