summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubhransu Mohanty <sub.mohanty@samsung.com>2015-08-17 15:42:48 +0900
committerCedric BAIL <cedric@osg.samsung.com>2015-08-19 15:11:06 +0200
commitbed8325e3c2632782c01d21d008b09be7b8b3a3e (patch)
tree2f25d44a583eb72ae3887849583f71833ee156ad
parent74dcf5ed15061349614c9d9a33437808734d5afb (diff)
ector: add NEON support for composition function in software backend.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Ector.am3
-rw-r--r--src/lib/ector/software/ector_drawhelper.c2
-rw-r--r--src/lib/ector/software/ector_drawhelper_neon.c226
3 files changed, 230 insertions, 1 deletions
diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am
index 26e934d4b0..3d158ef5e8 100644
--- a/src/Makefile_Ector.am
+++ b/src/Makefile_Ector.am
@@ -97,7 +97,8 @@ lib/ector/software/sw_ft_math.c \
97lib/ector/software/sw_ft_raster.c \ 97lib/ector/software/sw_ft_raster.c \
98lib/ector/software/sw_ft_stroker.c \ 98lib/ector/software/sw_ft_stroker.c \
99lib/ector/software/ector_drawhelper.c \ 99lib/ector/software/ector_drawhelper.c \
100lib/ector/software/ector_drawhelper_sse2.c 100lib/ector/software/ector_drawhelper_sse2.c \
101lib/ector/software/ector_drawhelper_neon.c
101 102
102installed_ectorsoftwareheadersdir = $(includedir)/ector-@VMAJ@/software 103installed_ectorsoftwareheadersdir = $(includedir)/ector-@VMAJ@/software
103nodist_installed_ectorsoftwareheaders_DATA = $(ector_eolian_software_h) 104nodist_installed_ectorsoftwareheaders_DATA = $(ector_eolian_software_h)
diff --git a/src/lib/ector/software/ector_drawhelper.c b/src/lib/ector/software/ector_drawhelper.c
index 26d8f988b0..39180b8e77 100644
--- a/src/lib/ector/software/ector_drawhelper.c
+++ b/src/lib/ector/software/ector_drawhelper.c
@@ -150,8 +150,10 @@ RGBA_Comp_Func ector_comp_func_span_get(Ector_Rop op, uint color, Eina_Bool src_
150} 150}
151 151
152extern void init_draw_helper_sse2(); 152extern void init_draw_helper_sse2();
153extern void init_draw_helper_neon();
153 154
154void init_draw_helper() 155void init_draw_helper()
155{ 156{
156 init_draw_helper_sse2(); 157 init_draw_helper_sse2();
158 init_draw_helper_neon();
157} 159}
diff --git a/src/lib/ector/software/ector_drawhelper_neon.c b/src/lib/ector/software/ector_drawhelper_neon.c
new file mode 100644
index 0000000000..3adfdba62f
--- /dev/null
+++ b/src/lib/ector/software/ector_drawhelper_neon.c
@@ -0,0 +1,226 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include <Ector.h>
6#include "ector_drawhelper_private.h"
7
8#ifdef BUILD_NEON
9#include <arm_neon.h>
10static void
11comp_func_solid_source_over_neon(uint * __restrict dest, int length, uint color, uint const_alpha)
12{
13 uint16x8_t temp00_16x8;
14 uint16x8_t temp01_16x8;
15 uint16x8_t temp10_16x8;
16 uint16x8_t temp11_16x8;
17 uint32x4_t temp0_32x4;
18 uint32x4_t temp1_32x4;
19 uint32x4_t c_32x4;
20 uint32x4_t d0_32x4;
21 uint32x4_t d1_32x4;
22 uint8x16_t d0_8x16;
23 uint8x16_t d1_8x16;
24 uint8x16_t temp0_8x16;
25 uint8x16_t temp1_8x16;
26 uint8x8_t alpha_8x8;
27 uint8x8_t d00_8x8;
28 uint8x8_t d01_8x8;
29 uint8x8_t d10_8x8;
30 uint8x8_t d11_8x8;
31 uint8x8_t temp00_8x8;
32 uint8x8_t temp01_8x8;
33 uint8x8_t temp10_8x8;
34 uint8x8_t temp11_8x8;
35
36 if (const_alpha != 255)
37 color = BYTE_MUL(color, const_alpha);
38
39 // alpha can only be 0 if color is 0x0. In that case we can just return.
40 // Otherwise we can assume alpha != 0. This allows more optimization in
41 // NEON code.
42 if(!color)
43 return;
44
45 DATA32 *start = dest;
46 int size = length;
47 DATA32 *end = start + (size & ~7);
48
49 unsigned char alpha;
50 alpha = ~(color >> 24) + 1;
51 alpha_8x8 = vdup_n_u8(alpha);
52
53 c_32x4 = vdupq_n_u32(color);
54
55 while (start < end)
56 {
57 d0_32x4 = vld1q_u32(start);
58 d1_32x4 = vld1q_u32(start+4);
59 d0_8x16 = vreinterpretq_u8_u32(d0_32x4);
60 d1_8x16 = vreinterpretq_u8_u32(d1_32x4);
61
62 d00_8x8 = vget_low_u8(d0_8x16);
63 d01_8x8 = vget_high_u8(d0_8x16);
64 d10_8x8 = vget_low_u8(d1_8x16);
65 d11_8x8 = vget_high_u8(d1_8x16);
66
67 temp00_16x8 = vmull_u8(alpha_8x8, d00_8x8);
68 temp01_16x8 = vmull_u8(alpha_8x8, d01_8x8);
69 temp10_16x8 = vmull_u8(alpha_8x8, d10_8x8);
70 temp11_16x8 = vmull_u8(alpha_8x8, d11_8x8);
71
72 temp00_8x8 = vshrn_n_u16(temp00_16x8,8);
73 temp01_8x8 = vshrn_n_u16(temp01_16x8,8);
74 temp10_8x8 = vshrn_n_u16(temp10_16x8,8);
75 temp11_8x8 = vshrn_n_u16(temp11_16x8,8);
76
77 temp0_8x16 = vcombine_u8(temp00_8x8, temp01_8x8);
78 temp1_8x16 = vcombine_u8(temp10_8x8, temp11_8x8);
79
80 temp0_32x4 = vreinterpretq_u32_u8(temp0_8x16);
81 temp1_32x4 = vreinterpretq_u32_u8(temp1_8x16);
82
83 d0_32x4 = vaddq_u32(c_32x4, temp0_32x4);
84 d1_32x4 = vaddq_u32(c_32x4, temp1_32x4);
85
86 vst1q_u32(start, d0_32x4);
87 vst1q_u32(start+4, d1_32x4);
88 start+=8;
89 }
90 end += (size & 7);
91 while (start < end)
92 {
93 *start = color + MUL_256(alpha, *start);
94 start++;
95 }
96}
97
98/* Note: Optimisation is based on keeping _dest_ aligned: else it's a pair of
99 * reads, then two writes, a miss on read is 'just' two reads */
100static void
101comp_func_source_over_sse2(uint * __restrict dest, const uint * __restrict src, int length, uint color, uint const_alpha)
102{
103 uint16x8_t ad0_16x8;
104 uint16x8_t ad1_16x8;
105 uint16x8_t sc0_16x8;
106 uint16x8_t sc1_16x8;
107 uint16x8_t x255_16x8;
108 uint32x2_t c_32x2;
109 uint32x4_t ad_32x4;
110 uint32x4_t alpha_32x4;
111 uint32x4_t cond_32x4;
112 uint32x4_t d_32x4;
113 uint32x4_t s_32x4;
114 uint32x4_t sc_32x4;
115 uint32x4_t x0_32x4;
116 uint32x4_t x1_32x4;
117 uint8x16_t ad_8x16;
118 uint8x16_t alpha_8x16;
119 uint8x16_t d_8x16;
120 uint8x16_t s_8x16;
121 uint8x16_t sc_8x16;
122 uint8x16_t x0_8x16;
123 uint8x16_t x1_8x16;
124 uint8x8_t ad0_8x8;
125 uint8x8_t ad1_8x8;
126 uint8x8_t alpha0_8x8;
127 uint8x8_t alpha1_8x8;
128 uint8x8_t c_8x8;
129 uint8x8_t d0_8x8;
130 uint8x8_t d1_8x8;
131 uint8x8_t s0_8x8;
132 uint8x8_t s1_8x8;
133 uint8x8_t sc0_8x8;
134 uint8x8_t sc1_8x8;
135
136 if (const_alpha != 255)
137 color = BYTE_MUL(color, const_alpha);
138
139 c_32x2 = vdup_n_u32(color);
140 c_8x8 = vreinterpret_u8_u32(c_32x2);
141 x255_16x8 = vdupq_n_u16(0xff);
142 x0_8x16 = vdupq_n_u8(0x0);
143 x0_32x4 = vreinterpretq_u32_u8(x0_8x16);
144 x1_8x16 = vdupq_n_u8(0x1);
145 x1_32x4 = vreinterpretq_u32_u8(x1_8x16);
146 DATA32 *start = dest;
147 int size = l;
148 DATA32 *end = start + (size & ~3);
149 while (start < end)
150 {
151
152 s_32x4 = vld1q_u32(src);
153 s_8x16 = vreinterpretq_u8_u32(s_32x4);
154
155 d_32x4 = vld1q_u32(start);
156 d_8x16 = vreinterpretq_u8_u32(d_32x4);
157 d0_8x8 = vget_low_u8(d_8x16);
158 d1_8x8 = vget_high_u8(d_8x16);
159
160 s0_8x8 = vget_low_u8(s_8x16);
161 s1_8x8 = vget_high_u8(s_8x16);
162
163 sc0_16x8 = vmull_u8(s0_8x8, c_8x8);
164 sc1_16x8 = vmull_u8(s1_8x8, c_8x8);
165 sc0_16x8 = vaddq_u16(sc0_16x8, x255_16x8);
166 sc1_16x8 = vaddq_u16(sc1_16x8, x255_16x8);
167 sc0_8x8 = vshrn_n_u16(sc0_16x8, 8);
168 sc1_8x8 = vshrn_n_u16(sc1_16x8, 8);
169 sc_8x16 = vcombine_u8(sc0_8x8, sc1_8x8);
170
171 alpha_32x4 = vreinterpretq_u32_u8(sc_8x16);
172 alpha_32x4 = vshrq_n_u32(alpha_32x4, 24);
173 alpha_32x4 = vmulq_u32(x1_32x4, alpha_32x4);
174 alpha_8x16 = vreinterpretq_u8_u32(alpha_32x4);
175 alpha_8x16 = vsubq_u8(x0_8x16, alpha_8x16);
176 alpha0_8x8 = vget_low_u8(alpha_8x16);
177 alpha1_8x8 = vget_high_u8(alpha_8x16);
178
179 ad0_16x8 = vmull_u8(alpha0_8x8, d0_8x8);
180 ad1_16x8 = vmull_u8(alpha1_8x8, d1_8x8);
181 ad0_8x8 = vshrn_n_u16(ad0_16x8,8);
182 ad1_8x8 = vshrn_n_u16(ad1_16x8,8);
183 ad_8x16 = vcombine_u8(ad0_8x8, ad1_8x8);
184 ad_32x4 = vreinterpretq_u32_u8(ad_8x16);
185
186 alpha_32x4 = vreinterpretq_u32_u8(alpha_8x16);
187 cond_32x4 = vceqq_u32(alpha_32x4, x0_32x4);
188 ad_32x4 = vbslq_u32(cond_32x4, d_32x4 , ad_32x4);
189
190 sc_32x4 = vreinterpretq_u32_u8(sc_8x16);
191 d_32x4 = vaddq_u32(sc_32x4, ad_32x4);
192
193 vst1q_u32(start, d_32x4);
194
195 src+=4;
196 start+=4;
197 }
198 end += (size & 3);
199 while (start < end)
200 {
201 DATA32 sc = MUL4_SYM(color, *s);
202 DATA32 alpha = 256 - (sc >> 24);
203 *start = sc + MUL_256(alpha, *start);
204 start++;
205 src++;
206 }
207}
208
209#endif
210
211void
212init_draw_helper_neon()
213{
214#ifdef BUILD_NEON
215 if (eina_cpu_features_get() & EINA_CPU_NEON)
216 {
217 // update the comp_function table for solid color
218 //func_for_mode_solid[ECTOR_ROP_COPY] = comp_func_solid_source_sse2;
219 func_for_mode_solid[ECTOR_ROP_BLEND] = comp_func_solid_source_over_neon;
220
221 // update the comp_function table for source data
222 //func_for_mode[ECTOR_ROP_COPY] = comp_func_source_sse2;
223 func_for_mode[ECTOR_ROP_BLEND] = comp_func_source_over_neon;
224 }
225#endif
226}