Commit 83074c1c authored by Kévin PETIT's avatar Kévin PETIT Committed by Commit Bot

Accelerate convolution functions using NEON

Adds Arm NEON versions of convolve_4_rows_horizontally,
convolve_horizontally and convolve_vertically.

This NEON convolution code was originally added here: [1]. Then, at the
introduction of GPU raster, the code (then in SkBitmapFilter_opts.h) was
removed [2].

The re-introduction of this code gives a significant performance boost
to Arm platforms which do not have GPU raster enabled - currently all
Arm Chromebooks and old Android devices.

Similar SIMD-accelerated convolution code exists in src/skia/ext for
Intel and MIPS platforms which do not have GPU raster enabled. This
commit simply adds an Arm NEON counterpart.

[1] https://codereview.chromium.org/27533004
[2] https://skia-review.googlesource.com/c/skia/+/24644

Change-Id: Ied7d65c0f1e2fd3cb54dee3ff70dcccb8eafcb8a
Reviewed-on: https://chromium-review.googlesource.com/911789
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: default avatarMike Klein <mtklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539143}
parent 73c0ec5a
......@@ -281,6 +281,11 @@ component("skia") {
"ext/convolver_mips_dspr2.cc",
"ext/convolver_mips_dspr2.h",
]
} else if (current_cpu == "arm" || current_cpu == "arm64") {
sources += [
"ext/convolver_neon.cc",
"ext/convolver_neon.h",
]
}
# The imported Skia gni source paths are made absolute by gn.
......
......@@ -8,6 +8,7 @@
#include "skia/ext/convolver.h"
#include "skia/ext/convolver_SSE2.h"
#include "skia/ext/convolver_mips_dspr2.h"
#include "skia/ext/convolver_neon.h"
#include "third_party/skia/include/core/SkSize.h"
#include "third_party/skia/include/core/SkTypes.h"
......@@ -369,6 +370,11 @@ void SetupSIMD(ConvolveProcs *procs) {
procs->extra_horizontal_reads = 3;
procs->convolve_vertically = &ConvolveVertically_mips_dspr2;
procs->convolve_horizontally = &ConvolveHorizontally_mips_dspr2;
#elif defined SIMD_NEON
procs->extra_horizontal_reads = 3;
procs->convolve_vertically = &ConvolveVertically_Neon;
procs->convolve_4rows_horizontally = &Convolve4RowsHorizontally_Neon;
procs->convolve_horizontally = &ConvolveHorizontally_Neon;
#endif
}
......
......@@ -25,6 +25,12 @@
defined(__mips_dsp) && (__mips_dsp_rev >= 2)
#define SIMD_MIPS_DSPR2 1
#endif
#if defined(ARCH_CPU_ARM_FAMILY) && \
(defined(__ARM_NEON__) || defined(__ARM_NEON))
#define SIMD_NEON 1
#endif
// avoid confusion with Mac OS X's math library (Carbon)
#if defined(__APPLE__)
#undef FloatToFixed
......
This diff is collapsed.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKIA_EXT_CONVOLVER_NEON_H_
#define SKIA_EXT_CONVOLVER_NEON_H_
#include "skia/ext/convolver.h"
namespace skia {
void ConvolveHorizontally_Neon(const unsigned char* src_data,
const ConvolutionFilter1D& filter,
unsigned char* out_row,
bool has_alpha);
void Convolve4RowsHorizontally_Neon(const unsigned char* src_data[4],
const ConvolutionFilter1D& filter,
unsigned char* out_row[4]);
void ConvolveVertically_Neon(const ConvolutionFilter1D::Fixed* filter_values,
int filter_length,
unsigned char* const* source_data_rows,
int pixel_width,
unsigned char* out_row,
bool has_alpha);
} // namespace skia
#endif // SKIA_EXT_CONVOLVER_NEON_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment