finish new-style opts
Nothing super interesting.
SkOpts_crc32.cpp is worth looking at
as the only non-x86 code.
I marked a few places I think we can
trim to save code size as follow ups.
Change-Id: Ifdc8f4d1495ff56df5d2cdde39f7e9a6ac2b1277
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294019
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
diff --git a/gn/core.gni b/gn/core.gni
index e4d26bb..cf65c77 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -272,15 +272,13 @@
"$_src/core/SkOSFile.h",
"$_src/core/SkOpts.cpp",
"$_src/core/SkOpts.h",
-
- #"$_src/core/SkOpts_avx.cpp",
- #"$_src/core/SkOpts_crc32.cpp",
+ "$_src/core/SkOpts_avx.cpp",
+ "$_src/core/SkOpts_crc32.cpp",
"$_src/core/SkOpts_hsw.cpp",
"$_src/core/SkOpts_skx.cpp",
-
- #"$_src/core/SkOpts_sse41.cpp",
- #"$_src/core/SkOpts_sse42.cpp",
- #"$_src/core/SkOpts_ssse3.cpp",
+ "$_src/core/SkOpts_sse41.cpp",
+ "$_src/core/SkOpts_sse42.cpp",
+ "$_src/core/SkOpts_ssse3.cpp",
"$_src/core/SkOrderedReadBuffer.h",
"$_src/core/SkOverdrawCanvas.cpp",
"$_src/core/SkPaint.cpp",
diff --git a/src/core/SkOpts_avx.cpp b/src/core/SkOpts_avx.cpp
new file mode 100644
index 0000000..14283cb
--- /dev/null
+++ b/src/core/SkOpts_avx.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkOpts.h"
+
+#if defined(SK_CPU_X86)
+
+ // Turn on AVX feature set.
+ #if defined(__clang__)
+ #pragma clang attribute push(__attribute__((target("avx"))), apply_to=function)
+ #elif defined(__GNUC__)
+ #pragma GCC push_options
+ #pragma GCC target("avx")
+ #endif
+
+ // Let our code in *_opts.h know we want AVX features.
+ #undef SK_CPU_SSE_LEVEL
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_AVX
+
+ #if defined(__clang__) && defined(_MSC_VER)
+ // clang-cl's immintrin.h is bizarrely annoying, not including the
+ // various foointrin.h unless the __FOO__ flag is also defined (i.e.
+ // you used command-line flags to set the features instead of attributes).
+ // MSVC itself doesn't work this way, nor does non-_MSC_VER clang. :/
+ #define __SSE__ 1
+ #define __SSE2__ 1
+ #define __SSE3__ 1
+ #define __SSSE3__ 1
+ #define __SSE4_1__ 1
+ #define __SSE4_2__ 1
+ #define __AVX__ 1
+ #endif
+
+ #define SK_OPTS_NS avx
+ #include "src/opts/SkRasterPipeline_opts.h"
+ #include "src/opts/SkUtils_opts.h"
+
+ namespace SkOpts {
+ void Init_avx() {
+ memset16 = SK_OPTS_NS::memset16;
+ memset32 = SK_OPTS_NS::memset32;
+ memset64 = SK_OPTS_NS::memset64;
+
+ rect_memset16 = SK_OPTS_NS::rect_memset16;
+ rect_memset32 = SK_OPTS_NS::rect_memset32;
+ rect_memset64 = SK_OPTS_NS::rect_memset64;
+
+ // TODO: maybe cut these stages to save code size? Almost everything is HSW these days.
+ #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
+ SK_RASTER_PIPELINE_STAGES(M)
+ just_return_highp = (StageFn)SK_OPTS_NS::just_return;
+ start_pipeline_highp = SK_OPTS_NS::start_pipeline;
+ #undef M
+
+ #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
+ SK_RASTER_PIPELINE_STAGES(M)
+ just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
+ start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
+ #undef M
+ }
+ }
+
+ #if defined(__clang__)
+ #pragma clang attribute pop
+ #elif defined(__GNUC__)
+ #pragma GCC pop_options
+ #endif
+
+#endif//defined(SK_CPU_X86)
diff --git a/src/core/SkOpts_crc32.cpp b/src/core/SkOpts_crc32.cpp
new file mode 100644
index 0000000..e8b0d5a
--- /dev/null
+++ b/src/core/SkOpts_crc32.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkOpts.h"
+
+#if defined(SK_CPU_ARM64)
+
+ // Turn on CRC32 feature set.
+ #if defined(__clang__)
+ #pragma clang attribute push(__attribute__((target("crc"))), apply_to=function)
+ #elif defined(__GNUC__)
+ #pragma GCC push_options
+ #pragma GCC target("crc")
+ #endif
+
+ // Let our code in *_opts.h know we want CRC32 features.
+ #define SK_ARM_HAS_CRC32
+
+ // Let the arm_acle.h headers know we will be using the CRC32 intrinsics.
+ #define __ARM_FEATURE_CRC32 1
+
+ #define SK_OPTS_NS crc32
+ #include "src/opts/SkChecksum_opts.h"
+
+ namespace SkOpts {
+ void Init_crc32() {
+ hash_fn = SK_OPTS_NS::hash_fn;
+ }
+ }
+
+ #if defined(__clang__)
+ #pragma clang attribute pop
+ #elif defined(__GNUC__)
+ #pragma GCC pop_options
+ #endif
+
+#endif//defined(SK_CPU_ARM64)
diff --git a/src/core/SkOpts_sse41.cpp b/src/core/SkOpts_sse41.cpp
new file mode 100644
index 0000000..a6ff3ae
--- /dev/null
+++ b/src/core/SkOpts_sse41.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkOpts.h"
+
+#if defined(SK_CPU_X86)
+
+ // Turn on SSE4.1 feature set.
+ #if defined(__clang__)
+ #pragma clang attribute push(__attribute__((target("sse4.1"))), apply_to=function)
+ #elif defined(__GNUC__)
+ #pragma GCC push_options
+ #pragma GCC target("sse4.1")
+ #endif
+
+ // Let our code in *_opts.h know we want SSE 4.1 features.
+ #undef SK_CPU_SSE_LEVEL
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE41
+
+ #if defined(__clang__) && defined(_MSC_VER)
+ // clang-cl's immintrin.h is bizarrely annoying, not including the
+ // various foointrin.h unless the __FOO__ flag is also defined (i.e.
+ // you used command-line flags to set the features instead of attributes).
+ // MSVC itself doesn't work this way, nor does non-_MSC_VER clang. :/
+ #define __SSE__ 1
+ #define __SSE2__ 1
+ #define __SSE3__ 1
+ #define __SSSE3__ 1
+ #define __SSE4_1__ 1
+ #endif
+
+ #define SK_OPTS_NS sse41
+ #include "src/opts/SkBlitRow_opts.h"
+ #include "src/opts/SkRasterPipeline_opts.h"
+
+ // TODO: maybe cut this whole file to save code size? Almost everything is HSW these days.
+ namespace SkOpts {
+ void Init_sse41() {
+ blit_row_color32 = SK_OPTS_NS::blit_row_color32;
+ blit_row_s32a_opaque = SK_OPTS_NS::blit_row_s32a_opaque;
+
+ #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
+ SK_RASTER_PIPELINE_STAGES(M)
+ just_return_highp = (StageFn)SK_OPTS_NS::just_return;
+ start_pipeline_highp = SK_OPTS_NS::start_pipeline;
+ #undef M
+
+ #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
+ SK_RASTER_PIPELINE_STAGES(M)
+ just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
+ start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
+ #undef M
+ }
+ }
+
+ #if defined(__clang__)
+ #pragma clang attribute pop
+ #elif defined(__GNUC__)
+ #pragma GCC pop_options
+ #endif
+
+#endif//defined(SK_CPU_X86)
+
diff --git a/src/core/SkOpts_sse42.cpp b/src/core/SkOpts_sse42.cpp
new file mode 100644
index 0000000..46f0851
--- /dev/null
+++ b/src/core/SkOpts_sse42.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkOpts.h"
+
+#if defined(SK_CPU_X86)
+
+ // Turn on SSE4.2 feature set.
+ #if defined(__clang__)
+ #pragma clang attribute push(__attribute__((target("sse4.2"))), apply_to=function)
+ #elif defined(__GNUC__)
+ #pragma GCC push_options
+ #pragma GCC target("sse4.2")
+ #endif
+
+ // Let our code in *_opts.h know we want SSE 4.2 features.
+ #undef SK_CPU_SSE_LEVEL
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE42
+
+ #if defined(__clang__) && defined(_MSC_VER)
+ // clang-cl's immintrin.h is bizarrely annoying, not including the
+ // various foointrin.h unless the __FOO__ flag is also defined (i.e.
+ // you used command-line flags to set the features instead of attributes).
+ // MSVC itself doesn't work this way, nor does non-_MSC_VER clang. :/
+ #define __SSE__ 1
+ #define __SSE2__ 1
+ #define __SSE3__ 1
+ #define __SSSE3__ 1
+ #define __SSE4_1__ 1
+ #define __SSE4_2__ 1
+ #endif
+
+ #define SK_OPTS_NS sse42
+ #include "src/opts/SkChecksum_opts.h"
+
+ namespace SkOpts {
+ void Init_sse42() {
+ hash_fn = SK_OPTS_NS::hash_fn;
+ }
+ }
+
+ #if defined(__clang__)
+ #pragma clang attribute pop
+ #elif defined(__GNUC__)
+ #pragma GCC pop_options
+ #endif
+
+#endif//defined(SK_CPU_X86)
diff --git a/src/core/SkOpts_ssse3.cpp b/src/core/SkOpts_ssse3.cpp
new file mode 100644
index 0000000..7009546
--- /dev/null
+++ b/src/core/SkOpts_ssse3.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2020 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "src/core/SkOpts.h"
+
+#if defined(SK_CPU_X86)
+
+ // Turn on SSSE3 feature set.
+ #if defined(__clang__)
+ #pragma clang attribute push(__attribute__((target("ssse3"))), apply_to=function)
+ #elif defined(__GNUC__)
+ #pragma GCC push_options
+ #pragma GCC target("ssse3")
+ #endif
+
+ // Let our code in *_opts.h know we want SSSE3 features.
+ #undef SK_CPU_SSE_LEVEL
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSSE3
+
+ #if defined(__clang__) && defined(_MSC_VER)
+ // clang-cl's immintrin.h is bizarrely annoying, not including the
+ // various foointrin.h unless the __FOO__ flag is also defined (i.e.
+ // you used command-line flags to set the features instead of attributes).
+ // MSVC itself doesn't work this way, nor does non-_MSC_VER clang. :/
+ #define __SSE__ 1
+ #define __SSE2__ 1
+ #define __SSE3__ 1
+ #define __SSSE3__ 1
+ #endif
+
+ #define SK_OPTS_NS ssse3
+ #include "src/opts/SkBitmapProcState_opts.h"
+ #include "src/opts/SkBlitMask_opts.h"
+ #include "src/opts/SkSwizzler_opts.h"
+ #include "src/opts/SkXfermode_opts.h"
+
+ namespace SkOpts {
+ void Init_ssse3() {
+ RGBA_to_BGRA = SK_OPTS_NS::RGBA_to_BGRA;
+ RGBA_to_rgbA = SK_OPTS_NS::RGBA_to_rgbA;
+ RGBA_to_bgrA = SK_OPTS_NS::RGBA_to_bgrA;
+ RGB_to_RGB1 = SK_OPTS_NS::RGB_to_RGB1;
+ RGB_to_BGR1 = SK_OPTS_NS::RGB_to_BGR1;
+ gray_to_RGB1 = SK_OPTS_NS::gray_to_RGB1;
+ grayA_to_RGBA = SK_OPTS_NS::grayA_to_RGBA;
+ grayA_to_rgbA = SK_OPTS_NS::grayA_to_rgbA;
+ inverted_CMYK_to_RGB1 = SK_OPTS_NS::inverted_CMYK_to_RGB1;
+ inverted_CMYK_to_BGR1 = SK_OPTS_NS::inverted_CMYK_to_BGR1;
+
+ // TODO: maybe cut these three to save code size? Almost everything is HSW these days.
+ create_xfermode = SK_OPTS_NS::create_xfermode;
+ blit_mask_d32_a8 = SK_OPTS_NS::blit_mask_d32_a8;
+ S32_alpha_D32_filter_DX = SK_OPTS_NS::S32_alpha_D32_filter_DX;
+ }
+ }
+
+ #if defined(__clang__)
+ #pragma clang attribute pop
+ #elif defined(__GNUC__)
+ #pragma GCC pop_options
+ #endif
+
+#endif//defined(SK_CPU_X86)
diff --git a/src/opts/SkOpts_avx.cpp b/src/opts/SkOpts_avx.cpp
index 80ccf54..049c90e 100644
--- a/src/opts/SkOpts_avx.cpp
+++ b/src/opts/SkOpts_avx.cpp
@@ -5,32 +5,4 @@
* found in the LICENSE file.
*/
-#include "src/core/SkOpts.h"
-
-#define SK_OPTS_NS avx
-#include "src/opts/SkRasterPipeline_opts.h"
-#include "src/opts/SkUtils_opts.h"
-
-namespace SkOpts {
- void Init_avx() {
- memset16 = SK_OPTS_NS::memset16;
- memset32 = SK_OPTS_NS::memset32;
- memset64 = SK_OPTS_NS::memset64;
-
- rect_memset16 = SK_OPTS_NS::rect_memset16;
- rect_memset32 = SK_OPTS_NS::rect_memset32;
- rect_memset64 = SK_OPTS_NS::rect_memset64;
-
- #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_highp = (StageFn)SK_OPTS_NS::just_return;
- start_pipeline_highp = SK_OPTS_NS::start_pipeline;
- #undef M
-
- #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
- start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
- #undef M
- }
-}
+// Intentionally empty, to be cleaned up.
diff --git a/src/opts/SkOpts_crc32.cpp b/src/opts/SkOpts_crc32.cpp
index 205f0eb..049c90e 100644
--- a/src/opts/SkOpts_crc32.cpp
+++ b/src/opts/SkOpts_crc32.cpp
@@ -5,13 +5,4 @@
* found in the LICENSE file.
*/
-#include "src/core/SkOpts.h"
-
-#define SK_OPTS_NS crc32
-#include "src/opts/SkChecksum_opts.h"
-
-namespace SkOpts {
- void Init_crc32() {
- hash_fn = crc32::hash_fn;
- }
-}
+// Intentionally empty, to be cleaned up.
diff --git a/src/opts/SkOpts_sse41.cpp b/src/opts/SkOpts_sse41.cpp
index 8e52596..abd4796 100644
--- a/src/opts/SkOpts_sse41.cpp
+++ b/src/opts/SkOpts_sse41.cpp
@@ -5,27 +5,4 @@
* found in the LICENSE file.
*/
-#include "src/core/SkOpts.h"
-
-#define SK_OPTS_NS sse41
-#include "src/opts/SkBlitRow_opts.h"
-#include "src/opts/SkRasterPipeline_opts.h"
-
-namespace SkOpts {
- void Init_sse41() {
- blit_row_color32 = sse41::blit_row_color32;
- blit_row_s32a_opaque = sse41::blit_row_s32a_opaque;
-
- #define M(st) stages_highp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_highp = (StageFn)SK_OPTS_NS::just_return;
- start_pipeline_highp = SK_OPTS_NS::start_pipeline;
- #undef M
-
- #define M(st) stages_lowp[SkRasterPipeline::st] = (StageFn)SK_OPTS_NS::lowp::st;
- SK_RASTER_PIPELINE_STAGES(M)
- just_return_lowp = (StageFn)SK_OPTS_NS::lowp::just_return;
- start_pipeline_lowp = SK_OPTS_NS::lowp::start_pipeline;
- #undef M
- }
-}
+// Intentionally empty, to be cleaned up.
diff --git a/src/opts/SkOpts_sse42.cpp b/src/opts/SkOpts_sse42.cpp
index 8e80fff..049c90e 100644
--- a/src/opts/SkOpts_sse42.cpp
+++ b/src/opts/SkOpts_sse42.cpp
@@ -5,14 +5,4 @@
* found in the LICENSE file.
*/
-#include "src/core/SkOpts.h"
-
-#define SK_OPTS_NS sse42
-#include "src/opts/SkChecksum_opts.h"
-
-namespace SkOpts {
- void Init_sse42() {
- hash_fn = sse42::hash_fn;
- }
-}
-
+// Intentionally empty, to be cleaned up.
diff --git a/src/opts/SkOpts_ssse3.cpp b/src/opts/SkOpts_ssse3.cpp
index daa6987..abd4796 100644
--- a/src/opts/SkOpts_ssse3.cpp
+++ b/src/opts/SkOpts_ssse3.cpp
@@ -5,29 +5,4 @@
* found in the LICENSE file.
*/
-#include "src/core/SkOpts.h"
-#define SK_OPTS_NS ssse3
-#include "src/opts/SkBitmapProcState_opts.h"
-#include "src/opts/SkBlitMask_opts.h"
-#include "src/opts/SkSwizzler_opts.h"
-#include "src/opts/SkXfermode_opts.h"
-
-namespace SkOpts {
- void Init_ssse3() {
- create_xfermode = ssse3::create_xfermode;
- blit_mask_d32_a8 = ssse3::blit_mask_d32_a8;
-
- RGBA_to_BGRA = ssse3::RGBA_to_BGRA;
- RGBA_to_rgbA = ssse3::RGBA_to_rgbA;
- RGBA_to_bgrA = ssse3::RGBA_to_bgrA;
- RGB_to_RGB1 = ssse3::RGB_to_RGB1;
- RGB_to_BGR1 = ssse3::RGB_to_BGR1;
- gray_to_RGB1 = ssse3::gray_to_RGB1;
- grayA_to_RGBA = ssse3::grayA_to_RGBA;
- grayA_to_rgbA = ssse3::grayA_to_rgbA;
- inverted_CMYK_to_RGB1 = ssse3::inverted_CMYK_to_RGB1;
- inverted_CMYK_to_BGR1 = ssse3::inverted_CMYK_to_BGR1;
-
- S32_alpha_D32_filter_DX = ssse3::S32_alpha_D32_filter_DX;
- }
-}
+// Intentionally empty, to be cleaned up.