lowlevel-blt-bench.c revision f4f78bb6
11b18d63aSmrg/* 21b18d63aSmrg * Copyright © 2009 Nokia Corporation 31b18d63aSmrg * Copyright © 2010 Movial Creative Technologies Oy 41b18d63aSmrg * 51b18d63aSmrg * Permission is hereby granted, free of charge, to any person obtaining a 61b18d63aSmrg * copy of this software and associated documentation files (the "Software"), 71b18d63aSmrg * to deal in the Software without restriction, including without limitation 81b18d63aSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 91b18d63aSmrg * and/or sell copies of the Software, and to permit persons to whom the 101b18d63aSmrg * Software is furnished to do so, subject to the following conditions: 111b18d63aSmrg * 121b18d63aSmrg * The above copyright notice and this permission notice (including the next 131b18d63aSmrg * paragraph) shall be included in all copies or substantial portions of the 141b18d63aSmrg * Software. 151b18d63aSmrg * 161b18d63aSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 171b18d63aSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 181b18d63aSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 191b18d63aSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 201b18d63aSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 211b18d63aSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 221b18d63aSmrg * DEALINGS IN THE SOFTWARE. 231b18d63aSmrg */ 241b18d63aSmrg 251b18d63aSmrg#include <stdio.h> 261b18d63aSmrg#include <stdlib.h> 271b18d63aSmrg#include <string.h> 281b18d63aSmrg#include "utils.h" 291b18d63aSmrg 301b18d63aSmrg#define SOLID_FLAG 1 311b18d63aSmrg#define CA_FLAG 2 321b18d63aSmrg 331b18d63aSmrg#define L1CACHE_SIZE (8 * 1024) 341b18d63aSmrg#define L2CACHE_SIZE (128 * 1024) 351b18d63aSmrg 36f4f78bb6Smrg/* This is applied to both L1 and L2 tests - alternatively, you could 37f4f78bb6Smrg * parameterise bench_L or split it into two functions. It could be 38f4f78bb6Smrg * read at runtime on some architectures, but it only really matters 39f4f78bb6Smrg * that it's a number that's an integer divisor of both cacheline 40f4f78bb6Smrg * lengths, and further, it only really matters for caches that don't 41f4f78bb6Smrg * do allocate0on-write. */ 42f4f78bb6Smrg#define CACHELINE_LENGTH (32) /* bytes */ 43f4f78bb6Smrg 441b18d63aSmrg#define WIDTH 1920 451b18d63aSmrg#define HEIGHT 1080 461b18d63aSmrg#define BUFSIZE (WIDTH * HEIGHT * 4) 471b18d63aSmrg#define XWIDTH 256 481b18d63aSmrg#define XHEIGHT 256 491b18d63aSmrg#define TILEWIDTH 32 501b18d63aSmrg#define TINYWIDTH 8 511b18d63aSmrg 521b18d63aSmrg#define EXCLUDE_OVERHEAD 1 531b18d63aSmrg 541b18d63aSmrguint32_t *dst; 551b18d63aSmrguint32_t *src; 561b18d63aSmrguint32_t *mask; 571b18d63aSmrg 581b18d63aSmrgdouble bandwidth = 0; 591b18d63aSmrg 601b18d63aSmrgdouble 611b18d63aSmrgbench_memcpy () 621b18d63aSmrg{ 631b18d63aSmrg int64_t n = 0, total; 641b18d63aSmrg double t1, t2; 651b18d63aSmrg int x = 0; 661b18d63aSmrg 671b18d63aSmrg t1 = gettime (); 681b18d63aSmrg while (1) 691b18d63aSmrg { 701b18d63aSmrg memcpy (dst, src, BUFSIZE - 64); 711b18d63aSmrg memcpy (src, dst, BUFSIZE - 64); 721b18d63aSmrg n += 4 * (BUFSIZE - 64); 731b18d63aSmrg t2 = gettime (); 741b18d63aSmrg if (t2 - t1 > 0.5) 751b18d63aSmrg break; 761b18d63aSmrg } 771b18d63aSmrg n = total = n * 5; 781b18d63aSmrg t1 = gettime (); 791b18d63aSmrg while (n > 0) 801b18d63aSmrg { 811b18d63aSmrg if (++x >= 64) 821b18d63aSmrg x = 0; 831b18d63aSmrg memcpy ((char *)dst + 1, (char *)src + x, BUFSIZE - 64); 841b18d63aSmrg memcpy ((char *)src + 1, (char *)dst + x, BUFSIZE - 64); 851b18d63aSmrg n -= 4 * (BUFSIZE - 64); 861b18d63aSmrg } 871b18d63aSmrg t2 = gettime (); 881b18d63aSmrg return (double)total / (t2 - t1); 891b18d63aSmrg} 901b18d63aSmrg 919ad247e8Sjmcneillstatic pixman_bool_t use_scaling = FALSE; 929ad247e8Sjmcneillstatic pixman_filter_t filter = PIXMAN_FILTER_NEAREST; 939ad247e8Sjmcneill 949ad247e8Sjmcneill/* nearly 1x scale factor */ 959ad247e8Sjmcneillstatic pixman_transform_t m = 969ad247e8Sjmcneill{ 979ad247e8Sjmcneill { 989ad247e8Sjmcneill { pixman_fixed_1 + 1, 0, 0 }, 999ad247e8Sjmcneill { 0, pixman_fixed_1, 0 }, 1009ad247e8Sjmcneill { 0, 0, pixman_fixed_1 } 1019ad247e8Sjmcneill } 1029ad247e8Sjmcneill}; 1039ad247e8Sjmcneill 1041b18d63aSmrgstatic void 1051b18d63aSmrgpixman_image_composite_wrapper (pixman_implementation_t *impl, 1066ba797d6Smrg pixman_composite_info_t *info) 1071b18d63aSmrg{ 1089ad247e8Sjmcneill if (use_scaling) 1099ad247e8Sjmcneill { 1109ad247e8Sjmcneill pixman_image_set_filter (info->src_image, filter, NULL, 0); 1119ad247e8Sjmcneill pixman_image_set_transform(info->src_image, &m); 1129ad247e8Sjmcneill } 1136ba797d6Smrg pixman_image_composite (info->op, 1146ba797d6Smrg info->src_image, info->mask_image, info->dest_image, 1156ba797d6Smrg info->src_x, info->src_y, 1166ba797d6Smrg info->mask_x, info->mask_y, 1176ba797d6Smrg info->dest_x, info->dest_y, 1186ba797d6Smrg info->width, info->height); 1191b18d63aSmrg} 1201b18d63aSmrg 1211b18d63aSmrgstatic void 1221b18d63aSmrgpixman_image_composite_empty (pixman_implementation_t *impl, 1236ba797d6Smrg pixman_composite_info_t *info) 1241b18d63aSmrg{ 1259ad247e8Sjmcneill if (use_scaling) 1269ad247e8Sjmcneill { 1279ad247e8Sjmcneill pixman_image_set_filter (info->src_image, filter, NULL, 0); 1289ad247e8Sjmcneill pixman_image_set_transform(info->src_image, &m); 1299ad247e8Sjmcneill } 1306ba797d6Smrg pixman_image_composite (info->op, 1316ba797d6Smrg info->src_image, info->mask_image, info->dest_image, 1326ba797d6Smrg 0, 0, 0, 0, 0, 0, 1, 1); 1336ba797d6Smrg} 1346ba797d6Smrg 1356ba797d6Smrgstatic inline void 1366ba797d6Smrgcall_func (pixman_composite_func_t func, 1376ba797d6Smrg pixman_op_t op, 1386ba797d6Smrg pixman_image_t * src_image, 1396ba797d6Smrg pixman_image_t * mask_image, 1406ba797d6Smrg pixman_image_t * dest_image, 1416ba797d6Smrg int32_t src_x, 1426ba797d6Smrg int32_t src_y, 1436ba797d6Smrg int32_t mask_x, 1446ba797d6Smrg int32_t mask_y, 1456ba797d6Smrg int32_t dest_x, 1466ba797d6Smrg int32_t dest_y, 1476ba797d6Smrg int32_t width, 1486ba797d6Smrg int32_t height) 1496ba797d6Smrg{ 1506ba797d6Smrg pixman_composite_info_t info; 1516ba797d6Smrg 1526ba797d6Smrg info.op = op; 1536ba797d6Smrg info.src_image = src_image; 1546ba797d6Smrg info.mask_image = mask_image; 1556ba797d6Smrg info.dest_image = dest_image; 1566ba797d6Smrg info.src_x = src_x; 1576ba797d6Smrg info.src_y = src_y; 1586ba797d6Smrg info.mask_x = mask_x; 1596ba797d6Smrg info.mask_y = mask_y; 1606ba797d6Smrg info.dest_x = dest_x; 1616ba797d6Smrg info.dest_y = dest_y; 1626ba797d6Smrg info.width = width; 1636ba797d6Smrg info.height = height; 1646ba797d6Smrg 1656ba797d6Smrg func (0, &info); 1661b18d63aSmrg} 1671b18d63aSmrg 1681b18d63aSmrgvoid 1691b18d63aSmrgnoinline 1701b18d63aSmrgbench_L (pixman_op_t op, 1711b18d63aSmrg pixman_image_t * src_img, 1721b18d63aSmrg pixman_image_t * mask_img, 1731b18d63aSmrg pixman_image_t * dst_img, 1741b18d63aSmrg int64_t n, 1751b18d63aSmrg pixman_composite_func_t func, 1761b18d63aSmrg int width, 1771b18d63aSmrg int lines_count) 1781b18d63aSmrg{ 179f4f78bb6Smrg int64_t i, j, k; 1801b18d63aSmrg int x = 0; 1811b18d63aSmrg int q = 0; 1821b18d63aSmrg volatile int qx; 1831b18d63aSmrg 1841b18d63aSmrg for (i = 0; i < n; i++) 1851b18d63aSmrg { 186f4f78bb6Smrg /* For caches without allocate-on-write, we need to force the 187f4f78bb6Smrg * destination buffer back into the cache on each iteration, 188f4f78bb6Smrg * otherwise if they are evicted during the test, they remain 189f4f78bb6Smrg * uncached. This doesn't matter for tests which read the 190f4f78bb6Smrg * destination buffer, or for caches that do allocate-on-write, 191f4f78bb6Smrg * but in those cases this loop just adds constant time, which 192f4f78bb6Smrg * should be successfully cancelled out. 193f4f78bb6Smrg */ 194f4f78bb6Smrg for (j = 0; j < lines_count; j++) 195f4f78bb6Smrg { 196f4f78bb6Smrg for (k = 0; k < width + 62; k += CACHELINE_LENGTH / sizeof *dst) 197f4f78bb6Smrg { 198f4f78bb6Smrg q += dst[j * WIDTH + k]; 199f4f78bb6Smrg } 200f4f78bb6Smrg q += dst[j * WIDTH + width + 62]; 201f4f78bb6Smrg } 2021b18d63aSmrg if (++x >= 64) 2031b18d63aSmrg x = 0; 2046ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 63 - x, 0, width, lines_count); 2051b18d63aSmrg } 2061b18d63aSmrg qx = q; 2071b18d63aSmrg} 2081b18d63aSmrg 2091b18d63aSmrgvoid 2101b18d63aSmrgnoinline 2111b18d63aSmrgbench_M (pixman_op_t op, 2121b18d63aSmrg pixman_image_t * src_img, 2131b18d63aSmrg pixman_image_t * mask_img, 2141b18d63aSmrg pixman_image_t * dst_img, 2151b18d63aSmrg int64_t n, 2161b18d63aSmrg pixman_composite_func_t func) 2171b18d63aSmrg{ 2181b18d63aSmrg int64_t i; 2191b18d63aSmrg int x = 0; 2201b18d63aSmrg 2211b18d63aSmrg for (i = 0; i < n; i++) 2221b18d63aSmrg { 2231b18d63aSmrg if (++x >= 64) 2241b18d63aSmrg x = 0; 2256ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, x, 0, x, 0, 1, 0, WIDTH - 64, HEIGHT); 2261b18d63aSmrg } 2271b18d63aSmrg} 2281b18d63aSmrg 2291b18d63aSmrgdouble 2301b18d63aSmrgnoinline 2311b18d63aSmrgbench_HT (pixman_op_t op, 2321b18d63aSmrg pixman_image_t * src_img, 2331b18d63aSmrg pixman_image_t * mask_img, 2341b18d63aSmrg pixman_image_t * dst_img, 2351b18d63aSmrg int64_t n, 2361b18d63aSmrg pixman_composite_func_t func) 2371b18d63aSmrg{ 2381b18d63aSmrg double pix_cnt = 0; 2391b18d63aSmrg int x = 0; 2401b18d63aSmrg int y = 0; 2411b18d63aSmrg int64_t i; 2421b18d63aSmrg 2431b18d63aSmrg srand (0); 2441b18d63aSmrg for (i = 0; i < n; i++) 2451b18d63aSmrg { 2461b18d63aSmrg int w = (rand () % (TILEWIDTH * 2)) + 1; 2471b18d63aSmrg int h = (rand () % (TILEWIDTH * 2)) + 1; 2481b18d63aSmrg if (x + w > WIDTH) 2491b18d63aSmrg { 2501b18d63aSmrg x = 0; 2511b18d63aSmrg y += TILEWIDTH * 2; 2521b18d63aSmrg } 2531b18d63aSmrg if (y + h > HEIGHT) 2541b18d63aSmrg { 2551b18d63aSmrg y = 0; 2561b18d63aSmrg } 2576ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h); 2581b18d63aSmrg x += w; 2591b18d63aSmrg pix_cnt += w * h; 2601b18d63aSmrg } 2611b18d63aSmrg return pix_cnt; 2621b18d63aSmrg} 2631b18d63aSmrg 2641b18d63aSmrgdouble 2651b18d63aSmrgnoinline 2661b18d63aSmrgbench_VT (pixman_op_t op, 2671b18d63aSmrg pixman_image_t * src_img, 2681b18d63aSmrg pixman_image_t * mask_img, 2691b18d63aSmrg pixman_image_t * dst_img, 2701b18d63aSmrg int64_t n, 2711b18d63aSmrg pixman_composite_func_t func) 2721b18d63aSmrg{ 2731b18d63aSmrg double pix_cnt = 0; 2741b18d63aSmrg int x = 0; 2751b18d63aSmrg int y = 0; 2761b18d63aSmrg int64_t i; 2771b18d63aSmrg 2781b18d63aSmrg srand (0); 2791b18d63aSmrg for (i = 0; i < n; i++) 2801b18d63aSmrg { 2811b18d63aSmrg int w = (rand () % (TILEWIDTH * 2)) + 1; 2821b18d63aSmrg int h = (rand () % (TILEWIDTH * 2)) + 1; 2831b18d63aSmrg if (y + h > HEIGHT) 2841b18d63aSmrg { 2851b18d63aSmrg y = 0; 2861b18d63aSmrg x += TILEWIDTH * 2; 2871b18d63aSmrg } 2881b18d63aSmrg if (x + w > WIDTH) 2891b18d63aSmrg { 2901b18d63aSmrg x = 0; 2911b18d63aSmrg } 2926ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, x, y, x, y, x, y, w, h); 2931b18d63aSmrg y += h; 2941b18d63aSmrg pix_cnt += w * h; 2951b18d63aSmrg } 2961b18d63aSmrg return pix_cnt; 2971b18d63aSmrg} 2981b18d63aSmrg 2991b18d63aSmrgdouble 3001b18d63aSmrgnoinline 3011b18d63aSmrgbench_R (pixman_op_t op, 3021b18d63aSmrg pixman_image_t * src_img, 3031b18d63aSmrg pixman_image_t * mask_img, 3041b18d63aSmrg pixman_image_t * dst_img, 3051b18d63aSmrg int64_t n, 3061b18d63aSmrg pixman_composite_func_t func, 3071b18d63aSmrg int maxw, 3081b18d63aSmrg int maxh) 3091b18d63aSmrg{ 3101b18d63aSmrg double pix_cnt = 0; 3111b18d63aSmrg int64_t i; 3121b18d63aSmrg 3131b18d63aSmrg if (maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2) 3141b18d63aSmrg { 3151b18d63aSmrg printf("error: maxw <= TILEWIDTH * 2 || maxh <= TILEWIDTH * 2\n"); 3161b18d63aSmrg return 0; 3171b18d63aSmrg } 3181b18d63aSmrg 3191b18d63aSmrg srand (0); 3201b18d63aSmrg for (i = 0; i < n; i++) 3211b18d63aSmrg { 3221b18d63aSmrg int w = (rand () % (TILEWIDTH * 2)) + 1; 3231b18d63aSmrg int h = (rand () % (TILEWIDTH * 2)) + 1; 3241b18d63aSmrg int sx = rand () % (maxw - TILEWIDTH * 2); 3251b18d63aSmrg int sy = rand () % (maxh - TILEWIDTH * 2); 3261b18d63aSmrg int dx = rand () % (maxw - TILEWIDTH * 2); 3271b18d63aSmrg int dy = rand () % (maxh - TILEWIDTH * 2); 3286ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h); 3291b18d63aSmrg pix_cnt += w * h; 3301b18d63aSmrg } 3311b18d63aSmrg return pix_cnt; 3321b18d63aSmrg} 3331b18d63aSmrg 3341b18d63aSmrgdouble 3351b18d63aSmrgnoinline 3361b18d63aSmrgbench_RT (pixman_op_t op, 3371b18d63aSmrg pixman_image_t * src_img, 3381b18d63aSmrg pixman_image_t * mask_img, 3391b18d63aSmrg pixman_image_t * dst_img, 3401b18d63aSmrg int64_t n, 3411b18d63aSmrg pixman_composite_func_t func, 3421b18d63aSmrg int maxw, 3431b18d63aSmrg int maxh) 3441b18d63aSmrg{ 3451b18d63aSmrg double pix_cnt = 0; 3461b18d63aSmrg int64_t i; 3471b18d63aSmrg 3481b18d63aSmrg if (maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2) 3491b18d63aSmrg { 3501b18d63aSmrg printf("error: maxw <= TINYWIDTH * 2 || maxh <= TINYWIDTH * 2\n"); 3511b18d63aSmrg return 0; 3521b18d63aSmrg } 3531b18d63aSmrg 3541b18d63aSmrg srand (0); 3551b18d63aSmrg for (i = 0; i < n; i++) 3561b18d63aSmrg { 3571b18d63aSmrg int w = (rand () % (TINYWIDTH * 2)) + 1; 3581b18d63aSmrg int h = (rand () % (TINYWIDTH * 2)) + 1; 3591b18d63aSmrg int sx = rand () % (maxw - TINYWIDTH * 2); 3601b18d63aSmrg int sy = rand () % (maxh - TINYWIDTH * 2); 3611b18d63aSmrg int dx = rand () % (maxw - TINYWIDTH * 2); 3621b18d63aSmrg int dy = rand () % (maxh - TINYWIDTH * 2); 3636ba797d6Smrg call_func (func, op, src_img, mask_img, dst_img, sx, sy, sx, sy, dx, dy, w, h); 3641b18d63aSmrg pix_cnt += w * h; 3651b18d63aSmrg } 3661b18d63aSmrg return pix_cnt; 3671b18d63aSmrg} 3681b18d63aSmrg 3691b18d63aSmrgvoid 3701b18d63aSmrgbench_composite (char * testname, 3711b18d63aSmrg int src_fmt, 3721b18d63aSmrg int src_flags, 3731b18d63aSmrg int op, 3741b18d63aSmrg int mask_fmt, 3751b18d63aSmrg int mask_flags, 3761b18d63aSmrg int dst_fmt, 3771b18d63aSmrg double npix) 3781b18d63aSmrg{ 3791b18d63aSmrg pixman_image_t * src_img; 3801b18d63aSmrg pixman_image_t * dst_img; 3811b18d63aSmrg pixman_image_t * mask_img; 3821b18d63aSmrg pixman_image_t * xsrc_img; 3831b18d63aSmrg pixman_image_t * xdst_img; 3841b18d63aSmrg pixman_image_t * xmask_img; 3851b18d63aSmrg double t1, t2, t3, pix_cnt; 3861b18d63aSmrg int64_t n, l1test_width, nlines; 3871b18d63aSmrg double bytes_per_pix = 0; 388f4f78bb6Smrg pixman_bool_t bench_pixbuf = FALSE; 3891b18d63aSmrg 3901b18d63aSmrg pixman_composite_func_t func = pixman_image_composite_wrapper; 3911b18d63aSmrg 3921b18d63aSmrg if (!(src_flags & SOLID_FLAG)) 3931b18d63aSmrg { 3941b18d63aSmrg bytes_per_pix += (src_fmt >> 24) / 8.0; 3951b18d63aSmrg src_img = pixman_image_create_bits (src_fmt, 3961b18d63aSmrg WIDTH, HEIGHT, 3971b18d63aSmrg src, 3981b18d63aSmrg WIDTH * 4); 3991b18d63aSmrg xsrc_img = pixman_image_create_bits (src_fmt, 4001b18d63aSmrg XWIDTH, XHEIGHT, 4011b18d63aSmrg src, 4021b18d63aSmrg XWIDTH * 4); 4031b18d63aSmrg } 4041b18d63aSmrg else 4051b18d63aSmrg { 4061b18d63aSmrg src_img = pixman_image_create_bits (src_fmt, 4071b18d63aSmrg 1, 1, 4081b18d63aSmrg src, 4091b18d63aSmrg 4); 4101b18d63aSmrg xsrc_img = pixman_image_create_bits (src_fmt, 4111b18d63aSmrg 1, 1, 4121b18d63aSmrg src, 4131b18d63aSmrg 4); 4141b18d63aSmrg pixman_image_set_repeat (src_img, PIXMAN_REPEAT_NORMAL); 4151b18d63aSmrg pixman_image_set_repeat (xsrc_img, PIXMAN_REPEAT_NORMAL); 4161b18d63aSmrg } 4171b18d63aSmrg 4181b18d63aSmrg bytes_per_pix += (dst_fmt >> 24) / 8.0; 4191b18d63aSmrg dst_img = pixman_image_create_bits (dst_fmt, 4201b18d63aSmrg WIDTH, HEIGHT, 4211b18d63aSmrg dst, 4221b18d63aSmrg WIDTH * 4); 4231b18d63aSmrg 4241b18d63aSmrg mask_img = NULL; 4251b18d63aSmrg xmask_img = NULL; 426f4f78bb6Smrg if (strcmp (testname, "pixbuf") == 0 || strcmp (testname, "rpixbuf") == 0) 427f4f78bb6Smrg { 428f4f78bb6Smrg bench_pixbuf = TRUE; 429f4f78bb6Smrg } 4301b18d63aSmrg if (!(mask_flags & SOLID_FLAG) && mask_fmt != PIXMAN_null) 4311b18d63aSmrg { 4321b18d63aSmrg bytes_per_pix += (mask_fmt >> 24) / ((op == PIXMAN_OP_SRC) ? 8.0 : 4.0); 4331b18d63aSmrg mask_img = pixman_image_create_bits (mask_fmt, 4341b18d63aSmrg WIDTH, HEIGHT, 435f4f78bb6Smrg bench_pixbuf ? src : mask, 4361b18d63aSmrg WIDTH * 4); 4371b18d63aSmrg xmask_img = pixman_image_create_bits (mask_fmt, 4381b18d63aSmrg XWIDTH, XHEIGHT, 439f4f78bb6Smrg bench_pixbuf ? src : mask, 4401b18d63aSmrg XWIDTH * 4); 4411b18d63aSmrg } 4421b18d63aSmrg else if (mask_fmt != PIXMAN_null) 4431b18d63aSmrg { 4441b18d63aSmrg mask_img = pixman_image_create_bits (mask_fmt, 4451b18d63aSmrg 1, 1, 4461b18d63aSmrg mask, 4471b18d63aSmrg 4); 4481b18d63aSmrg xmask_img = pixman_image_create_bits (mask_fmt, 4491b18d63aSmrg 1, 1, 4501b18d63aSmrg mask, 4511b18d63aSmrg 4 * 4); 4521b18d63aSmrg pixman_image_set_repeat (mask_img, PIXMAN_REPEAT_NORMAL); 4531b18d63aSmrg pixman_image_set_repeat (xmask_img, PIXMAN_REPEAT_NORMAL); 4541b18d63aSmrg } 4551b18d63aSmrg if ((mask_flags & CA_FLAG) && mask_fmt != PIXMAN_null) 4561b18d63aSmrg { 4571b18d63aSmrg pixman_image_set_component_alpha (mask_img, 1); 4581b18d63aSmrg } 4591b18d63aSmrg xdst_img = pixman_image_create_bits (dst_fmt, 4601b18d63aSmrg XWIDTH, XHEIGHT, 4611b18d63aSmrg dst, 4621b18d63aSmrg XWIDTH * 4); 4631b18d63aSmrg 4641b18d63aSmrg 4651b18d63aSmrg printf ("%24s %c", testname, func != pixman_image_composite_wrapper ? 4661b18d63aSmrg '-' : '='); 4671b18d63aSmrg 4681b18d63aSmrg memcpy (dst, src, BUFSIZE); 469f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 4701b18d63aSmrg 4711b18d63aSmrg l1test_width = L1CACHE_SIZE / 8 - 64; 4721b18d63aSmrg if (l1test_width < 1) 4731b18d63aSmrg l1test_width = 1; 4741b18d63aSmrg if (l1test_width > WIDTH - 64) 4751b18d63aSmrg l1test_width = WIDTH - 64; 4761b18d63aSmrg n = 1 + npix / (l1test_width * 8); 4771b18d63aSmrg t1 = gettime (); 4781b18d63aSmrg#if EXCLUDE_OVERHEAD 4791b18d63aSmrg bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, 1); 4801b18d63aSmrg#endif 4811b18d63aSmrg t2 = gettime (); 4821b18d63aSmrg bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, 1); 4831b18d63aSmrg t3 = gettime (); 4841b18d63aSmrg printf (" L1:%7.2f", (double)n * l1test_width * 1 / 4851b18d63aSmrg ((t3 - t2) - (t2 - t1)) / 1000000.); 4861b18d63aSmrg fflush (stdout); 4871b18d63aSmrg 4881b18d63aSmrg memcpy (dst, src, BUFSIZE); 489f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 4901b18d63aSmrg 4911b18d63aSmrg nlines = (L2CACHE_SIZE / l1test_width) / 4921b18d63aSmrg ((PIXMAN_FORMAT_BPP(src_fmt) + PIXMAN_FORMAT_BPP(dst_fmt)) / 8); 4931b18d63aSmrg if (nlines < 1) 4941b18d63aSmrg nlines = 1; 4951b18d63aSmrg n = 1 + npix / (l1test_width * nlines); 4961b18d63aSmrg t1 = gettime (); 4971b18d63aSmrg#if EXCLUDE_OVERHEAD 4981b18d63aSmrg bench_L (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, l1test_width, nlines); 4991b18d63aSmrg#endif 5001b18d63aSmrg t2 = gettime (); 5011b18d63aSmrg bench_L (op, src_img, mask_img, dst_img, n, func, l1test_width, nlines); 5021b18d63aSmrg t3 = gettime (); 5031b18d63aSmrg printf (" L2:%7.2f", (double)n * l1test_width * nlines / 5041b18d63aSmrg ((t3 - t2) - (t2 - t1)) / 1000000.); 5051b18d63aSmrg fflush (stdout); 5061b18d63aSmrg 5071b18d63aSmrg memcpy (dst, src, BUFSIZE); 508f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 5091b18d63aSmrg 5101b18d63aSmrg n = 1 + npix / (WIDTH * HEIGHT); 5111b18d63aSmrg t1 = gettime (); 5121b18d63aSmrg#if EXCLUDE_OVERHEAD 5131b18d63aSmrg bench_M (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty); 5141b18d63aSmrg#endif 5151b18d63aSmrg t2 = gettime (); 5161b18d63aSmrg bench_M (op, src_img, mask_img, dst_img, n, func); 5171b18d63aSmrg t3 = gettime (); 5181b18d63aSmrg printf (" M:%6.2f (%6.2f%%)", 5191b18d63aSmrg ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1))) / 1000000., 5201b18d63aSmrg ((double)n * (WIDTH - 64) * HEIGHT / ((t3 - t2) - (t2 - t1)) * bytes_per_pix) * (100.0 / bandwidth) ); 5211b18d63aSmrg fflush (stdout); 5221b18d63aSmrg 5231b18d63aSmrg memcpy (dst, src, BUFSIZE); 524f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 5251b18d63aSmrg 5261b18d63aSmrg n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH); 5271b18d63aSmrg t1 = gettime (); 5281b18d63aSmrg#if EXCLUDE_OVERHEAD 5291b18d63aSmrg pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty); 5301b18d63aSmrg#endif 5311b18d63aSmrg t2 = gettime (); 5321b18d63aSmrg pix_cnt = bench_HT (op, src_img, mask_img, dst_img, n, func); 5331b18d63aSmrg t3 = gettime (); 5341b18d63aSmrg printf (" HT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.); 5351b18d63aSmrg fflush (stdout); 5361b18d63aSmrg 5371b18d63aSmrg memcpy (dst, src, BUFSIZE); 538f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 5391b18d63aSmrg 5401b18d63aSmrg n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH); 5411b18d63aSmrg t1 = gettime (); 5421b18d63aSmrg#if EXCLUDE_OVERHEAD 5431b18d63aSmrg pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty); 5441b18d63aSmrg#endif 5451b18d63aSmrg t2 = gettime (); 5461b18d63aSmrg pix_cnt = bench_VT (op, src_img, mask_img, dst_img, n, func); 5471b18d63aSmrg t3 = gettime (); 5481b18d63aSmrg printf (" VT:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.); 5491b18d63aSmrg fflush (stdout); 5501b18d63aSmrg 5511b18d63aSmrg memcpy (dst, src, BUFSIZE); 552f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 5531b18d63aSmrg 5541b18d63aSmrg n = 1 + npix / (8 * TILEWIDTH * TILEWIDTH); 5551b18d63aSmrg t1 = gettime (); 5561b18d63aSmrg#if EXCLUDE_OVERHEAD 5571b18d63aSmrg pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT); 5581b18d63aSmrg#endif 5591b18d63aSmrg t2 = gettime (); 5601b18d63aSmrg pix_cnt = bench_R (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT); 5611b18d63aSmrg t3 = gettime (); 5621b18d63aSmrg printf (" R:%6.2f", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000.); 5631b18d63aSmrg fflush (stdout); 5641b18d63aSmrg 5651b18d63aSmrg memcpy (dst, src, BUFSIZE); 566f4f78bb6Smrg memcpy (src, dst, BUFSIZE); 5671b18d63aSmrg 5681b18d63aSmrg n = 1 + npix / (16 * TINYWIDTH * TINYWIDTH); 5691b18d63aSmrg t1 = gettime (); 5701b18d63aSmrg#if EXCLUDE_OVERHEAD 5711b18d63aSmrg pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, pixman_image_composite_empty, WIDTH, HEIGHT); 5721b18d63aSmrg#endif 5731b18d63aSmrg t2 = gettime (); 5741b18d63aSmrg pix_cnt = bench_RT (op, src_img, mask_img, dst_img, n, func, WIDTH, HEIGHT); 5751b18d63aSmrg t3 = gettime (); 5761b18d63aSmrg printf (" RT:%6.2f (%4.0fKops/s)\n", (double)pix_cnt / ((t3 - t2) - (t2 - t1)) / 1000000., (double) n / ((t3 - t2) * 1000)); 5771b18d63aSmrg 5781b18d63aSmrg if (mask_img) { 5791b18d63aSmrg pixman_image_unref (mask_img); 5801b18d63aSmrg pixman_image_unref (xmask_img); 5811b18d63aSmrg } 5821b18d63aSmrg pixman_image_unref (src_img); 5831b18d63aSmrg pixman_image_unref (dst_img); 5841b18d63aSmrg pixman_image_unref (xsrc_img); 5851b18d63aSmrg pixman_image_unref (xdst_img); 5861b18d63aSmrg} 5871b18d63aSmrg 5881b18d63aSmrg#define PIXMAN_OP_OUT_REV (PIXMAN_OP_OUT_REVERSE) 5891b18d63aSmrg 5901b18d63aSmrgstruct 5911b18d63aSmrg{ 5921b18d63aSmrg char *testname; 5931b18d63aSmrg int src_fmt; 5941b18d63aSmrg int src_flags; 5951b18d63aSmrg int op; 5961b18d63aSmrg int mask_fmt; 5971b18d63aSmrg int mask_flags; 5981b18d63aSmrg int dst_fmt; 5991b18d63aSmrg} 6001b18d63aSmrgtests_tbl[] = 6011b18d63aSmrg{ 6021b18d63aSmrg { "add_8_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 }, 6031b18d63aSmrg { "add_n_8_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8 }, 6041b18d63aSmrg { "add_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6051b18d63aSmrg { "add_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 6061b18d63aSmrg { "add_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6071b18d63aSmrg { "add_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 }, 6081b18d63aSmrg { "add_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 }, 6091b18d63aSmrg { "add_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 }, 6101b18d63aSmrg { "add_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 }, 6111b18d63aSmrg { "add_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 }, 6121b18d63aSmrg { "add_n_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 }, 6131b18d63aSmrg { "add_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6141b18d63aSmrg { "add_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6151b18d63aSmrg { "add_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6161b18d63aSmrg { "add_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 6171b18d63aSmrg { "add_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 }, 6181b18d63aSmrg { "add_n_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 }, 6191b18d63aSmrg { "add_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x2r10g10b10 }, 6201b18d63aSmrg { "add_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r10g10b10 }, 6211b18d63aSmrg { "add_8_8", PIXMAN_a8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8 }, 6221b18d63aSmrg { "add_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6231b18d63aSmrg { "add_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6241b18d63aSmrg { "add_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6251b18d63aSmrg { "add_8888_1555", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 6261b18d63aSmrg { "add_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a4r4g4b4 }, 6271b18d63aSmrg { "add_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r2g2b2 }, 6281b18d63aSmrg { "add_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6291b18d63aSmrg { "add_1555_1555", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 6301b18d63aSmrg { "add_0565_2x10", PIXMAN_r5g6b5, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_x2r10g10b10 }, 6311b18d63aSmrg { "add_2a10_2a10", PIXMAN_a2r10g10b10, 0, PIXMAN_OP_ADD, PIXMAN_null, 0, PIXMAN_a2r10g10b10 }, 6329ad247e8Sjmcneill { "in_n_8_8", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_IN, PIXMAN_a8, 0, PIXMAN_a8 }, 6339ad247e8Sjmcneill { "in_8_8", PIXMAN_a8, 0, PIXMAN_OP_IN, PIXMAN_null, 0, PIXMAN_a8 }, 6341b18d63aSmrg { "src_n_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r2g2b2 }, 6351b18d63aSmrg { "src_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6361b18d63aSmrg { "src_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 6371b18d63aSmrg { "src_n_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 }, 6381b18d63aSmrg { "src_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6391b18d63aSmrg { "src_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6401b18d63aSmrg { "src_n_2x10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 }, 6411b18d63aSmrg { "src_n_2a10", PIXMAN_a2r10g10b10, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 }, 6421b18d63aSmrg { "src_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 643f4f78bb6Smrg { "src_0565_8888", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6441b18d63aSmrg { "src_8888_4444", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a4r4g4b4 }, 6451b18d63aSmrg { "src_8888_2222", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r2g2b2 }, 6461b18d63aSmrg { "src_8888_2x10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x2r10g10b10 }, 6471b18d63aSmrg { "src_8888_2a10", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a2r10g10b10 }, 6481b18d63aSmrg { "src_0888_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6491b18d63aSmrg { "src_0888_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6501b18d63aSmrg { "src_0888_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 651f4f78bb6Smrg { "src_0888_8888_rev", PIXMAN_b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 652f4f78bb6Smrg { "src_0888_0565_rev", PIXMAN_b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6531b18d63aSmrg { "src_x888_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6541b18d63aSmrg { "src_x888_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6551b18d63aSmrg { "src_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6561b18d63aSmrg { "src_0565_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6571b18d63aSmrg { "src_1555_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6581b18d63aSmrg { "src_0565_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 659f4f78bb6Smrg { "src_8_8", PIXMAN_a8, 0, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8 }, 660f4f78bb6Smrg { "src_n_8", PIXMAN_a8, 1, PIXMAN_OP_SRC, PIXMAN_null, 0, PIXMAN_a8 }, 6611b18d63aSmrg { "src_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6621b18d63aSmrg { "src_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 }, 6631b18d63aSmrg { "src_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 }, 6641b18d63aSmrg { "src_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 }, 6651b18d63aSmrg { "src_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 6661b18d63aSmrg { "src_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6671b18d63aSmrg { "src_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 }, 6681b18d63aSmrg { "src_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 }, 6691b18d63aSmrg { "src_8888_8_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6701b18d63aSmrg { "src_0888_8_0565", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6711b18d63aSmrg { "src_0888_8_8888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6721b18d63aSmrg { "src_0888_8_x888", PIXMAN_r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 6731b18d63aSmrg { "src_x888_8_x888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 6741b18d63aSmrg { "src_x888_8_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6751b18d63aSmrg { "src_0565_8_0565", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6761b18d63aSmrg { "src_1555_8_0565", PIXMAN_a1r5g5b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6771b18d63aSmrg { "src_0565_8_1555", PIXMAN_r5g6b5, 0, PIXMAN_OP_SRC, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 }, 6781b18d63aSmrg { "over_n_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6791b18d63aSmrg { "over_n_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6801b18d63aSmrg { "over_n_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6811b18d63aSmrg { "over_n_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a1r5g5b5 }, 6821b18d63aSmrg { "over_8888_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_r5g6b5 }, 6839ad247e8Sjmcneill { "over_8888_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 6841b18d63aSmrg { "over_8888_x888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_null, 0, PIXMAN_x8r8g8b8 }, 6856ba797d6Smrg { "over_x888_8_0565", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6869ad247e8Sjmcneill { "over_x888_8_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6871b18d63aSmrg { "over_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 6881b18d63aSmrg { "over_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 }, 6891b18d63aSmrg { "over_n_8_4444", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a4r4g4b4 }, 6901b18d63aSmrg { "over_n_8_2222", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r2g2b2 }, 6911b18d63aSmrg { "over_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 6921b18d63aSmrg { "over_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 6931b18d63aSmrg { "over_n_8_2x10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_x2r10g10b10 }, 6941b18d63aSmrg { "over_n_8_2a10", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8, 0, PIXMAN_a2r10g10b10 }, 6951b18d63aSmrg { "over_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 }, 6961b18d63aSmrg { "over_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 }, 6971b18d63aSmrg { "over_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 }, 6981b18d63aSmrg { "over_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 }, 6991b18d63aSmrg { "over_n_8888_4444_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a4r4g4b4 }, 7001b18d63aSmrg { "over_n_8888_2222_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r2g2b2 }, 7011b18d63aSmrg { "over_n_8888_2x10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_x2r10g10b10 }, 7021b18d63aSmrg { "over_n_8888_2a10_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OVER, PIXMAN_a8r8g8b8, 2, PIXMAN_a2r10g10b10 }, 7031b18d63aSmrg { "over_8888_n_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a8r8g8b8 }, 7041b18d63aSmrg { "over_8888_n_x888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_x8r8g8b8 }, 7051b18d63aSmrg { "over_8888_n_0565", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_r5g6b5 }, 7061b18d63aSmrg { "over_8888_n_1555", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a1r5g5b5 }, 7079ad247e8Sjmcneill { "over_x888_n_8888", PIXMAN_x8r8g8b8, 0, PIXMAN_OP_OVER, PIXMAN_a8, 1, PIXMAN_a8r8g8b8 }, 7081b18d63aSmrg { "outrev_n_8_0565", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_r5g6b5 }, 7091b18d63aSmrg { "outrev_n_8_1555", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_a1r5g5b5 }, 7101b18d63aSmrg { "outrev_n_8_x888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_x8r8g8b8 }, 7111b18d63aSmrg { "outrev_n_8_8888", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8, 0, PIXMAN_a8r8g8b8 }, 7121b18d63aSmrg { "outrev_n_8888_0565_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_r5g6b5 }, 7131b18d63aSmrg { "outrev_n_8888_1555_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a1r5g5b5 }, 7141b18d63aSmrg { "outrev_n_8888_x888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_x8r8g8b8 }, 7151b18d63aSmrg { "outrev_n_8888_8888_ca", PIXMAN_a8r8g8b8, 1, PIXMAN_OP_OUT_REV, PIXMAN_a8r8g8b8, 2, PIXMAN_a8r8g8b8 }, 7169ad247e8Sjmcneill { "over_reverse_n_8888", PIXMAN_a8r8g8b8, 0, PIXMAN_OP_OVER_REVERSE, PIXMAN_null, 0, PIXMAN_a8r8g8b8 }, 717f4f78bb6Smrg { "pixbuf", PIXMAN_x8b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_a8b8g8r8, 0, PIXMAN_a8r8g8b8 }, 718f4f78bb6Smrg { "rpixbuf", PIXMAN_x8b8g8r8, 0, PIXMAN_OP_SRC, PIXMAN_a8b8g8r8, 0, PIXMAN_a8b8g8r8 }, 7191b18d63aSmrg}; 7201b18d63aSmrg 7211b18d63aSmrgint 7221b18d63aSmrgmain (int argc, char *argv[]) 7231b18d63aSmrg{ 7241b18d63aSmrg double x; 7251b18d63aSmrg int i; 7269ad247e8Sjmcneill const char *pattern = NULL; 7279ad247e8Sjmcneill for (i = 1; i < argc; i++) 7289ad247e8Sjmcneill { 7299ad247e8Sjmcneill if (argv[i][0] == '-') 7309ad247e8Sjmcneill { 7319ad247e8Sjmcneill if (strchr (argv[i] + 1, 'b')) 7329ad247e8Sjmcneill { 7339ad247e8Sjmcneill use_scaling = TRUE; 7349ad247e8Sjmcneill filter = PIXMAN_FILTER_BILINEAR; 7359ad247e8Sjmcneill } 7369ad247e8Sjmcneill else if (strchr (argv[i] + 1, 'n')) 7379ad247e8Sjmcneill { 7389ad247e8Sjmcneill use_scaling = TRUE; 7399ad247e8Sjmcneill filter = PIXMAN_FILTER_NEAREST; 7409ad247e8Sjmcneill } 7419ad247e8Sjmcneill } 7429ad247e8Sjmcneill else 7439ad247e8Sjmcneill { 7449ad247e8Sjmcneill pattern = argv[i]; 7459ad247e8Sjmcneill } 7469ad247e8Sjmcneill } 7479ad247e8Sjmcneill 7489ad247e8Sjmcneill if (!pattern) 7499ad247e8Sjmcneill { 7509ad247e8Sjmcneill printf ("Usage: lowlevel-blt-bench [-b] [-n] pattern\n"); 7519ad247e8Sjmcneill printf (" -n : benchmark nearest scaling\n"); 7529ad247e8Sjmcneill printf (" -b : benchmark bilinear scaling\n"); 7539ad247e8Sjmcneill return 1; 7549ad247e8Sjmcneill } 7551b18d63aSmrg 7561b18d63aSmrg src = aligned_malloc (4096, BUFSIZE * 3); 7571b18d63aSmrg memset (src, 0xCC, BUFSIZE * 3); 7581b18d63aSmrg dst = src + (BUFSIZE / 4); 7591b18d63aSmrg mask = dst + (BUFSIZE / 4); 7601b18d63aSmrg 7611b18d63aSmrg printf ("Benchmark for a set of most commonly used functions\n"); 7621b18d63aSmrg printf ("---\n"); 7631b18d63aSmrg printf ("All results are presented in millions of pixels per second\n"); 7641b18d63aSmrg printf ("L1 - small Xx1 rectangle (fitting L1 cache), always blitted at the same\n"); 7651b18d63aSmrg printf (" memory location with small drift in horizontal direction\n"); 7661b18d63aSmrg printf ("L2 - small XxY rectangle (fitting L2 cache), always blitted at the same\n"); 7671b18d63aSmrg printf (" memory location with small drift in horizontal direction\n"); 7681b18d63aSmrg printf ("M - large %dx%d rectangle, always blitted at the same\n", 7691b18d63aSmrg WIDTH - 64, HEIGHT); 7701b18d63aSmrg printf (" memory location with small drift in horizontal direction\n"); 7711b18d63aSmrg printf ("HT - random rectangles with %dx%d average size are copied from\n", 7721b18d63aSmrg TILEWIDTH, TILEWIDTH); 7731b18d63aSmrg printf (" one %dx%d buffer to another, traversing from left to right\n", 7741b18d63aSmrg WIDTH, HEIGHT); 7751b18d63aSmrg printf (" and from top to bottom\n"); 7761b18d63aSmrg printf ("VT - random rectangles with %dx%d average size are copied from\n", 7771b18d63aSmrg TILEWIDTH, TILEWIDTH); 7781b18d63aSmrg printf (" one %dx%d buffer to another, traversing from top to bottom\n", 7791b18d63aSmrg WIDTH, HEIGHT); 7801b18d63aSmrg printf (" and from left to right\n"); 7811b18d63aSmrg printf ("R - random rectangles with %dx%d average size are copied from\n", 7821b18d63aSmrg TILEWIDTH, TILEWIDTH); 7831b18d63aSmrg printf (" random locations of one %dx%d buffer to another\n", 7841b18d63aSmrg WIDTH, HEIGHT); 7851b18d63aSmrg printf ("RT - as R, but %dx%d average sized rectangles are copied\n", 7861b18d63aSmrg TINYWIDTH, TINYWIDTH); 7871b18d63aSmrg printf ("---\n"); 7881b18d63aSmrg bandwidth = x = bench_memcpy (); 7891b18d63aSmrg printf ("reference memcpy speed = %.1fMB/s (%.1fMP/s for 32bpp fills)\n", 7901b18d63aSmrg x / 1000000., x / 4000000); 7919ad247e8Sjmcneill if (use_scaling) 7929ad247e8Sjmcneill { 7939ad247e8Sjmcneill printf ("---\n"); 7949ad247e8Sjmcneill if (filter == PIXMAN_FILTER_BILINEAR) 7959ad247e8Sjmcneill printf ("BILINEAR scaling\n"); 7969ad247e8Sjmcneill else if (filter == PIXMAN_FILTER_NEAREST) 7979ad247e8Sjmcneill printf ("NEAREST scaling\n"); 7989ad247e8Sjmcneill else 7999ad247e8Sjmcneill printf ("UNKNOWN scaling\n"); 8009ad247e8Sjmcneill } 8011b18d63aSmrg printf ("---\n"); 8021b18d63aSmrg 8039ad247e8Sjmcneill for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++) 8041b18d63aSmrg { 805f4f78bb6Smrg if (strcmp (pattern, "all") == 0 || strcmp (tests_tbl[i].testname, pattern) == 0) 8061b18d63aSmrg { 8071b18d63aSmrg bench_composite (tests_tbl[i].testname, 8081b18d63aSmrg tests_tbl[i].src_fmt, 8091b18d63aSmrg tests_tbl[i].src_flags, 8101b18d63aSmrg tests_tbl[i].op, 8111b18d63aSmrg tests_tbl[i].mask_fmt, 8121b18d63aSmrg tests_tbl[i].mask_flags, 8131b18d63aSmrg tests_tbl[i].dst_fmt, 8141b18d63aSmrg bandwidth/8); 8151b18d63aSmrg } 8161b18d63aSmrg } 8171b18d63aSmrg 8181b18d63aSmrg free (src); 8191b18d63aSmrg return 0; 8201b18d63aSmrg} 821