| 2419 | } |
| 2420 | |
| 2421 | bool basis_benchmark_etc1s_opencl(bool* pOpenCL_failed) |
| 2422 | { |
| 2423 | if (pOpenCL_failed) |
| 2424 | *pOpenCL_failed = false; |
| 2425 | |
| 2426 | if (!opencl_is_available()) |
| 2427 | { |
| 2428 | error_printf("basis_benchmark_etc1s_opencl: OpenCL support must be enabled first!\n"); |
| 2429 | return false; |
| 2430 | } |
| 2431 | |
| 2432 | const uint32_t W = 1024, H = 1024; |
| 2433 | basisu::vector<image> images; |
| 2434 | image& img = images.enlarge(1)->resize(W, H); |
| 2435 | |
| 2436 | const uint32_t NUM_RAND_LETTERS = 6000;// 40000; |
| 2437 | |
| 2438 | rand r; |
| 2439 | r.seed(200); |
| 2440 | |
| 2441 | for (uint32_t i = 0; i < NUM_RAND_LETTERS; i++) |
| 2442 | { |
| 2443 | uint32_t x = r.irand(0, W - 1), y = r.irand(0, H - 1); |
| 2444 | uint32_t sx = r.irand(1, 4), sy = r.irand(1, 4); |
| 2445 | color_rgba c(r.byte(), r.byte(), r.byte(), 255); |
| 2446 | |
| 2447 | img.debug_text(x, y, sx, sy, c, nullptr, false, "%c", static_cast<char>(r.irand(32, 127))); |
| 2448 | } |
| 2449 | |
| 2450 | //save_png("test.png", img); |
| 2451 | |
| 2452 | image_stats stats; |
| 2453 | |
| 2454 | uint32_t flags_and_quality = cFlagSRGB | cFlagThreaded | 255; |
| 2455 | size_t comp_size = 0; |
| 2456 | |
| 2457 | double best_cpu_time = 1e+9f, best_gpu_time = 1e+9f; |
| 2458 | |
| 2459 | const uint32_t TIMES_TO_ENCODE = 2; |
| 2460 | interval_timer tm; |
| 2461 | |
| 2462 | for (uint32_t i = 0; i < TIMES_TO_ENCODE; i++) |
| 2463 | { |
| 2464 | tm.start(); |
| 2465 | void* pComp_data = basis_compress( |
| 2466 | images, |
| 2467 | flags_and_quality, 1.0f, |
| 2468 | &comp_size, |
| 2469 | &stats); |
| 2470 | double cpu_time = tm.get_elapsed_secs(); |
| 2471 | if (!pComp_data) |
| 2472 | { |
| 2473 | error_printf("basis_benchmark_etc1s_opencl: basis_compress() failed (CPU)!\n"); |
| 2474 | return false; |
| 2475 | } |
| 2476 | |
| 2477 | best_cpu_time = minimum(best_cpu_time, cpu_time); |
| 2478 |
nothing calls this directly
no test coverage detected