Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkOnce.h" | 8 #include "SkOnce.h" |
| 9 #include "SkOpts.h" | 9 #include "SkOpts.h" |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 | 76 |
| 77 decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_color32; | 77 decltype(blit_row_color32) blit_row_color32 = sk_default::blit_row_color32; |
| 78 | 78 |
| 79 decltype(matrix_translate) matrix_translate = sk_default::matrix _translate; | 79 decltype(matrix_translate) matrix_translate = sk_default::matrix _translate; |
| 80 decltype(matrix_scale_translate) matrix_scale_translate = sk_default::matrix _scale_translate; | 80 decltype(matrix_scale_translate) matrix_scale_translate = sk_default::matrix _scale_translate; |
| 81 decltype(matrix_affine) matrix_affine = sk_default::matrix _affine; | 81 decltype(matrix_affine) matrix_affine = sk_default::matrix _affine; |
| 82 | 82 |
| 83 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. | 83 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. |
| 84 void Init_ssse3(); | 84 void Init_ssse3(); |
| 85 void Init_sse41(); | 85 void Init_sse41(); |
| 86 void Init_neon(); | 86 void Init_sse42() { SkDEBUGCODE( SkDebugf("sse 4.2 detected\n"); ) } |
|
Lei Zhang
2015/11/17 00:11:32
These are a wee bit spammy in debug builds. Every
| |
| 87 void Init_avx() { SkDEBUGCODE( SkDebugf("avx detected\n"); ) } | 87 void Init_avx() { SkDEBUGCODE( SkDebugf("avx detected\n"); ) } |
| 88 void Init_avx2() { SkDEBUGCODE( SkDebugf("avx2 detected\n"); ) } | 88 void Init_avx2() { SkDEBUGCODE( SkDebugf("avx2 detected\n"); ) } |
| 89 void Init_neon(); | |
| 89 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, ... ? | 90 //TODO: _dsp2, _armv7, _armv8, _x86, _x86_64, _sse42, ... ? |
|
Lei Zhang
2015/11/17 00:11:32
Remove sse42 from this list now?
| |
| 90 | 91 |
| 91 static void init() { | 92 static void init() { |
| 92 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? | 93 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? |
| 93 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) | 94 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) |
| 94 uint32_t abcd[] = {0,0,0,0}; | 95 uint32_t abcd[] = {0,0,0,0}; |
| 95 cpuid(abcd); | 96 cpuid(abcd); |
| 96 if (abcd[2] & (1<< 9)) { Init_ssse3(); } | 97 if (abcd[2] & (1<< 9)) { Init_ssse3(); } |
| 97 if (abcd[2] & (1<<19)) { Init_sse41(); } | 98 if (abcd[2] & (1<<19)) { Init_sse41(); } |
| 99 if (abcd[2] & (1<<20)) { Init_sse42(); } | |
| 98 | 100 |
| 99 // AVX detection's kind of a pain. This is cribbed from Chromium. | 101 // AVX detection's kind of a pain. This is cribbed from Chromium. |
| 100 if ( ( abcd[2] & (7<<26)) == (7<<26) && // Check bits 26-28 of ecx a re all set, | 102 if ( ( abcd[2] & (7<<26)) == (7<<26) && // Check bits 26-28 of ecx a re all set, |
| 101 (xgetbv(0) & 6 ) == 6 ){ // and check the OS support s XSAVE. | 103 (xgetbv(0) & 6 ) == 6 ){ // and check the OS support s XSAVE. |
| 102 Init_avx(); | 104 Init_avx(); |
| 103 | 105 |
| 104 // AVX2 additionally needs bit 5 set on ebx after calling cpuid(7). | 106 // AVX2 additionally needs bit 5 set on ebx after calling cpuid(7). |
| 105 uint32_t abcd7[] = {0,0,0,0}; | 107 uint32_t abcd7[] = {0,0,0,0}; |
| 106 cpuid7(abcd7); | 108 cpuid7(abcd7); |
| 107 if (abcd7[1] & (1<<5)) { Init_avx2(); } | 109 if (abcd7[1] & (1<<5)) { Init_avx2(); } |
| 108 } | 110 } |
| 109 | 111 |
| 110 #elif !defined(SK_ARM_HAS_NEON) && \ | 112 #elif !defined(SK_ARM_HAS_NEON) && \ |
| 111 defined(SK_CPU_ARM32) && \ | 113 defined(SK_CPU_ARM32) && \ |
| 112 defined(SK_BUILD_FOR_ANDROID) && \ | 114 defined(SK_BUILD_FOR_ANDROID) && \ |
| 113 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | 115 !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 114 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon (); } | 116 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) { Init_neon (); } |
| 115 #endif | 117 #endif |
| 116 } | 118 } |
| 117 | 119 |
| 118 SK_DECLARE_STATIC_ONCE(gInitOnce); | 120 SK_DECLARE_STATIC_ONCE(gInitOnce); |
| 119 void Init() { SkOnce(&gInitOnce, init); } | 121 void Init() { SkOnce(&gInitOnce, init); } |
| 120 | 122 |
| 121 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 123 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 122 static struct AutoInit { | 124 static struct AutoInit { |
| 123 AutoInit() { Init(); } | 125 AutoInit() { Init(); } |
| 124 } gAutoInit; | 126 } gAutoInit; |
| 125 #endif | 127 #endif |
| 126 } | 128 } |
| OLD | NEW |