Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: src/core/SkOpts.cpp

Issue 1881903004: Rewriting MatrixConvolution image filter with SSE and AVX2 Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkHalf.h" 8 #include "SkHalf.h"
9 #include "SkOnce.h" 9 #include "SkOnce.h"
10 #include "SkOpts.h" 10 #include "SkOpts.h"
11 11
12 #define SK_OPTS_NS sk_default 12 #define SK_OPTS_NS sk_default
13 #include "SkBlitMask_opts.h" 13 #include "SkBlitMask_opts.h"
14 #include "SkBlitRow_opts.h" 14 #include "SkBlitRow_opts.h"
15 #include "SkBlurImageFilter_opts.h" 15 #include "SkBlurImageFilter_opts.h"
16 #include "SkColorCubeFilter_opts.h" 16 #include "SkColorCubeFilter_opts.h"
17 #include "SkMatrix_opts.h" 17 #include "SkMatrix_opts.h"
18 #include "SkMorphologyImageFilter_opts.h" 18 #include "SkMorphologyImageFilter_opts.h"
19 #include "SkSwizzler_opts.h" 19 #include "SkSwizzler_opts.h"
20 #include "SkTextureCompressor_opts.h" 20 #include "SkTextureCompressor_opts.h"
21 #include "SkXfermode_opts.h" 21 #include "SkXfermode_opts.h"
22 #include "SkMatrixConvolutionImageFilter_opts.h"
22 23
23 namespace SK_OPTS_NS { 24 namespace SK_OPTS_NS {
24 static void float_to_half(uint16_t dst[], const float src[], int n) { 25 static void float_to_half(uint16_t dst[], const float src[], int n) {
25 while (n-->0) { 26 while (n-->0) {
26 *dst++ = SkFloatToHalf(*src++); 27 *dst++ = SkFloatToHalf(*src++);
27 } 28 }
28 } 29 }
29 static void half_to_float(float dst[], const uint16_t src[], int n) { 30 static void half_to_float(float dst[], const uint16_t src[], int n) {
30 while (n-->0) { 31 while (n-->0) {
31 *dst++ = SkHalfToFloat(*src++); 32 *dst++ = SkHalfToFloat(*src++);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 decltype(RGB_to_BGR1) RGB_to_BGR1 = sk_default::RGB_to_B GR1; 100 decltype(RGB_to_BGR1) RGB_to_BGR1 = sk_default::RGB_to_B GR1;
100 decltype(gray_to_RGB1) gray_to_RGB1 = sk_default::gray_to_ RGB1; 101 decltype(gray_to_RGB1) gray_to_RGB1 = sk_default::gray_to_ RGB1;
101 decltype(grayA_to_RGBA) grayA_to_RGBA = sk_default::grayA_to _RGBA; 102 decltype(grayA_to_RGBA) grayA_to_RGBA = sk_default::grayA_to _RGBA;
102 decltype(grayA_to_rgbA) grayA_to_rgbA = sk_default::grayA_to _rgbA; 103 decltype(grayA_to_rgbA) grayA_to_rgbA = sk_default::grayA_to _rgbA;
103 decltype(inverted_CMYK_to_RGB1) inverted_CMYK_to_RGB1 = sk_default::inverted _CMYK_to_RGB1; 104 decltype(inverted_CMYK_to_RGB1) inverted_CMYK_to_RGB1 = sk_default::inverted _CMYK_to_RGB1;
104 decltype(inverted_CMYK_to_BGR1) inverted_CMYK_to_BGR1 = sk_default::inverted _CMYK_to_BGR1; 105 decltype(inverted_CMYK_to_BGR1) inverted_CMYK_to_BGR1 = sk_default::inverted _CMYK_to_BGR1;
105 106
106 decltype(half_to_float) half_to_float = sk_default::half_to_float; 107 decltype(half_to_float) half_to_float = sk_default::half_to_float;
107 decltype(float_to_half) float_to_half = sk_default::float_to_half; 108 decltype(float_to_half) float_to_half = sk_default::float_to_half;
108 109
110 decltype(matrix_convolution_image_filter_filter_pixels) matrix_convolution_i mage_filter_filter_pixels = sk_default::SkMatrixConvolutionImageFilter_filterPix els_none;
111
109 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp. 112 // Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
113 void Init_sse_sse2();
110 void Init_ssse3(); 114 void Init_ssse3();
111 void Init_sse41(); 115 void Init_sse41();
112 void Init_sse42() {} 116 void Init_sse42() {}
113 void Init_avx() {} 117 void Init_avx() {}
114 void Init_avx2() {} 118 void Init_avx2();
115 void Init_neon(); 119 void Init_neon();
116 120
117 static void init() { 121 static void init() {
118 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature? 122 // TODO: Chrome's not linking _sse* opts on iOS simulator builds. Bug o r feature?
119 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS) 123 #if defined(SK_CPU_X86) && !defined(SK_BUILD_FOR_IOS)
124
125 // 'opts' target for x86 is already compiled with -msse2. Therefore, MMX , SSE, SSE2
126 // should be supported by every x86 CPU. So, just call Init_sse_sse2 fun ction without
127 // any additional check.
128 Init_sse_sse2();
129
120 uint32_t abcd[] = {0,0,0,0}; 130 uint32_t abcd[] = {0,0,0,0};
121 cpuid(abcd); 131 cpuid(abcd);
132
122 if (abcd[2] & (1<< 9)) { Init_ssse3(); } 133 if (abcd[2] & (1<< 9)) { Init_ssse3(); }
123 if (abcd[2] & (1<<19)) { Init_sse41(); } 134 if (abcd[2] & (1<<19)) { Init_sse41(); }
124 if (abcd[2] & (1<<20)) { Init_sse42(); } 135 if (abcd[2] & (1<<20)) { Init_sse42(); }
125 136
126 // AVX detection's kind of a pain. This is cribbed from Chromium. 137 // AVX detection's kind of a pain. This is cribbed from Chromium.
127 if ( ( abcd[2] & (7<<26)) == (7<<26) && // Check bits 26-28 of ecx a re all set, 138 if ( ( abcd[2] & (7<<26)) == (7<<26) && // Check bits 26-28 of ecx a re all set,
128 (xgetbv(0) & 6 ) == 6 ){ // and check the OS support s XSAVE. 139 (xgetbv(0) & 6 ) == 6 ){ // and check the OS support s XSAVE.
129 Init_avx(); 140 Init_avx();
130 141
131 // AVX2 additionally needs bit 5 set on ebx after calling cpuid(7). 142 // AVX2 additionally needs bit 5 set on ebx after calling cpuid(7).
(...skipping 12 matching lines...) Expand all
144 155
145 SK_DECLARE_STATIC_ONCE(gInitOnce); 156 SK_DECLARE_STATIC_ONCE(gInitOnce);
146 void Init() { SkOnce(&gInitOnce, init); } 157 void Init() { SkOnce(&gInitOnce, init); }
147 158
148 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 159 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
149 static struct AutoInit { 160 static struct AutoInit {
150 AutoInit() { Init(); } 161 AutoInit() { Init(); }
151 } gAutoInit; 162 } gAutoInit;
152 #endif 163 #endif
153 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698