2 * Copyright © 2009 Nokia Corporation
3 * Copyright © 2010 Movial Creative Technologies Oy
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
33 #define L1CACHE_SIZE (8 * 1024)
34 #define L2CACHE_SIZE (128 * 1024)
38 #define BUFSIZE (WIDTH * HEIGHT * 4)
44 #define EXCLUDE_OVERHEAD 1
62 memcpy (dst, src, BUFSIZE - 64);
63 memcpy (src, dst, BUFSIZE - 64);
64 n += 4 * (BUFSIZE - 64);
75 memcpy ((char *)dst + 1, (char *)src + x, BUFSIZE - 64);
76 memcpy ((char *)src + 1, (char *)dst + x, BUFSIZE - 64);
77 n -= 4 * (BUFSIZE - 64);
80 return (double)total / (t2 - t1);
84 pixman_image_composite_wrapper (pixman_implementation_t *impl,
85 pixman_composite_info_t *info)
87 pixman_image_composite (info->op,
88 info->src_image, info->mask_image, info->dest_image,
89 info->src_x, info->src_y,
90 info->mask_x, info->mask_y,
91 info->dest_x, info->dest_y,
92 info->width, info->height);
96 pixman_image_composite_empty (pixman_implementation_t *impl,
97 pixman_composite_info_t *info)
99 pixman_image_composite (info->op,
100 info->src_image, info->mask_image, info->dest_image,
101 0, 0, 0, 0, 0, 0, 1, 1);
105 call_func (pixman_composite_func_t func,
107 pixman_image_t * src_image,
108 pixman_image_t * mask_image,
109 pixman_image_t * dest_image,
119 pixman_composite_info_t info;
122 info.src_image = src_image;
123 info.mask_image = mask_image;
124 info.dest_image = dest_image;
127 info.mask_x = mask_x;
128 info.mask_y = mask_y;
129 info.dest_x = dest_x;
130 info.dest_y = dest_y;
132 info.height = height;
139 bench_L (pixman_op_t op,
140 pixman_image_t * src_img,
141 pixman_image_t * mask_img,
142 pixman_image_t * dst_img,
144 pixman_composite_func_t func,
153 for (i = 0; i < n; i++)
155 /* touch destination buffer to fetch it into L1 cache */
156 for (j = 0; j < width + 64; j += 16) {
162 call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 63 - x, 0, width, lines_count);
169 bench_M (pixman_op_t op,
170 pixman_image_t * src_img,
171 pixman_image_t * mask_img,
172 pixman_image_t * dst_img,
174 pixman_composite_func_t func)
179 for (i = 0; i < n; i++)
183 call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 1, 0, WIDTH - 64, HEIGHT);
189 bench_HT (pixman_op_t op,
190 pixman_image_t * src_img,
191 pixman_image_t * mask_img,
192 pixman_image_t * dst_img,
194 pixman_composite_func_t func)
202 for (i = 0; i < n; i++)
204 int w = (rand () % (TILEWIDTH * 2)) + 1;
205 int h = (rand () % (TILEWIDTH * 2)) + 1;
215 call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h);
224 bench_VT (pixman_op_t op,
225 pixman_image_t * src_img,
226 pixman_image_t * mask_img,
227 pixman_image_t * dst_img,
229 pixman_composite_func_t func)
237 for (i = 0; i < n; i++)
239 int w = (rand () % (TILEWIDTH * 2)) + 1;
240 int h = (rand () % (TILEWIDTH * 2)) + 1;
250 call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h);
259 bench_R (pixman_op_t op,
260 pixman_image_t * src_img,
261 pixman_image_t * mask_img,
262 pixman_image_t * dst_img,
264 pixman_composite_func_t func,
271 if (maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2)
273 printf("error: maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2\n");
278 for (i = 0; i < n; i++)
280 int w = (rand () % (TILEWIDTH * 2)) + 1;
281 int h = (rand () % (TILEWIDTH * 2)) + 1;
282 int sx = rand () % (maxw - TILEWIDTH * 2);
283 int sy = rand () % (maxh - TILEWIDTH * 2);
284 int dx = rand () % (maxw - TILEWIDTH * 2);
285 int dy = rand () % (maxh - TILEWIDTH * 2);
286 call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h);
294 bench_RT (pixman_op_t op,
295 pixman_image_t * src_img,
296 pixman_image_t * mask_img,
297 pixman_image_t * dst_img,
299 pixman_composite_func_t func,
306 if (maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2)
308 printf("error: maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2\n");
313 for (i = 0; i < n; i++)
315 int w = (rand () % (TINYWIDTH * 2)) + 1;
316 int h = (rand () % (TINYWIDTH * 2)) + 1;
317 int sx = rand () % (maxw - TINYWIDTH * 2);
318 int sy = rand () % (maxh - TINYWIDTH * 2);
319 int dx = rand () % (maxw - TINYWIDTH * 2);
320 int dy = rand () % (maxh - TINYWIDTH * 2);
321 call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h);
328 bench_composite (char * testname,
337 pixman_image_t * src_img;
338 pixman_image_t * dst_img;
339 pixman_image_t * mask_img;
340 pixman_image_t * xsrc_img;
341 pixman_image_t * xdst_img;
342 pixman_image_t * xmask_img;
343 double t1, t2, t3, pix_cnt;
344 int64_t n, l1test_width, nlines;
345 double bytes_per_pix = 0;
347 pixman_composite_func_t func = pixman_image_composite_wrapper;
349 if (!(src_flags & SOLID_FLAG))
351 bytes_per_pix += (src_fmt >> 24) / 8.0;
352 src_img = pixman_image_create_bits (src_fmt,
356 xsrc_img = pixman_image_create_bits (src_fmt,
363 src_img = pixman_image_create_bits (src_fmt,
367 xsrc_img = pixman_image_create_bits (src_fmt,
371 pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL);
372 pixman_image_set_repeat (xsrc_img, PIXMAN_REPEAT_NORMAL);
375 bytes_per_pix += (dst_fmt >> 24) / 8.0;
376 dst_img = pixman_image_create_bits (dst_fmt,
383 if (!(mask_flags & SOLID_FLAG) && mask_fmt != PIXMAN_null)
385 bytes_per_pix += (mask_fmt >> 24) / ((op == PIXMAN_OP_SRC) ? 8.0 : 4.0);
386 mask_img = pixman_image_create_bits (mask_fmt,
390 xmask_img = pixman_image_create_bits (mask_fmt,
395 else if (mask_fmt != PIXMAN_null)
397 mask_img = pixman_image_create_bits (mask_fmt,
401 xmask_img = pixman_image_create_bits (mask_fmt,
405 pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL);
406 pixman_image_set_repeat (xmask_img, PIXMAN_REPEAT_NORMAL);
408 if ((mask_flags & CA_FLAG) && mask_fmt != PIXMAN_null)
410 pixman_image_set_component_alpha (mask_img, 1);
412 xdst_img = pixman_image_create_bits (dst_fmt,
418 printf ("%24s %c", testname, func != pixman_image_composite_wrapper ?
421 memcpy (src, dst, BUFSIZE);
422 memcpy (dst, src, BUFSIZE);
424 l1test_width = L1CACHE_SIZE / 8 - 64;
425 if (l1test_width < 1)
427 if (l1test_width > WIDTH - 64)
428 l1test_width = WIDTH - 64;
429 n = 1 + npix / (l1test_width * 8);
432 bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, 1);
435 bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1);
437 printf (" L1:%7.2f", (double)n * l1test_width * 1 /
438 ((t3 - t2) - (t2 - t1)) / 1000000.);
441 memcpy (src, dst, BUFSIZE);
442 memcpy (dst, src, BUFSIZE);
444 nlines = (L2CACHE_SIZE / l1test_width) /
445 ((PIXMAN_FORMAT_BPP(src_fmt) + PIXMAN_FORMAT_BPP(dst_fmt)) / 8);
448 n = 1 + npix / (l1test_width * nlines);
451 bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, nlines);
454 bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines);
456 printf (" L2:%7.2f", (double)n * l1test_width * nlines /
457 ((t3 - t2) - (t2 - t1)) / 1000000.);
460 memcpy (src, dst, BUFSIZE);
461 memcpy (dst, src, BUFSIZE);
463 n = 1 + npix / (WIDTH * HEIGHT);
466 bench_M (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
469 bench_M (op, src_img, mask_img, dst_img, n, func);
471 printf (" M:%6.2f (%6.2f%%)",
472 ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1))) / 1000000.,
473 ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) );
476 memcpy (src, dst, BUFSIZE);
477 memcpy (dst, src, BUFSIZE);
479 n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
482 pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
485 pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, func);
487 printf (" HT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
490 memcpy (src, dst, BUFSIZE);
491 memcpy (dst, src, BUFSIZE);
493 n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
496 pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty);
499 pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, func);
501 printf (" VT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
504 memcpy (src, dst, BUFSIZE);
505 memcpy (dst, src, BUFSIZE);
507 n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH);
510 pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT);
513 pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
515 printf (" R:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.);
518 memcpy (src, dst, BUFSIZE);
519 memcpy (dst, src, BUFSIZE);
521 n = 1 + npix / (16 * TINYWIDTH * TINYWIDTH);
524 pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT);
527 pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT);
529 printf (" RT:%6.2f (%4.0fKops/s)\n", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000., (double) n / ((t3 - t2) * 1000));
532 pixman_image_unref (mask_img);
533 pixman_image_unref (xmask_img);
535 pixman_image_unref (src_img);
536 pixman_image_unref (dst_img);
537 pixman_image_unref (xsrc_img);
538 pixman_image_unref (xdst_img);
541 #define PIXMAN_OP_OUT_REV (PIXMAN_OP_OUT_REVERSE)
555 { "add_8_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 },
556 { "add_n_8_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 },
557 { "add_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
558 { "add_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
559 { "add_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
560 { "add_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
561 { "add_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
562 { "add_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
563 { "add_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
564 { "add_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
565 { "add_n_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 },
566 { "add_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
567 { "add_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
568 { "add_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
569 { "add_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
570 { "add_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
571 { "add_n_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
572 { "add_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
573 { "add_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
574 { "add_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 },
575 { "add_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
576 { "add_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
577 { "add_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
578 { "add_8888_1555", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
579 { "add_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
580 { "add_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
581 { "add_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 },
582 { "add_1555_1555", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
583 { "add_0565_2x10", PIXMAN_r5g6b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
584 { "add_2a10_2a10", PIXMAN_a2r10g10b10, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
585 { "in_n_8_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_IN, PIXMAN_a8, 0, PIXMAN_a8 },
586 { "in_8_8", PIXMAN_a8, 0, PIXMAN_OP_IN, PIXMAN_null, 0, PIXMAN_a8 },
587 { "src_n_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
588 { "src_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
589 { "src_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
590 { "src_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
591 { "src_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
592 { "src_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
593 { "src_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
594 { "src_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
595 { "src_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
596 { "src_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 },
597 { "src_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r2g2b2 },
598 { "src_8888_2x10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 },
599 { "src_8888_2a10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 },
600 { "src_0888_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
601 { "src_0888_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
602 { "src_0888_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
603 { "src_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
604 { "src_x888_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
605 { "src_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
606 { "src_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
607 { "src_1555_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 },
608 { "src_0565_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
609 { "src_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
610 { "src_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
611 { "src_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
612 { "src_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
613 { "src_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
614 { "src_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
615 { "src_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
616 { "src_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
617 { "src_8888_8_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
618 { "src_0888_8_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
619 { "src_0888_8_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
620 { "src_0888_8_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
621 { "src_x888_8_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
622 { "src_x888_8_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
623 { "src_0565_8_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
624 { "src_1555_8_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
625 { "src_0565_8_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
626 { "over_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
627 { "over_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
628 { "over_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_r5g6b5 },
629 { "over_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a1r5g5b5 },
630 { "over_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_r5g6b5 },
631 { "over_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a8r8g8b8 },
632 { "over_8888_x888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_x8r8g8b8 },
633 { "over_x888_8_0565", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
634 { "over_x888_8_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
635 { "over_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
636 { "over_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
637 { "over_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 },
638 { "over_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 },
639 { "over_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
640 { "over_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
641 { "over_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 },
642 { "over_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 },
643 { "over_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 },
644 { "over_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 },
645 { "over_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 },
646 { "over_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 },
647 { "over_n_8888_4444_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a4r4g4b4 },
648 { "over_n_8888_2222_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r2g2b2 },
649 { "over_n_8888_2x10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x2r10g10b10 },
650 { "over_n_8888_2a10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r10g10b10 },
651 { "over_8888_n_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a8r8g8b8 },
652 { "over_8888_n_x888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_x8r8g8b8 },
653 { "over_8888_n_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_r5g6b5 },
654 { "over_8888_n_1555", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a1r5g5b5 },
655 { "over_x888_n_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a8r8g8b8 },
656 { "outrev_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_r5g6b5 },
657 { "outrev_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 },
658 { "outrev_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 },
659 { "outrev_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 },
660 { "outrev_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 },
661 { "outrev_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 },
662 { "outrev_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 },
663 { "outrev_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 },
667 main (int argc, char *argv[])
671 char *pattern = argc > 1 ? argv[1] : "all";
673 src = aligned_malloc (4096, BUFSIZE * 3);
674 memset (src, 0xCC, BUFSIZE * 3);
675 dst = src + (BUFSIZE / 4);
676 mask = dst + (BUFSIZE / 4);
678 printf ("Benchmark for a set of most commonly used functions\n");
680 printf ("All results are presented in millions of pixels per second\n");
681 printf ("L1 - small Xx1 rectangle (fitting L1 cache), always blitted at the same\n");
682 printf (" memory location with small drift in horizontal direction\n");
683 printf ("L2 - small XxY rectangle (fitting L2 cache), always blitted at the same\n");
684 printf (" memory location with small drift in horizontal direction\n");
685 printf ("M - large %dx%d rectangle, always blitted at the same\n",
687 printf (" memory location with small drift in horizontal direction\n");
688 printf ("HT - random rectangles with %dx%d average size are copied from\n",
689 TILEWIDTH, TILEWIDTH);
690 printf (" one %dx%d buffer to another, traversing from left to right\n",
692 printf (" and from top to bottom\n");
693 printf ("VT - random rectangles with %dx%d average size are copied from\n",
694 TILEWIDTH, TILEWIDTH);
695 printf (" one %dx%d buffer to another, traversing from top to bottom\n",
697 printf (" and from left to right\n");
698 printf ("R - random rectangles with %dx%d average size are copied from\n",
699 TILEWIDTH, TILEWIDTH);
700 printf (" random locations of one %dx%d buffer to another\n",
702 printf ("RT - as R, but %dx%d average sized rectangles are copied\n",
703 TINYWIDTH, TINYWIDTH);
705 bandwidth = x = bench_memcpy ();
706 printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n",
707 x / 1000000., x / 4000000);
710 for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
712 if (strcmp (pattern, "all") == 0 || strstr (tests_tbl[i].testname, pattern))
714 bench_composite (tests_tbl[i].testname,
715 tests_tbl[i].src_fmt,
716 tests_tbl[i].src_flags,
718 tests_tbl[i].mask_fmt,
719 tests_tbl[i].mask_flags,
720 tests_tbl[i].dst_fmt,