void test_fill(uint32_t w, uint32_t h, uint32_t format) { PixmapPtr dest; C2D_RECT rect; c2d_ts_handle curTimestamp; DEBUG_MSG("fill: %04dx%04d-%08x", w, h, format); RD_START("fill", "%dx%d-%08x", w, h, format); dest = create_pixmap(w, h, format); rect.x = 1 + (w / 64); rect.y = 2 + (w / 32); rect.width = w - 2 * rect.x; rect.height = h - 2 * rect.y; // note: look for pattern 0xff556677 in memory to find cmdstream: CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); // second blit.. fill a sub-rect in center of surface: rect.x = (w - 10) / 2; rect.y = (h - 16) / 2; rect.width = 10; rect.height = 16; CHK(c2dFillSurface(dest->id, 0xff223344, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); RD_END(); dump_pixmap(dest, "fill-%04dx%04d-%08x.bmp", w, h, format); }
void test_copy(uint32_t w, uint32_t h, uint32_t format) { PixmapPtr src, dest; C2D_OBJECT blit = {}; C2D_RECT rect; c2d_ts_handle curTimestamp; DEBUG_MSG("----------------------------------------------------------------"); DEBUG_MSG("copy: %04dx%04d-%08x", w, h, format); RD_START("copy", "%dx%d format:%08x", w, h, format); dest = create_pixmap(w, h, format); src = create_pixmap(13, 17, format); rect.x = 1; rect.y = 2; rect.width = w - 2; rect.height = h - 3; CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); rect.x = 0; rect.y = 0; rect.width = 13; rect.height = 17; CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFlush(src->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); blit.surface_id = src->id; blit.config_mask = DEFAULT_BLIT_MASK; blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(13-1); blit.source_rect.height = FIXED(17-2); blit.target_rect.x = FIXED((w - 13) / 2); blit.target_rect.y = FIXED((h - 17) / 2); blit.target_rect.width = FIXED(13); blit.target_rect.height = FIXED(17); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); RD_END(); dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
void test_fill(uint32_t w, uint32_t h, uint32_t format, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) { PixmapPtr dest; C2D_RECT rect; c2d_ts_handle curTimestamp; DEBUG_MSG("----------------------------------------------------------------"); DEBUG_MSG("fill2: %04dx%04d-%08x-%d,%d,%d,%d", w, h, format, x1, y1, x2, y2); RD_START("fill2", "%dx%d-%08x-%d-%d-%d-%d", w, h, format, x1, y1, x2, y2); dest = create_pixmap(w, h, format); rect.x = x1; rect.y = y1; rect.width = x2 - x1; rect.height = y2 - y1; CHK(c2dFillSurface(dest->id, 0x00585a5d, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); RD_END(); dump_pixmap(dest, "fill-%04dx%04d-%08x.bmp", w, h, format); }
static void init(void) { /* create dummy pixmap to get initialization out of the way */ c2d_ts_handle curTimestamp; PixmapPtr tmp = create_pixmap(64, 64, xRGB); CHK(c2dFlush(tmp->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); }
int main(int argc, char **argv) { /* create dummy pixmap to get initialization out of the way */ c2d_ts_handle curTimestamp; PixmapPtr tmp = create_pixmap(64, 64, xRGB); CHK(c2dFlush(tmp->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); test_copy(63, 65, xRGB); test_copy(127, 260, xRGB); test_copy(62, 66, ARGB); test_copy(59, 69, C2D_COLOR_FORMAT_565_RGB); return 0; }
int main(int argc, char **argv) { /* create dummy pixmap to get initialization out of the way */ c2d_ts_handle curTimestamp; PixmapPtr tmp = create_pixmap(64, 64, xRGB); CHK(c2dFlush(tmp->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); test_fill(1920, 1080, xRGB, 0, 0, 1920, 1080); test_fill(1920, 1080, xRGB, 717, 395, 718, 685); /* test limits of x, y */ test_fill(1920, 1080, xRGB, 0x100, 0, 0x101, 0); test_fill(1920, 1080, xRGB, 0, 0x100, 0, 0x101); /* test limits of width, height */ test_fill(1920, 1080, xRGB, 0, 0, 0x100, 0); test_fill(1920, 1080, xRGB, 0, 0, 0, 0x100); return 0; }
int main(int argc, char **argv) { /* create dummy pixmap to get initialization out of the way */ c2d_ts_handle curTimestamp; PixmapPtr tmp = create_pixmap(64, 64, xRGB); CHK(c2dFlush(tmp->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); /* [ 1340.257] (II) freedreno(0): MSMCheckComposite:590 op:12: 0x2eb268 {20028888, 0} <- 0x2eb3a8 {08018000, 0} ((nil) {00000000, 0}) [ 1340.257] (II) freedreno(0): MSMPrepareComposite:694 0x2eb178 {35x8,256} <- 0x2eb2c8 {1024x320,1024} ((nil) {0x0,0}) [ 1340.258] (II) freedreno(0): MSMComposite:766 srcX=0 srcY=0 maskX=0 maskY=0 dstX=0 dstY=2 width=7 height=6 */ test_composite(C2D_ALPHA_BLEND_ADDITIVE, ARGB, 35, 8, A8, 1024, 320, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 6); return 0; }
void test_composite(const char *name, const struct blend_mode *blend, const struct format_mode *dst_format, uint32_t bw, uint32_t bh, const struct format_mode *src_format, uint32_t src_repeat, uint32_t sw, uint32_t sh, const struct format_mode *mask_format, uint32_t mask_repeat, uint32_t mw, uint32_t mh) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("%s: op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", name, blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); RD_START(name, "op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); blit.config_mask = DEFAULT_BLEND_MASK | blend->mode; dest = create_pixmap(1033, 1077, dst_format->format); if (src_repeat) { src = create_pixmap(1, 1, src_format->format); blit.config_mask |= C2D_SOURCE_TILE_BIT; } else { src = create_pixmap(sw, sh, src_format->format); } blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ if (mask_repeat) { mask = create_pixmap(1, 1, mask_format->format); blit.config_mask |= C2D_MASK_TILE_BIT; } else { mask = create_pixmap(mw, mh, mask_format->format); } blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } else { // TODO make redump not confused when one column has extra rows mask = create_pixmap(1, 1, ARGB); } blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(bw - blit.source_rect.x - 1); blit.source_rect.height = FIXED(bh - blit.source_rect.y - 2); blit.target_rect.x = FIXED((dest->width - sw) / 2); blit.target_rect.y = FIXED((dest->height - sh) / 2); blit.target_rect.width = blit.source_rect.width; blit.target_rect.height = blit.source_rect.height; CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
int main(int argc, char **argv) { uint32_t i, j; /* create dummy pixmap to get initialization out of the way */ c2d_ts_handle curTimestamp; PixmapPtr tmp = create_pixmap(64, 64, xRGB); CHK(c2dFlush(tmp->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); /* NOTE: my assumption here is that repeat, op, and color formats * are rather independent, so we don't need to dump every possible * combination (which would be a huge list).. possibly need to * sanity check this assumption, though.. */ /* test composite ops: */ for (i = 0; i < ARRAY_SIZE(blend_modes); i++) { test_composite("composite-op", &blend_modes[i], &format_modes[2], &format_modes[0], FALSE, NULL, FALSE); } /* test formats, by dst: */ for (i = 0; i < ARRAY_SIZE(format_modes); i++) { char name[32]; sprintf(name, "composite-dst-%s", format_modes[i].name); for (j = 0; j < ARRAY_SIZE(format_modes); j++) { // TODO add mask: test_composite(name, &blend_modes[4], &format_modes[i], &format_modes[j], FALSE, NULL, FALSE); } } /* test formats, by src: */ for (i = 0; i < ARRAY_SIZE(format_modes); i++) { char name[32]; sprintf(name, "composite-src-%s", format_modes[i].name); for (j = 0; j < ARRAY_SIZE(format_modes); j++) { // TODO add mask: test_composite(name, &blend_modes[4], &format_modes[j], &format_modes[i], FALSE, NULL, FALSE); } } /* test with/without mask: */ test_composite("composite-mask", &blend_modes[3], &format_modes[0], &format_modes[0], FALSE, NULL, FALSE); for (i = 0; i < ARRAY_SIZE(format_modes); i++) { test_composite("composite-mask", &blend_modes[3], &format_modes[0], &format_modes[0], FALSE, &format_modes[i], FALSE); } /* test repeat: */ // TODO add mask: test_composite("composite-repeat", &blend_modes[4], &format_modes[0], &format_modes[0], FALSE, NULL, FALSE); test_composite("composite-repeat", &blend_modes[4], &format_modes[0], &format_modes[0], TRUE, NULL, FALSE); return 0; }
void test_composite(uint32_t blend_mode, uint32_t dst_format, uint32_t dst_width, uint32_t dst_height, uint32_t src_format, uint32_t src_width, uint32_t src_height, uint32_t mask_format, uint32_t mask_width, uint32_t mask_height, uint32_t src_x, uint32_t src_y, uint32_t mask_x, uint32_t mask_y, uint32_t dst_x, uint32_t dst_y, uint32_t w, uint32_t h) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("composite2: blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); RD_START("composite2","blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); blit.config_mask = DEFAULT_BLEND_MASK | blend_mode; dest = create_pixmap(dst_width, dst_height, dst_format); src = create_pixmap(src_width, src_height, src_format); blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ mask = create_pixmap(mask_width, mask_height, mask_format); blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } blit.next = NULL; blit.source_rect.x = FIXED(src_x); blit.source_rect.y = FIXED(src_y); blit.source_rect.width = FIXED(w); blit.source_rect.height = FIXED(h); blit.target_rect.x = FIXED(dst_x); blit.target_rect.y = FIXED(dst_y); blit.target_rect.width = FIXED(w); blit.target_rect.height = FIXED(h); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
static void wait(uint32_t timestamp) { CHK(c2dWaitTimestamp((c2d_ts_handle)timestamp)); }
void test_multi(void) { PixmapPtr src, dest; C2D_OBJECT blit = {}; C2D_RECT rect; c2d_ts_handle curTimestamp; uint32_t w = 1920, h = 1080, format = xRGB; int i; DEBUG_MSG("multi: %04dx%04d-%08x", w, h, format); RD_START("multi", "%dx%d format:%08x", w, h, format); dest = create_pixmap(w, h, format); src = create_pixmap(w, h, format); for (i = 0; i < 200; i++ ) { rect.x = 1; rect.y = 2; rect.width = w - 2; rect.height = h - 3; CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); rect.x = 0; rect.y = 0; rect.width = 13; rect.height = 17; CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); blit.surface_id = src->id; blit.config_mask = DEFAULT_BLIT_MASK; blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(13-2); blit.source_rect.height = FIXED(17-4); blit.target_rect.x = FIXED((w - 13) / 2); blit.target_rect.y = FIXED((h - 17) / 2); blit.target_rect.width = blit.source_rect.width; blit.target_rect.height = blit.source_rect.height; CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); // well, identical copy twice is fine, and I'm lazy: CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); if (!(i % 16)) CHK(c2dWaitTimestamp(curTimestamp)); } free_pixmap(src); free_pixmap(dest); RD_END(); }