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

Side by Side Diff: src/opts/SkBlitMask_opts_arm_neon.cpp

Issue 1213723002: Optimize RGB16 blitV functions with NEON for ARM platform. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/core/SkBlitter_RGB16.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2016 The Android Open Source Project
mtklein 2015/06/26 14:05:50 Let's put 2013 (file created) or 2015 (now) here.
yang.zhang 2015/06/29 07:25:57 Done.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 8
2 #include "SkBlitMask.h" 9 #include "SkBlitMask.h"
3 #include "SkColor_opts_neon.h" 10 #include "SkColor_opts_neon.h"
4 11
5 static void D32_A8_Black_neon(void* SK_RESTRICT dst, size_t dstRB, 12 static void D32_A8_Black_neon(void* SK_RESTRICT dst, size_t dstRB,
6 const void* SK_RESTRICT maskPtr, size_t maskRB, 13 const void* SK_RESTRICT maskPtr, size_t maskRB,
7 SkColor, int width, int height) { 14 SkColor, int width, int height) {
8 SkPMColor* SK_RESTRICT device = (SkPMColor*)dst; 15 SkPMColor* SK_RESTRICT device = (SkPMColor*)dst;
9 const uint8_t* SK_RESTRICT mask = (const uint8_t*)maskPtr; 16 const uint8_t* SK_RESTRICT mask = (const uint8_t*)maskPtr;
10 17
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 252
246 dst += 8; 253 dst += 8;
247 src += 8; 254 src += 8;
248 width -= 8; 255 width -= 8;
249 } 256 }
250 257
251 for (int i = 0; i < width; i++) { 258 for (int i = 0; i < width; i++) {
252 dst[i] = SkBlendLCD16(colA, colR, colG, colB, dst[i], src[i]); 259 dst[i] = SkBlendLCD16(colA, colR, colG, colB, dst[i], src[i]);
253 } 260 }
254 } 261 }
262
263 void SkRGB16BlitterBlitV_neon(uint16_t* device,
264 int height,
265 size_t deviceRB,
266 unsigned scale,
267 uint32_t src32) {
268 uint32x4_t vsrc32, vscale5;
mtklein 2015/06/26 14:05:50 Does writing it like this recover any of the slowd
yang.zhang 2015/06/29 07:25:57 Yeah. The setup code may have an effect on the cas
269 uint16x8_t vmaskq_g16, vmaskq_ng16;
270 uint16x4_t vmask_g16, vmask_ng16;
271 uint16x8_t vdev;
272 uint16x8x2_t vdst32;
mtklein 2015/06/26 14:05:50 I'd prefer if if you could move the declarations o
yang.zhang 2015/06/29 07:25:57 Done.
273 uint32x4_t vdst32_lo, vdst32_hi;
274 uint16x4_t vtmp_lo, vtmp_hi;
275 uint16x4_t vdst16_lo, vdst16_hi;
276 uint16_t* dst = device;
277
278 // prepare constants
279 vdev = vdupq_n_u16(0);
280 vmaskq_g16 = vdupq_n_u16(SK_G16_MASK_IN_PLACE);
mtklein 2015/06/26 14:05:50 Why do we make four masks here when we can use van
yang.zhang 2015/06/29 07:25:57 Done.
281 vmaskq_ng16 = vdupq_n_u16(~SK_G16_MASK_IN_PLACE);
282 vmask_g16 = vdup_n_u16(SK_G16_MASK_IN_PLACE);
283 vmask_ng16 = vdup_n_u16(~SK_G16_MASK_IN_PLACE);
284 vsrc32 = vdupq_n_u32(src32);
285 vscale5 = vdupq_n_u32((uint32_t)scale);
286
287 while (height >= 8){
288 vdev = vld1q_lane_u16(device, vdev, 0);
mtklein 2015/06/26 14:05:50 This code (and the stores) might read more clearly
yang.zhang 2015/06/29 07:25:57 Done.
289 device = (uint16_t*)((char*)device + deviceRB);
290 vdev = vld1q_lane_u16(device, vdev, 1);
291 device = (uint16_t*)((char*)device + deviceRB);
292 vdev = vld1q_lane_u16(device, vdev, 2);
293 device = (uint16_t*)((char*)device + deviceRB);
294 vdev = vld1q_lane_u16(device, vdev, 3);
295 device = (uint16_t*)((char*)device + deviceRB);
296 vdev = vld1q_lane_u16(device, vdev, 4);
297 device = (uint16_t*)((char*)device + deviceRB);
298 vdev = vld1q_lane_u16(device, vdev, 5);
299 device = (uint16_t*)((char*)device + deviceRB);
300 vdev = vld1q_lane_u16(device, vdev, 6);
301 device = (uint16_t*)((char*)device + deviceRB);
302 vdev = vld1q_lane_u16(device, vdev, 7);
303 device = (uint16_t*)((char*)device + deviceRB);
304
305 // Expand_rgb_16
306 vdst32 = vzipq_u16((vdev & vmaskq_ng16), (vdev & vmaskq_g16));
307 vdst32_lo = vmulq_u32(vreinterpretq_u32_u16(vdst32.val[0]), vscale5);
308 vdst32_hi = vmulq_u32(vreinterpretq_u32_u16(vdst32.val[1]), vscale5);
309
310 // Compact_rgb_16
311 vdst32_lo = vaddq_u32(vdst32_lo, vsrc32);
312 vdst32_hi = vaddq_u32(vdst32_hi, vsrc32);
313 vdst32_lo = vshrq_n_u32(vdst32_lo, 5);
314 vdst32_hi = vshrq_n_u32(vdst32_hi, 5);
315
316 vtmp_lo = vmovn_u32(vdst32_lo) & vmask_ng16;
317 vtmp_hi = vshrn_n_u32(vdst32_lo, 16) & vmask_g16;
318 vdst16_lo = vorr_u16(vtmp_lo, vtmp_hi);
319 vtmp_lo = vmovn_u32(vdst32_hi) & vmask_ng16;
320 vtmp_hi = vshrn_n_u32(vdst32_hi, 16) & vmask_g16;
321 vdst16_hi = vorr_u16(vtmp_lo, vtmp_hi);
322
323 vst1_lane_u16(dst, vdst16_lo, 0);
324 dst = (uint16_t*)((char*)dst + deviceRB);
325 vst1_lane_u16(dst, vdst16_lo, 1);
326 dst = (uint16_t*)((char*)dst + deviceRB);
327 vst1_lane_u16(dst, vdst16_lo, 2);
328 dst = (uint16_t*)((char*)dst + deviceRB);
329 vst1_lane_u16(dst, vdst16_lo, 3);
330 dst = (uint16_t*)((char*)dst + deviceRB);
331 vst1_lane_u16(dst, vdst16_hi, 0);
332 dst = (uint16_t*)((char*)dst + deviceRB);
333 vst1_lane_u16(dst, vdst16_hi, 1);
334 dst = (uint16_t*)((char*)dst + deviceRB);
335 vst1_lane_u16(dst, vdst16_hi, 2);
336 dst = (uint16_t*)((char*)dst + deviceRB);
337 vst1_lane_u16(dst, vdst16_hi, 3);
338 dst = (uint16_t*)((char*)dst + deviceRB);
339 height -= 8;
340 }
341 while (height != 0){
342 uint32_t dst32 = SkExpand_rgb_16(*device) * scale;
343 *device = SkCompact_rgb_16((src32 + dst32) >> 5);
344 device = (uint16_t*)((char*)device + deviceRB);
345 height--;
346 }
347 }
348
349 void SkRGB16BlitterBlitH_neon(uint16_t* device,
mtklein 2015/06/26 14:05:50 Let's leave this out until it's used?
350 int height,
351 unsigned scale,
352 uint32_t src32) {
353
354 uint32x4_t vsrc32, vscale5;
355 uint16x8_t vmaskq_g16, vmaskq_ng16;
356 uint16x4_t vmask_g16, vmask_ng16;
357 uint16x8_t vdev;
358 uint16x8x2_t vdst32;
359 uint32x4_t vdst32_lo, vdst32_hi;
360 uint16x4_t vtmp_lo, vtmp_hi;
361 uint16x4_t vdst16_lo, vdst16_hi;
362
363 // prepare constants
364 vdev = vdupq_n_u16(0);
365 vmaskq_g16 = vdupq_n_u16(SK_G16_MASK_IN_PLACE);
366 vmaskq_ng16 = vdupq_n_u16(~SK_G16_MASK_IN_PLACE);
367 vmask_g16 = vdup_n_u16(SK_G16_MASK_IN_PLACE);
368 vmask_ng16 = vdup_n_u16(~SK_G16_MASK_IN_PLACE);
369 vsrc32 = vdupq_n_u32(src32);
370 vscale5 = vdupq_n_u32((uint32_t)scale);
371
372 while (height >= 8){
373 vdev = vld1q_u16(device);
374
375 // Expand_rgb_16
376 vdst32 = vzipq_u16((vdev & vmaskq_ng16), (vdev & vmaskq_g16));
377 vdst32_lo = vmulq_u32(vreinterpretq_u32_u16(vdst32.val[0]), vscale5);
378 vdst32_hi = vmulq_u32(vreinterpretq_u32_u16(vdst32.val[1]), vscale5);
379
380 // Compact_rgb_16
381 vdst32_lo = vaddq_u32(vdst32_lo, vsrc32);
382 vdst32_hi = vaddq_u32(vdst32_hi, vsrc32);
383 vdst32_lo = vshrq_n_u32(vdst32_lo, 5);
384 vdst32_hi = vshrq_n_u32(vdst32_hi, 5);
385
386 vtmp_lo = vmovn_u32(vdst32_lo) & vmask_ng16;
387 vtmp_hi = vshrn_n_u32(vdst32_lo, 16) & vmask_g16;
388 vdst16_lo = vorr_u16(vtmp_lo, vtmp_hi);
389 vtmp_lo = vmovn_u32(vdst32_hi) & vmask_ng16;
390 vtmp_hi = vshrn_n_u32(vdst32_hi, 16) & vmask_g16;
391 vdst16_hi = vorr_u16(vtmp_lo, vtmp_hi);
392
393 vst1q_u16(device, vcombine_u16(vdst16_lo, vdst16_hi));
394 device += 8;
395 height -= 8;
396 }
397 while (height != 0){
398 uint32_t dst32 = SkExpand_rgb_16(*device) * scale;
399 *device++ = SkCompact_rgb_16((src32 + dst32) >> 5);
400 height--;
401 }
402 }
OLDNEW
« no previous file with comments | « src/core/SkBlitter_RGB16.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698