[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 08c3d7fd4b870536ca2c0eae16f645d8ff0bc94e..29f3ed8331f4d835d46a6143f99e7481fe5f9fa5 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 eafd949235a18f7b3e2ac637fc765a7868c5df1c..3833c6f2e14901d2d5fd72d7470b30f7a9aa011b 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 1720318823ab81380af00b793c720bd3e62b9fcf..711e0e64ba0d0498ce1d7b42218fcc9237111d43 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 b0016f8ad980e2090af1f7dd690baf8fea066feb..bbb84822d3b553b643393f3612b36a15c93d0b5d 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 21f4c92398a10e35ef8aa5ee0bdd9875ac39e73c..4f387e988380c165e62e08706474f4e08c29688d 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 b9b46c073a85736d739cb8ed4bf380789130c97f..928c1bda639379df2846aa10a7eb02110bfa734d 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 4cd21454d59e03445281c198720f6c5f16b68552..f84abc0e6c9abca39049585ac77661f1fadd3d2c 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 c6ff43b532dcf015b868a92ac870dfd6b7995a26..6d3e6c9feac4073b68b47d4dd8ac1c475fbb7b81 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 06b7c1ade2c252d02387882deab7041cda9264c9..9142f9d7a1b96c1a0c44e9675cc960ded43b2449 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", });
     }