From: sdefresne Date: Wed, 1 Jun 2016 14:08:56 +0000 (-0700) Subject: [GN] Add support for disabling opts via SK_BUILD_NO_OPTS define. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~129^2~351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3fa811657ecf4ab694d026752a81080c6b10611;p=platform%2Fupstream%2FlibSkiaSharp.git [GN] Add support for disabling opts via SK_BUILD_NO_OPTS define. 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 --- diff --git a/bench/SkBlend_optsBench.cpp b/bench/SkBlend_optsBench.cpp index 08c3d7f..29f3ed8 100644 --- a/bench/SkBlend_optsBench.cpp +++ b/bench/SkBlend_optsBench.cpp @@ -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(fileName); ) \ DEF_BENCH( return new LinearSrcOverBench(fileName); ) \ diff --git a/experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig b/experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig index eafd949..3833c6f 100644 --- a/experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig +++ b/experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig @@ -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 diff --git a/experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig b/experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig index 1720318..711e0e6 100644 --- a/experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig +++ b/experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig @@ -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 diff --git a/experimental/iOSSampleApp/iOSSampleApp.xcodeproj/project.pbxproj b/experimental/iOSSampleApp/iOSSampleApp.xcodeproj/project.pbxproj index b0016f8..bbb8482 100755 --- a/experimental/iOSSampleApp/iOSSampleApp.xcodeproj/project.pbxproj +++ b/experimental/iOSSampleApp/iOSSampleApp.xcodeproj/project.pbxproj @@ -3428,6 +3428,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( SK_BUILD_FOR_IOS, + SK_BUILD_NO_OPTS, SK_DEBUG, ); GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -3449,6 +3450,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( SK_RELEASE, SK_BUILD_FOR_IOS, + SK_BUILD_NO_OPTS, ); GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = NO; diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi index 21f4c92..4f387e9 100644 --- a/gyp/common_conditions.gypi +++ b/gyp/common_conditions.gypi @@ -562,7 +562,12 @@ [ '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', { diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h index b9b46c0..928c1bd 100644 --- a/include/core/SkPreConfig.h +++ b/include/core/SkPreConfig.h @@ -118,8 +118,12 @@ #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? @@ -190,14 +194,12 @@ #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 diff --git a/public.bzl b/public.bzl index 4cd2145..f84abc0 100644 --- a/public.bzl +++ b/public.bzl @@ -569,6 +569,7 @@ DEFINES_ANDROID = [ DEFINES_IOS = [ "SK_BUILD_FOR_IOS", + "SK_BUILD_NO_OPTS", "SK_IGNORE_ETC1_SUPPORT", "SKNX_NO_SIMD", ] diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp index c6ff43b..6d3e6c9 100644 --- a/src/core/SkOpts.cpp +++ b/src/core/SkOpts.cpp @@ -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(); } diff --git a/tests/SkBlend_optsTest.cpp b/tests/SkBlend_optsTest.cpp index 06b7c1a..9142f9d 100644 --- a/tests/SkBlend_optsTest.cpp +++ b/tests/SkBlend_optsTest.cpp @@ -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", }); }