[GN] Add support for disabling opts via SK_BUILD_NO_OPTS define.
authorsdefresne <sdefresne@chromium.org>
Wed, 1 Jun 2016 14:08:56 +0000 (07:08 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 1 Jun 2016 14:08:56 +0000 (07:08 -0700)
When targetting iOS and using gyp to generate the build files, it is not
possible to select files to build depending on the architecture. Due to
that, the skia code was disabling all optimisation when SK_BUILD_FOR_IOS
was defined.

Since it is possible to select the correct optimised version when using
gn, this pessimisation is hurting the build. Introduce a new define to
disable the optimisation SK_BUILD_NO_OPTS. It will be used by Chromium
when building skia for iOS with gyp but not gn.

Define SK_BUILD_NO_OPTS along-side SK_BUILD_FOR_IOS for all files that
look like build configuration (Xcode projects, gyp configuration files,
public.bzl) in order to avoid introducing breakage on those builds.

BUG=607933
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2002423002

Review-Url: https://codereview.chromium.org/2002423002

bench/SkBlend_optsBench.cpp
experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig
experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig
experimental/iOSSampleApp/iOSSampleApp.xcodeproj/project.pbxproj
gyp/common_conditions.gypi
include/core/SkPreConfig.h
public.bzl
src/core/SkOpts.cpp
tests/SkBlend_optsTest.cpp

index 08c3d7f..29f3ed8 100644 (file)
@@ -151,7 +151,7 @@ private:
     typedef Benchmark INHERITED;
 };
 
-#if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
+#if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
 #define BENCHES(fileName)                                                        \
 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsBruteForce>(fileName); )  \
 DEF_BENCH( return new LinearSrcOverBench<SrcOverVSkOptsTrivial>(fileName); )     \
index eafd949..3833c6f 100644 (file)
@@ -9,5 +9,5 @@
 //
 #include "SkiOSSampleApp-Base"
 
-GCC_PREPROCESSOR_DEFINITIONS=SK_DEBUG SK_BUILD_FOR_IOS
+GCC_PREPROCESSOR_DEFINITIONS=SK_DEBUG SK_BUILD_FOR_IOS SK_BUILD_NO_OPTS
 GCC_OPTIMIZATION_LEVEL=0
index 1720318..711e0e6 100644 (file)
@@ -8,5 +8,5 @@
 //  found in the LICENSE file.
 //
 #include "SkiOSSampleApp-Base"
-GCC_PREPROCESSOR_DEFINITIONS=SK_RELEASE SK_BUILD_FOR_IOS
+GCC_PREPROCESSOR_DEFINITIONS=SK_RELEASE SK_BUILD_FOR_IOS SK_BUILD_NO_OPTS
 GCC_OPTIMIZATION_LEVEL=s
index b0016f8..bbb8482 100755 (executable)
                                GCC_OPTIMIZATION_LEVEL = 0;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        SK_BUILD_FOR_IOS,
+                                       SK_BUILD_NO_OPTS,
                                        SK_DEBUG,
                                );
                                GCC_WARN_ABOUT_RETURN_TYPE = YES;
                                GCC_PREPROCESSOR_DEFINITIONS = (
                                        SK_RELEASE,
                                        SK_BUILD_FOR_IOS,
+                                       SK_BUILD_NO_OPTS,
                                );
                                GCC_WARN_ABOUT_RETURN_TYPE = YES;
                                GCC_WARN_UNUSED_VARIABLE = NO;
index 21f4c92..4f387e9 100644 (file)
     [ 'skia_os == "ios"',
       {
         'defines': [
+          # When targetting iOS and using gyp to generate the build files, it is
+          # not possible to select files to build depending on the architecture
+          # (i.e. it is not possible to use hand optimized assembly version). In
+          # that configuration, disable all optimisation.
           'SK_BUILD_FOR_IOS',
+          'SK_BUILD_NO_OPTS',
         ],
         'conditions' : [
           [ 'skia_warnings_as_errors', {
index b9b46c0..928c1bd 100644 (file)
 #define SK_CPU_SSE_LEVEL_AVX      51
 #define SK_CPU_SSE_LEVEL_AVX2     52
 
-#ifdef SK_BUILD_FOR_IOS
-    #define SK_CPU_SSE_LEVEL 0  // We're tired of fighting with opts/ and iOS simulator.
+// When targetting iOS and using gyp to generate the build files, it is not
+// possible to select files to build depending on the architecture (i.e. it
+// is not possible to use hand optimized assembly implementation). In that
+// configuration SK_BUILD_NO_OPTS is defined. Remove optimisation then.
+#ifdef SK_BUILD_NO_OPTS
+    #define SK_CPU_SSE_LEVEL 0
 #endif
 
 // Are we in GCC?
     #endif
 #endif
 
-// Disable ARM64 optimizations for iOS due to complications regarding gyp and iOS.
-#if defined(__aarch64__) && !defined(SK_BUILD_FOR_IOS)
+#if defined(__aarch64__) && !defined(SK_BUILD_NO_OPTS)
     #define SK_CPU_ARM64
 #endif
 
 // All 64-bit ARM chips have NEON.  Many 32-bit ARM chips do too.
-// TODO: Why don't we want NEON on iOS?
-#if !defined(SK_ARM_HAS_NEON) && !defined(SK_BUILD_FOR_IOS) && (defined(__ARM_NEON__) || defined(__ARM_NEON))
+#if !defined(SK_ARM_HAS_NEON) && !defined(SK_BUILD_NO_OPTS) && (defined(__ARM_NEON__) || defined(__ARM_NEON))
     #define SK_ARM_HAS_NEON
 #endif
 
index 4cd2145..f84abc0 100644 (file)
@@ -569,6 +569,7 @@ DEFINES_ANDROID = [
 
 DEFINES_IOS = [
     "SK_BUILD_FOR_IOS",
+    "SK_BUILD_NO_OPTS",
     "SK_IGNORE_ETC1_SUPPORT",
     "SKNX_NO_SIMD",
 ]
index c6ff43b..6d3e6c9 100644 (file)
@@ -84,8 +84,7 @@ namespace SkOpts {
     void Init_avx2() {}
 
     static void init() {
-        // TODO: Chrome's not linking _sse* opts on iOS simulator builds.  Bug or feature?
-    #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
+    #if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
         if (SkCpu::Supports(SkCpu::SSSE3)) { Init_ssse3(); }
         if (SkCpu::Supports(SkCpu::SSE41)) { Init_sse41(); }
         if (SkCpu::Supports(SkCpu::SSE42)) { Init_sse42(); }
index 06b7c1a..9142f9d 100644 (file)
@@ -35,7 +35,7 @@ extern void srcover_srgb_srgb(
     uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
 }
 
-#if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
+#if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
 namespace sk_sse41 {
 extern void srcover_srgb_srgb(
     uint32_t* dst, const uint32_t* const srcStart, int ndst, const int nsrc);
@@ -104,7 +104,7 @@ DEF_TEST(SkBlend_optsCheck, reporter) {
         Spec{sk_default::best_non_simd_srcover_srgb_srgb, "best_non_simd"},
         Spec{sk_default::srcover_srgb_srgb,               "default"},
     };
-    #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
+    #if defined(SK_CPU_X86) && !defined(SK_BUILD_NO_OPTS)
     if (SkCpu::Supports(SkCpu::SSE41)) {
         specs.push_back(Spec{sk_sse41::srcover_srgb_srgb, "sse41", });
     }