See header for documentation. */
| 505 | |
| 506 | /* See header for documentation. */ |
| 507 | size_t init_compute_averages( |
| 508 | const astcenc_image& img, |
| 509 | size_t alpha_kernel_radius, |
| 510 | const astcenc_swizzle& swz, |
| 511 | avg_args& ag |
| 512 | ) { |
| 513 | size_t size_x = img.dim_x; |
| 514 | size_t size_y = img.dim_y; |
| 515 | size_t size_z = img.dim_z; |
| 516 | |
| 517 | // Compute maximum block size and from that the working memory buffer size |
| 518 | size_t kernel_radius = alpha_kernel_radius; |
| 519 | size_t kerneldim = 2 * kernel_radius + 1; |
| 520 | |
| 521 | bool have_z = size_z > 1; |
| 522 | size_t max_blk_size_xy = have_z ? 16u : 32u; |
| 523 | |
| 524 | size_t max_blk_size_z_lim = have_z ? 16u : 1u; |
| 525 | size_t max_blk_size_z = astc::min(size_z, max_blk_size_z_lim); |
| 526 | |
| 527 | size_t max_padsize_xy = max_blk_size_xy + kerneldim; |
| 528 | size_t max_padsize_z = max_blk_size_z + (have_z ? kerneldim : 0); |
| 529 | |
| 530 | // Perform block-wise averages calculations across the image |
| 531 | // Initialize fields which are not populated until later |
| 532 | ag.arg.size_x = 0; |
| 533 | ag.arg.size_y = 0; |
| 534 | ag.arg.size_z = 0; |
| 535 | ag.arg.offset_x = 0; |
| 536 | ag.arg.offset_y = 0; |
| 537 | ag.arg.offset_z = 0; |
| 538 | ag.arg.work_memory = nullptr; |
| 539 | |
| 540 | ag.arg.img = &img; |
| 541 | ag.arg.swz = swz; |
| 542 | ag.arg.have_z = have_z; |
| 543 | ag.arg.alpha_kernel_radius = alpha_kernel_radius; |
| 544 | |
| 545 | ag.img_size_x = size_x; |
| 546 | ag.img_size_y = size_y; |
| 547 | ag.img_size_z = size_z; |
| 548 | ag.blk_size_xy = max_blk_size_xy; |
| 549 | ag.blk_size_z = max_blk_size_z; |
| 550 | ag.work_memory_size = 2 * max_padsize_xy * max_padsize_xy * max_padsize_z; |
| 551 | |
| 552 | // The parallel task count |
| 553 | size_t tasks_z = astc::get_block_count_safe(size_z, max_blk_size_z); |
| 554 | size_t tasks_y = astc::get_block_count_safe(size_y, max_blk_size_xy); |
| 555 | return tasks_z * tasks_y; |
| 556 | } |
| 557 | |
| 558 | #endif |
no test coverage detected