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 #include "SkCpu.h" | 8 #include "SkCpu.h" |
9 #include "SkOnce.h" | 9 #include "SkOnce.h" |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 cpuid7(abcd); | 53 cpuid7(abcd); |
54 if (abcd[1] & (1<<5)) { features |= SkCpu::AVX2; } | 54 if (abcd[1] & (1<<5)) { features |= SkCpu::AVX2; } |
55 } | 55 } |
56 return features; | 56 return features; |
57 } | 57 } |
58 | 58 |
59 #elif defined(SK_CPU_ARM32) && \ | 59 #elif defined(SK_CPU_ARM32) && \ |
60 defined(SK_BUILD_FOR_ANDROID) && \ | 60 defined(SK_BUILD_FOR_ANDROID) && \ |
61 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 61 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
62 #include <cpu-features.h> | 62 #include "cpu-features.h" |
63 | 63 |
64 static uint32_t read_cpu_features() { | 64 static uint32_t read_cpu_features() { |
65 uint32_t features = 0; | 65 uint32_t features = 0; |
66 | 66 |
67 uint64_t android_features = android_getCpuFeatures(); | 67 uint64_t android_features = android_getCpuFeatures(); |
68 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON ) { features |= S
kCpu::NEON ; } | 68 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON ) { features |= S
kCpu::NEON ; } |
69 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON_FMA) { features |= S
kCpu::NEON_FMA; } | 69 if (android_features & ANDROID_CPU_ARM_FEATURE_NEON_FMA) { features |= S
kCpu::NEON_FMA; } |
70 if (android_features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) { features |= S
kCpu::VFP_FP16; } | 70 if (android_features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) { features |= S
kCpu::VFP_FP16; } |
71 return features; | 71 return features; |
72 } | 72 } |
73 | 73 |
74 #elif defined(SK_CPU_ARM64) && \ | 74 #elif defined(SK_CPU_ARM64) && \ |
75 defined(SK_BUILD_FOR_ANDROID) && \ | 75 defined(SK_BUILD_FOR_ANDROID) && \ |
76 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 76 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
77 #include <cpu-features.h> | 77 #include "cpu-features.h" |
78 | 78 |
79 static uint32_t read_cpu_features() { | 79 static uint32_t read_cpu_features() { |
80 uint32_t features = 0; | 80 uint32_t features = 0; |
81 | 81 |
82 uint64_t android_features = android_getCpuFeatures(); | 82 uint64_t android_features = android_getCpuFeatures(); |
83 if (android_features & ANDROID_CPU_ARM64_FEATURE_CRC32) { features |= Sk
Cpu::CRC32; } | 83 if (android_features & ANDROID_CPU_ARM64_FEATURE_CRC32) { features |= Sk
Cpu::CRC32; } |
84 return features; | 84 return features; |
85 } | 85 } |
86 | 86 |
87 #else | 87 #else |
88 static uint32_t read_cpu_features() { | 88 static uint32_t read_cpu_features() { |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 #endif | 92 #endif |
93 | 93 |
94 uint32_t SkCpu::gCachedFeatures = 0; | 94 uint32_t SkCpu::gCachedFeatures = 0; |
95 | 95 |
96 void SkCpu::CacheRuntimeFeatures() { | 96 void SkCpu::CacheRuntimeFeatures() { |
97 static SkOnce once; | 97 static SkOnce once; |
98 once([] { gCachedFeatures = read_cpu_features(); }); | 98 once([] { gCachedFeatures = read_cpu_features(); }); |
99 } | 99 } |
OLD | NEW |