Bug 716766 - Enable NEON Skia codepaths r=snorp
authorGeorge Wright <george@mozilla.com>
Fri, 07 Mar 2014 17:27:10 -0500
changeset 193547 db35f443e62e0dc5478c815aa63e9ac033fb7952
parent 193546 c752ec797e82965c5a4257c95d710db7897ee1ee
child 193548 89275f0ae29f3467eb022c62da0c3ea838cf4196
child 193649 cd28787bf3901ec0f1cf4bd3d686f3f137d88634
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs716766
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 716766 - Enable NEON Skia codepaths r=snorp
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -12,16 +12,21 @@ header = """
 
 footer = """
 
 # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
 if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
     SOURCES += [
         'trunk/src/opts/memset.arm.S',
     ]
+    if CONFIG['BUILD_ARM_NEON']:
+        SOURCES += [
+            'trunk/src/opts/memset16_neon.S',
+            'trunk/src/opts/memset32_neon.S',
+        ]
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'gkmedias'
 LOCAL_INCLUDES += [
     'trunk/include/config',
     'trunk/include/core',
     'trunk/include/effects',
@@ -78,16 +83,19 @@ if CONFIG['INTEL_ARCHITECTURE'] and CONF
     SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-msse2']
+elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
+    DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
+    DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
 
 DEFINES['SKIA_IMPLEMENTATION'] = 1
 DEFINES['GR_IMPLEMENTATION'] = 1
 """
 
 import json
 
 platforms = ['linux', 'mac', 'android', 'win']
@@ -140,17 +148,16 @@ def generate_separated_sources(platform_
     'SkImageDecoder_',
     '_gif',
     'SkFontConfigParser_android',
     'SkJpeg',
     'SkXML',
     'SkCity',
     'GrGLCreateNativeInterface',
     'fontconfig',
-    '_neon',
     'SkThreadUtils_pthread_',
     'SkImage_Codec',
     'SkBitmapChecksummer',
     'SkNativeGLContext',
     'SkFontConfig',
     'SkFontHost_win_dw',
     'SkForceLinking',
     'SkMovie',
@@ -200,16 +207,20 @@ def generate_separated_sources(platform_
     'linux': {
       'trunk/src/ports/SkFontHost_cairo.cpp',
     },
     'intel': {
       'trunk/src/opts/SkXfermode_opts_none.cpp',
     },
     'arm': {
       'trunk/src/opts/SkUtils_opts_arm.cpp',
+      'trunk/src/core/SkUtilsArm.cpp',
+    },
+    'neon': {
+      'trunk/src/opts/SkBitmapProcState_arm_neon.cpp',
     },
     'none': {
       'trunk/src/opts/SkUtils_opts_none.cpp',
     }
   }
 
   for plat in platform_sources.keys():
     if not separated.has_key(plat):
@@ -218,17 +229,21 @@ def generate_separated_sources(platform_
     for value in platform_sources[plat]:
       if isblacklisted(value):
         continue
 
       if value.find('_SSE') > 0 or value.find('_SSSE') > 0: #lol
         separated['intel'].add(value)
         continue
 
-      if value.find('_arm') > 0 or value.find('_neon') > 0:
+      if value.find('_neon') > 0:
+        separated['neon'].add(value)
+        continue
+
+      if value.find('_arm') > 0:
         separated['arm'].add(value)
         continue
 
       if value.find('_none') > 0:
         separated['none'].add(value)
         continue
 
       found = True
@@ -247,33 +262,49 @@ def generate_separated_sources(platform_
 
   return separated
 
 def uniq(seq):
   seen = set()
   seen_add = seen.add
   return [ x for x in seq if x not in seen and not seen_add(x)]
 
+def write_cflags(f, values, subsearch, cflag, indent):
+  def write_indent(indent):
+    for _ in range(indent):
+        f.write(' ')
+
+  val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
+
+  if len(val_list) == 0:
+    return
+
+  for val in val_list:
+    if val.find(subsearch) > 0:
+      write_indent(indent)
+      f.write("SOURCES[\'" + val + "\'].flags += [\'" + cflag + "\']\n")
+
+
 def write_list(f, name, values, indent):
   def write_indent(indent):
     for _ in range(indent):
         f.write(' ')
 
   val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
 
   if len(val_list) == 0:
     return
 
   write_indent(indent)
   f.write(name + ' += [\n')
   for val in val_list:
     write_indent(indent + 4)
     f.write('\'' + val + '\',\n')
 
-  write_indent(4)
+  write_indent(indent)
   f.write(']\n')
 
 def write_mozbuild(includes, sources):
   filename = 'moz.build'
   f = open(filename, 'w')
 
   f.write(header)
 
@@ -298,16 +329,20 @@ def write_mozbuild(includes, sources):
 
   f.write("\n\n")
   f.write("if CONFIG['INTEL_ARCHITECTURE']:\n")
   write_list(f, 'SOURCES', sources['intel'], 4)
 
   f.write("elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:\n")
   write_list(f, 'SOURCES', sources['arm'], 4)
 
+  f.write("    if CONFIG['BUILD_ARM_NEON']:\n")
+  write_list(f, 'SOURCES', sources['neon'], 8)
+  write_cflags(f, sources['neon'], 'neon', '-mfpu=neon', 8)
+
   f.write("else:\n")
   write_list(f, 'SOURCES', sources['none'], 4)
 
   f.write(footer)
 
   f.close()
 
   print 'Wrote ' + filename
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -1,8 +1,9 @@
+
 # Please note this file is autogenerated from generate_mozbuild.py, so do not modify it directly
 
 EXPORTS.skia += [
     'trunk/include/animator/SkAnimator.h',
     'trunk/include/animator/SkAnimatorView.h',
     'trunk/include/config/SkUserConfig.h',
     'trunk/include/core/Sk64.h',
     'trunk/include/core/SkAdvancedTypefaceMetrics.h',
@@ -309,17 +310,17 @@ EXPORTS.skia += [
     'trunk/include/xml/SkJS.h',
     'trunk/include/xml/SkXMLParser.h',
     'trunk/include/xml/SkXMLWriter.h',
     'trunk/src/ports/SkAtomics_android.h',
     'trunk/src/ports/SkAtomics_sync.h',
     'trunk/src/ports/SkAtomics_win.h',
     'trunk/src/ports/SkMutex_pthread.h',
     'trunk/src/ports/SkMutex_win.h',
-    ]
+]
 SOURCES += [
     'trunk/src/core/SkAAClip.cpp',
     'trunk/src/core/SkAdvancedTypefaceMetrics.cpp',
     'trunk/src/core/SkAlphaRuns.cpp',
     'trunk/src/core/SkAnnotation.cpp',
     'trunk/src/core/SkBBoxHierarchyRecord.cpp',
     'trunk/src/core/SkBBoxRecord.cpp',
     'trunk/src/core/SkBitmap.cpp',
@@ -689,33 +690,32 @@ SOURCES += [
     'trunk/src/utils/SkParsePath.cpp',
     'trunk/src/utils/SkPathUtils.cpp',
     'trunk/src/utils/SkPictureUtils.cpp',
     'trunk/src/utils/SkProxyCanvas.cpp',
     'trunk/src/utils/SkRTConf.cpp',
     'trunk/src/utils/SkSHA1.cpp',
     'trunk/src/utils/SkThreadPool.cpp',
     'trunk/src/utils/SkUnitMappers.cpp',
-    ]
+]
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
     SOURCES += [
         'trunk/src/images/SkImageRef_ashmem.cpp',
         'trunk/src/ports/SkDebug_android.cpp',
         'trunk/src/ports/SkFontHost_android_old.cpp',
         'trunk/src/ports/SkFontHost_cairo.cpp',
         'trunk/src/ports/SkFontHost_FreeType.cpp',
         'trunk/src/ports/SkFontHost_FreeType_common.cpp',
         'trunk/src/ports/SkOSFile_posix.cpp',
         'trunk/src/ports/SkPurgeableMemoryBlock_android.cpp',
         'trunk/src/ports/SkTime_Unix.cpp',
         'trunk/src/ports/SkTLS_pthread.cpp',
         'trunk/src/utils/android/ashmem.cpp',
         'trunk/src/utils/SkThreadUtils_pthread.cpp',
     ]
-    DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     SOURCES += [
         'trunk/src/ports/SkDebug_stdio.cpp',
         'trunk/src/ports/SkFontHost_mac.cpp',
         'trunk/src/ports/SkOSFile_posix.cpp',
         'trunk/src/ports/SkPurgeableMemoryBlock_mac.cpp',
         'trunk/src/ports/SkTime_Unix.cpp',
         'trunk/src/ports/SkTLS_pthread.cpp',
@@ -772,24 +772,42 @@ if CONFIG['INTEL_ARCHITECTURE']:
         'trunk/src/opts/SkBlitRow_opts_SSE2.cpp',
         'trunk/src/opts/SkBlurImage_opts_SSE2.cpp',
         'trunk/src/opts/SkMorphology_opts_SSE2.cpp',
         'trunk/src/opts/SkUtils_opts_SSE2.cpp',
         'trunk/src/opts/SkXfermode_opts_none.cpp',
     ]
 elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
     SOURCES += [
+        'trunk/src/core/SkUtilsArm.cpp',
         'trunk/src/opts/SkBitmapProcState_opts_arm.cpp',
         'trunk/src/opts/SkBlitMask_opts_arm.cpp',
         'trunk/src/opts/SkBlitRow_opts_arm.cpp',
         'trunk/src/opts/SkBlurImage_opts_arm.cpp',
         'trunk/src/opts/SkMorphology_opts_arm.cpp',
         'trunk/src/opts/SkUtils_opts_arm.cpp',
         'trunk/src/opts/SkXfermode_opts_arm.cpp',
     ]
+    if CONFIG['BUILD_ARM_NEON']:
+        SOURCES += [
+            'trunk/src/opts/SkBitmapProcState_arm_neon.cpp',
+            'trunk/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
+            'trunk/src/opts/SkBlitMask_opts_arm_neon.cpp',
+            'trunk/src/opts/SkBlitRow_opts_arm_neon.cpp',
+            'trunk/src/opts/SkBlurImage_opts_neon.cpp',
+            'trunk/src/opts/SkMorphology_opts_neon.cpp',
+            'trunk/src/opts/SkXfermode_opts_arm_neon.cpp',
+        ]
+        SOURCES['trunk/src/opts/SkBitmapProcState_arm_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkBitmapProcState_matrixProcs_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkBlitMask_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkBlitRow_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkBlurImage_opts_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkMorphology_opts_neon.cpp'].flags += ['-mfpu=neon']
+        SOURCES['trunk/src/opts/SkXfermode_opts_arm_neon.cpp'].flags += ['-mfpu=neon']
 else:
     SOURCES += [
         'trunk/src/opts/SkBitmapProcState_opts_none.cpp',
         'trunk/src/opts/SkBlitMask_opts_none.cpp',
         'trunk/src/opts/SkBlitRow_opts_none.cpp',
         'trunk/src/opts/SkBlurImage_opts_none.cpp',
         'trunk/src/opts/SkMorphology_opts_none.cpp',
         'trunk/src/opts/SkUtils_opts_none.cpp',
@@ -799,16 +817,21 @@ else:
     ]
 
 
 # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
 if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
     SOURCES += [
         'trunk/src/opts/memset.arm.S',
     ]
+    if CONFIG['BUILD_ARM_NEON']:
+        SOURCES += [
+            'trunk/src/opts/memset16_neon.S',
+            'trunk/src/opts/memset32_neon.S',
+        ]
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'gkmedias'
 LOCAL_INCLUDES += [
     'trunk/include/config',
     'trunk/include/core',
     'trunk/include/effects',
@@ -842,27 +865,33 @@ DEFINES['SK_G32_SHIFT'] = 8
 DEFINES['SK_B32_SHIFT'] = 0
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'qt', 'gonk', 'cocoa'):
     DEFINES['SK_USE_POSIX_THREADS'] = 1
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['HAVE_TOOLCHAIN_SUPPORT_MSSSE3']:
     DEFINES['SK_BUILD_SSSE3'] = 1
 
-if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or    (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or    CONFIG['MOZ_WIDGET_GTK'] or    CONFIG['MOZ_WIDGET_QT']:
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'):
+    DEFINES['SK_FONTHOST_CAIRO_STANDALONE'] = 0
+
+if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android') or    (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa') or    (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk') or    CONFIG['MOZ_WIDGET_QT'] or    CONFIG['MOZ_WIDGET_GTK']:
     DEFINES['SK_FONTHOST_DOES_NOT_USE_FONTMGR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     DEFINES['SKIA_DLL'] = 1
     DEFINES['GR_DLL'] = 1
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
     SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-msse2']
     SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-msse2']
+elif CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC'] and CONFIG['BUILD_ARM_NEON']:
+    DEFINES['__ARM_HAVE_OPTIONAL_NEON_SUPPORT'] = 1
+    DEFINES['USE_ANDROID_NDK_CPU_FEATURES'] = 0
 
 DEFINES['SKIA_IMPLEMENTATION'] = 1
 DEFINES['GR_IMPLEMENTATION'] = 1