Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: src/core/SkCpu.cpp

Issue 1892643003: Revert of Move CPU feature detection to its own file. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkCpu.h ('k') | src/core/SkOpts.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCpu.cpp
diff --git a/src/core/SkCpu.cpp b/src/core/SkCpu.cpp
deleted file mode 100644
index 4030fce2e1fc6305e4fae37e8c90680e8dc6334d..0000000000000000000000000000000000000000
--- a/src/core/SkCpu.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkCpu.h"
-#include "SkOncePtr.h"
-
-#if defined(SK_CPU_X86)
- #if defined(SK_BUILD_FOR_WIN32)
- #include <intrin.h>
- static void cpuid (uint32_t abcd[4]) { __cpuid ((int*)abcd, 1); }
- static void cpuid7(uint32_t abcd[4]) { __cpuidex((int*)abcd, 7, 0); }
- static uint64_t xgetbv(uint32_t xcr) { return _xgetbv(xcr); }
- #else
- #include <cpuid.h>
- #if !defined(__cpuid_count) // Old Mac Clang doesn't have this defined.
- #define __cpuid_count(eax, ecx, a, b, c, d) \
- __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(eax), "2"(ecx))
- #endif
- static void cpuid (uint32_t abcd[4]) { __get_cpuid(1, abcd+0, abcd+1, abcd+2, abcd+3); }
- static void cpuid7(uint32_t abcd[4]) {
- __cpuid_count(7, 0, abcd[0], abcd[1], abcd[2], abcd[3]);
- }
- static uint64_t xgetbv(uint32_t xcr) {
- uint32_t eax, edx;
- __asm__ __volatile__ ( "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr));
- return (uint64_t)(edx) << 32 | eax;
- }
- #endif
-
- static uint32_t read_cpu_features() {
- uint32_t features = 0;
- uint32_t abcd[4] = {0,0,0,0};
-
- // You might want to refer to http://www.sandpile.org/x86/cpuid.htm
-
- cpuid(abcd);
- if (abcd[3] & (1<<25)) { features |= SkCpu:: SSE1; }
- if (abcd[3] & (1<<26)) { features |= SkCpu:: SSE2; }
- if (abcd[2] & (1<< 0)) { features |= SkCpu:: SSE3; }
- if (abcd[2] & (1<< 9)) { features |= SkCpu::SSSE3; }
- if (abcd[2] & (1<<19)) { features |= SkCpu::SSE41; }
- if (abcd[2] & (1<<20)) { features |= SkCpu::SSE42; }
-
- if ((abcd[2] & (3<<26)) == (3<<26) && (xgetbv(0) & 6) == 6) { // XSAVE + OSXSAVE
- if (abcd[2] & (1<<28)) { features |= SkCpu:: AVX; }
- if (abcd[2] & (1<<29)) { features |= SkCpu::F16C; }
- if (abcd[2] & (1<<12)) { features |= SkCpu:: FMA; }
-
- cpuid7(abcd);
- if (abcd[1] & (1<<5)) { features |= SkCpu::AVX2; }
- }
- return features;
- }
-
-#elif defined(SK_CPU_ARM32) && \
- defined(SK_BUILD_FOR_ANDROID) && \
- !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
- #include <cpu-features.h>
-
- static uint32_t read_cpu_features() {
- uint32_t features = 0;
-
- uint64_t android_features = android_getCpuFeatures();
- if (android_features & ANDROID_CPU_ARM_FEATURE_NEON ) { features |= SkCpu::NEON ; }
- if (android_features & ANDROID_CPU_ARM_FEATURE_NEON_FMA) { features |= SkCpu::NEON_FMA; }
- if (android_features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) { features |= SkCpu::VFP_FP16; }
- return features;
- }
-
-#else
- static uint32_t read_cpu_features() {
- return 0;
- }
-
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
- SK_DECLARE_STATIC_ONCE_PTR(uint32_t, gCachedCpuFeatures);
- uint32_t SkCpu::RuntimeCpuFeatures() {
- return *gCachedCpuFeatures.get([]{ return new uint32_t{read_cpu_features()}; });
- }
-
-#else
- const uint32_t SkCpu::gCachedCpuFeatures = read_cpu_features();
-
-#endif
« no previous file with comments | « src/core/SkCpu.h ('k') | src/core/SkOpts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698