• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:config

1 // SPDX-License-Identifier: Apache-2.0
2 // ----------------------------------------------------------------------------
3 // Copyright 2011-2024 Arm Limited
9 // http://www.apache.org/licenses/LICENSE-2.0
16 // ----------------------------------------------------------------------------
140 * stored and reloaded as a 32-bit IEEE-754 float with round-to-nearest rounding. This is always the
141 * case in an IEEE-754 compliant system, however not every system or compilation mode is actually
142 * IEEE-754 compliant. This normally fails if the code is compiled with fast math enabled.
151 float q = p.f - 12582912.0f; in validate_cpu_float()
162 * @brief Validate config profile.
353 * Validate that an incoming configuration is in-spec.
358 * for out-of-range inputs in this case.
362 * @param[in,out] config The input compressor configuration.
367 astcenc_config &config in validate_config() argument
371 status = validate_profile(config.profile); in validate_config()
377 status = validate_flags(config.profile, config.flags); in validate_config()
383 status = validate_block_size(config.block_x, config.block_y, config.block_z); in validate_config()
390 // Decompress-only builds only support decompress-only contexts in validate_config()
391 if (!(config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)) in validate_config()
397 config.rgbm_m_scale = astc::max(config.rgbm_m_scale, 1.0f); in validate_config()
399 config.tune_partition_count_limit = astc::clamp(config.tune_partition_count_limit, 1u, 4u); in validate_config()
400config.tune_2partition_index_limit = astc::clamp(config.tune_2partition_index_limit, 1u, BLOCK_MAX… in validate_config()
401config.tune_3partition_index_limit = astc::clamp(config.tune_3partition_index_limit, 1u, BLOCK_MAX… in validate_config()
402config.tune_4partition_index_limit = astc::clamp(config.tune_4partition_index_limit, 1u, BLOCK_MAX… in validate_config()
403 config.tune_block_mode_limit = astc::clamp(config.tune_block_mode_limit, 1u, 100u); in validate_config()
404 config.tune_refinement_limit = astc::max(config.tune_refinement_limit, 1u); in validate_config()
405config.tune_candidate_limit = astc::clamp(config.tune_candidate_limit, 1u, TUNE_MAX_TRIAL_CANDIDAT… in validate_config()
406config.tune_2partitioning_candidate_limit = astc::clamp(config.tune_2partitioning_candidate_limit,… in validate_config()
407config.tune_3partitioning_candidate_limit = astc::clamp(config.tune_3partitioning_candidate_limit,… in validate_config()
408config.tune_4partitioning_candidate_limit = astc::clamp(config.tune_4partitioning_candidate_limit,… in validate_config()
409 config.tune_db_limit = astc::max(config.tune_db_limit, 0.0f); in validate_config()
410 config.tune_mse_overshoot = astc::max(config.tune_mse_overshoot, 1.0f); in validate_config()
411config.tune_2partition_early_out_limit_factor = astc::max(config.tune_2partition_early_out_limit_f… in validate_config()
412config.tune_3partition_early_out_limit_factor = astc::max(config.tune_3partition_early_out_limit_f… in validate_config()
413config.tune_2plane_early_out_limit_correlation = astc::max(config.tune_2plane_early_out_limit_corr… in validate_config()
416 float max_weight = astc::max(astc::max(config.cw_r_weight, config.cw_g_weight), in validate_config()
417 astc::max(config.cw_b_weight, config.cw_a_weight)); in validate_config()
421 config.cw_r_weight = astc::max(config.cw_r_weight, max_weight); in validate_config()
422 config.cw_g_weight = astc::max(config.cw_g_weight, max_weight); in validate_config()
423 config.cw_b_weight = astc::max(config.cw_b_weight, max_weight); in validate_config()
424 config.cw_a_weight = astc::max(config.cw_a_weight, max_weight); in validate_config()
453 // Zero init all config fields; although most of will be over written in astcenc_config_init()
454 astcenc_config& config = *configp; in astcenc_config_init() local
455 std::memset(&config, 0, sizeof(config)); in astcenc_config_init()
465 config.block_x = block_x; in astcenc_config_init()
466 config.block_y = block_y; in astcenc_config_init()
467 config.block_z = block_z; in astcenc_config_init()
499 for (end = 0; end < preset_configs->size(); end++) in astcenc_config_init()
507 start = end == 0 ? 0 : end - 1; in astcenc_config_init()
509 // Start and end node are the same - so just transfer the values. in astcenc_config_init()
512 config.tune_partition_count_limit = (*preset_configs)[start].tune_partition_count_limit; in astcenc_config_init()
513 config.tune_2partition_index_limit = (*preset_configs)[start].tune_2partition_index_limit; in astcenc_config_init()
514 config.tune_3partition_index_limit = (*preset_configs)[start].tune_3partition_index_limit; in astcenc_config_init()
515 config.tune_4partition_index_limit = (*preset_configs)[start].tune_4partition_index_limit; in astcenc_config_init()
516 config.tune_block_mode_limit = (*preset_configs)[start].tune_block_mode_limit; in astcenc_config_init()
517 config.tune_refinement_limit = (*preset_configs)[start].tune_refinement_limit; in astcenc_config_init()
518 config.tune_candidate_limit = (*preset_configs)[start].tune_candidate_limit; in astcenc_config_init()
519config.tune_2partitioning_candidate_limit = (*preset_configs)[start].tune_2partitioning_candidate_… in astcenc_config_init()
520config.tune_3partitioning_candidate_limit = (*preset_configs)[start].tune_3partitioning_candidate_… in astcenc_config_init()
521config.tune_4partitioning_candidate_limit = (*preset_configs)[start].tune_4partitioning_candidate_… in astcenc_config_init()
522 config.tune_db_limit = astc::max((*preset_configs)[start].tune_db_limit_a_base - 35 * ltexels, in astcenc_config_init()
523 (*preset_configs)[start].tune_db_limit_b_base - 19 * ltexels); in astcenc_config_init()
525 config.tune_mse_overshoot = (*preset_configs)[start].tune_mse_overshoot; in astcenc_config_init()
527config.tune_2partition_early_out_limit_factor = (*preset_configs)[start].tune_2partition_early_out… in astcenc_config_init()
528config.tune_3partition_early_out_limit_factor = (*preset_configs)[start].tune_3partition_early_out… in astcenc_config_init()
529config.tune_2plane_early_out_limit_correlation = (*preset_configs)[start].tune_2plane_early_out_li… in astcenc_config_init()
530 config.tune_search_mode0_enable = (*preset_configs)[start].tune_search_mode0_enable; in astcenc_config_init()
532 // Start and end node are not the same - so interpolate between them in astcenc_config_init()
538 float wt_range = node_b.quality - node_a.quality; in astcenc_config_init()
542 float wt_node_a = (node_b.quality - quality) / wt_range; in astcenc_config_init()
543 float wt_node_b = (quality - node_a.quality) / wt_range; in astcenc_config_init()
551 config.tune_partition_count_limit = LERPI(tune_partition_count_limit); in astcenc_config_init()
552 config.tune_2partition_index_limit = LERPI(tune_2partition_index_limit); in astcenc_config_init()
553 config.tune_3partition_index_limit = LERPI(tune_3partition_index_limit); in astcenc_config_init()
554 config.tune_4partition_index_limit = LERPI(tune_4partition_index_limit); in astcenc_config_init()
555 config.tune_block_mode_limit = LERPI(tune_block_mode_limit); in astcenc_config_init()
556 config.tune_refinement_limit = LERPI(tune_refinement_limit); in astcenc_config_init()
557 config.tune_candidate_limit = LERPUI(tune_candidate_limit); in astcenc_config_init()
558 config.tune_2partitioning_candidate_limit = LERPUI(tune_2partitioning_candidate_limit); in astcenc_config_init()
559 config.tune_3partitioning_candidate_limit = LERPUI(tune_3partitioning_candidate_limit); in astcenc_config_init()
560 config.tune_4partitioning_candidate_limit = LERPUI(tune_4partitioning_candidate_limit); in astcenc_config_init()
561 config.tune_db_limit = astc::max(LERP(tune_db_limit_a_base) - 35 * ltexels, in astcenc_config_init()
562 LERP(tune_db_limit_b_base) - 19 * ltexels); in astcenc_config_init()
564 config.tune_mse_overshoot = LERP(tune_mse_overshoot); in astcenc_config_init()
566 config.tune_2partition_early_out_limit_factor = LERP(tune_2partition_early_out_limit_factor); in astcenc_config_init()
567 config.tune_3partition_early_out_limit_factor = LERP(tune_3partition_early_out_limit_factor); in astcenc_config_init()
568 config.tune_2plane_early_out_limit_correlation = LERP(tune_2plane_early_out_limit_correlation); in astcenc_config_init()
569 config.tune_search_mode0_enable = LERP(tune_search_mode0_enable); in astcenc_config_init()
576 config.cw_r_weight = 1.0f; in astcenc_config_init()
577 config.cw_g_weight = 1.0f; in astcenc_config_init()
578 config.cw_b_weight = 1.0f; in astcenc_config_init()
579 config.cw_a_weight = 1.0f; in astcenc_config_init()
581 config.a_scale_radius = 0; in astcenc_config_init()
583 config.rgbm_m_scale = 0.0f; in astcenc_config_init()
585 config.profile = profile; in astcenc_config_init()
596 config.tune_db_limit = 999.0f; in astcenc_config_init()
597 config.tune_search_mode0_enable = 0.0f; in astcenc_config_init()
615 config.tune_partition_count_limit = astc::min(config.tune_partition_count_limit + 1u, 4u); in astcenc_config_init()
617 config.cw_g_weight = 0.0f; in astcenc_config_init()
618 config.cw_b_weight = 0.0f; in astcenc_config_init()
619 config.tune_2partition_early_out_limit_factor *= 1.5f; in astcenc_config_init()
620 config.tune_3partition_early_out_limit_factor *= 1.5f; in astcenc_config_init()
621 config.tune_2plane_early_out_limit_correlation = 0.99f; in astcenc_config_init()
625 config.tune_db_limit *= 1.03f; in astcenc_config_init()
629 config.rgbm_m_scale = 5.0f; in astcenc_config_init()
630 config.cw_a_weight = 2.0f * config.rgbm_m_scale; in astcenc_config_init()
642 // that if the content is using alpha we'd recommend using the -a option to weight in astcenc_config_init()
646 config.cw_r_weight = 0.30f * 2.25f; in astcenc_config_init()
647 config.cw_g_weight = 0.59f * 2.25f; in astcenc_config_init()
648 config.cw_b_weight = 0.11f * 2.25f; in astcenc_config_init()
651 config.flags = flags; in astcenc_config_init()
663 const astcenc_config& config = *configp; in astcenc_context_alloc() local
685 if (config.privateProfile == CUSTOMIZED_PROFILE) in astcenc_context_alloc()
692 astcenc_contexti* ctx = &ctxo->context; in astcenc_context_alloc()
693 ctx->thread_count = thread_count; in astcenc_context_alloc()
694 ctx->config = config; in astcenc_context_alloc()
695 ctx->working_buffers = nullptr; in astcenc_context_alloc()
697 // These are allocated per-compress, as they depend on image size in astcenc_context_alloc()
698 ctx->input_alpha_averages = nullptr; in astcenc_context_alloc()
700 // Copy the config first and validate the copy (we may modify it) in astcenc_context_alloc()
701 status = validate_config(ctx->config); in astcenc_context_alloc()
708 ctx->bsd = aligned_malloc<block_size_descriptor>(sizeof(block_size_descriptor), ASTCENC_VECALIGN); in astcenc_context_alloc()
709 if (!ctx->bsd) in astcenc_context_alloc()
715 bool can_omit_modes = static_cast<bool>(config.flags & ASTCENC_FLG_SELF_DECOMPRESS_ONLY); in astcenc_context_alloc()
717 …if (!init_block_size_descriptor(ctx->config.privateProfile, config.block_x, config.block_y, config in astcenc_context_alloc()
719 config.tune_partition_count_limit, in astcenc_context_alloc()
720 static_cast<float>(config.tune_block_mode_limit) / 100.0f, in astcenc_context_alloc()
721 *ctx->bsd)) in astcenc_context_alloc()
723 aligned_free<block_size_descriptor>(ctx->bsd); in astcenc_context_alloc()
729 …init_block_size_descriptor(ctx->config.privateProfile, config.block_x, config.block_y, config.bloc… in astcenc_context_alloc()
731 config.tune_partition_count_limit, in astcenc_context_alloc()
732 static_cast<float>(config.tune_block_mode_limit) / 100.0f, in astcenc_context_alloc()
733 *ctx->bsd); in astcenc_context_alloc()
738 if (!(ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY)) in astcenc_context_alloc()
740 // Turn a dB limit into a per-texel error for faster use later in astcenc_context_alloc()
741 if ((ctx->config.profile == ASTCENC_PRF_LDR) || (ctx->config.profile == ASTCENC_PRF_LDR_SRGB)) in astcenc_context_alloc()
743 …ctx->config.tune_db_limit = astc::pow(0.1f, ctx->config.tune_db_limit * 0.1f) * 65535.0f * 65535.0… in astcenc_context_alloc()
747 ctx->config.tune_db_limit = 0.0f; in astcenc_context_alloc()
751 ctx->working_buffers = aligned_malloc<compression_working_buffers>(worksize, ASTCENC_VECALIGN); in astcenc_context_alloc()
754 if (!ctx->working_buffers) in astcenc_context_alloc()
756 aligned_free<block_size_descriptor>(ctx->bsd); in astcenc_context_alloc()
765 ctx->trace_log = new TraceLog(ctx->config.trace_file_path); in astcenc_context_alloc()
766 if (!ctx->trace_log->m_file) in astcenc_context_alloc()
771 trace_add_data("block_x", config.block_x); in astcenc_context_alloc()
772 trace_add_data("block_y", config.block_y); in astcenc_context_alloc()
773 trace_add_data("block_z", config.block_z); in astcenc_context_alloc()
791 astcenc_contexti* ctx = &ctxo->context; in astcenc_context_free()
792 if (ctx->working_buffers) in astcenc_context_free()
794 aligned_free<compression_working_buffers>(ctx->working_buffers); in astcenc_context_free()
798 printf("ctx->working_buffers is nullptr !!\n"); in astcenc_context_free()
800 if (ctx->bsd) in astcenc_context_free()
802 aligned_free<block_size_descriptor>(ctx->bsd); in astcenc_context_free()
806 printf("ctx->bsd is nullptr !!\n"); in astcenc_context_free()
809 delete ctx->trace_log; in astcenc_context_free()
841 astcenc_profile decode_mode = ctx.config.profile; in compress_image()
854 int xblocks = (dim_x + block_x - 1) / block_x; in compress_image()
855 int yblocks = (dim_y + block_y - 1) / block_y; in compress_image()
856 int zblocks = (dim_z + block_z - 1) / block_z; in compress_image()
862 blk.decode_unorm8 = ctxo.context.config.flags & ASTCENC_FLG_USE_DECODE_UNORM8; in compress_image()
865 blk.channel_weight = vfloat4(ctx.config.cw_r_weight, in compress_image()
866 ctx.config.cw_g_weight, in compress_image()
867 ctx.config.cw_b_weight, in compress_image()
868 ctx.config.cw_a_weight); in compress_image()
874 ctxo.manage_compress.init(block_count, ctx.config.progress_callback); in compress_image()
906 unsigned int rem = i - (z * plane_blocks); in compress_image()
908 int x = rem - (y * row_blocks); in compress_image()
910 // Test if we can apply some basic alpha-scale RDO in compress_image()
912 if (ctx.config.a_scale_radius != 0 && block_z == 1) in compress_image()
923 int x_footprint = block_x + 2 * (ctx.config.a_scale_radius - 1); in compress_image()
925 int y_footprint = block_y + 2 * (ctx.config.a_scale_radius - 1); in compress_image()
955 if (ctx.config.flags & ASTCENC_FLG_USE_ALPHA_WEIGHT) in compress_image()
958 blk.channel_weight = vfloat4(ctx.config.cw_r_weight * alpha_scale, in compress_image()
959 ctx.config.cw_g_weight * alpha_scale, in compress_image()
960 ctx.config.cw_b_weight * alpha_scale, in compress_image()
961 ctx.config.cw_a_weight); in compress_image()
964 // Apply alpha scale RDO - substitute constant color block in compress_image()
1001 * Results are written back into @c img->input_alpha_averages.
1020 int y_tasks = (size_y + step_xy - 1) / step_xy; in compute_averages()
1035 int y = (i - (z * y_tasks)) * step_xy; in compute_averages()
1037 arg.size_z = astc::min(step_z, size_z - z); in compute_averages()
1040 arg.size_y = astc::min(step_xy, size_y - y); in compute_averages()
1045 arg.size_x = astc::min(step_xy, size_x - x); in compute_averages()
1081 astcenc_contexti* ctx = &ctxo->context; in astcenc_compress_image()
1085 if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY) in astcenc_compress_image()
1096 if (thread_index >= ctx->thread_count) in astcenc_compress_image()
1101 unsigned int block_x = ctx->config.block_x; in astcenc_compress_image()
1102 unsigned int block_y = ctx->config.block_y; in astcenc_compress_image()
1103 unsigned int block_z = ctx->config.block_z; in astcenc_compress_image()
1105 unsigned int xblocks = (image.dim_x + block_x - 1) / block_x; in astcenc_compress_image()
1106 unsigned int yblocks = (image.dim_y + block_y - 1) / block_y; in astcenc_compress_image()
1107 unsigned int zblocks = (image.dim_z + block_z - 1) / block_z; in astcenc_compress_image()
1117 if (ctx->thread_count == 1) in astcenc_compress_image()
1122 if (ctx->config.a_scale_radius != 0) in astcenc_compress_image()
1129 ctx->input_alpha_averages = new float[texel_count]; in astcenc_compress_image()
1132 image, ctx->config.a_scale_radius, *swizzle, in astcenc_compress_image()
1133 ctx->avg_preprocess_args); in astcenc_compress_image()
1137 ctxo->manage_avg.init(init_avg); in astcenc_compress_image()
1140 compute_averages(*ctxo, ctx->avg_preprocess_args); in astcenc_compress_image()
1144 ctxo->manage_avg.wait(); in astcenc_compress_image()
1151 ctxo->manage_compress.wait(); in astcenc_compress_image()
1154 delete[] ctx->input_alpha_averages; in astcenc_compress_image()
1155 ctx->input_alpha_averages = nullptr; in astcenc_compress_image()
1159 ctxo->manage_compress.term(term_compress); in astcenc_compress_image()
1173 astcenc_contexti* ctx = &ctxo->context; in astcenc_compress_reset()
1174 if (ctx->config.flags & ASTCENC_FLG_DECOMPRESS_ONLY) in astcenc_compress_reset()
1179 ctxo->manage_avg.reset(); in astcenc_compress_reset()
1180 ctxo->manage_compress.reset(); in astcenc_compress_reset()
1196 astcenc_contexti* ctx = &ctxo->context; in astcenc_decompress_image()
1199 if (thread_index >= ctx->thread_count) in astcenc_decompress_image()
1210 unsigned int block_x = ctx->config.block_x; in astcenc_decompress_image()
1211 unsigned int block_y = ctx->config.block_y; in astcenc_decompress_image()
1212 unsigned int block_z = ctx->config.block_z; in astcenc_decompress_image()
1214 unsigned int xblocks = (image_out.dim_x + block_x - 1) / block_x; in astcenc_decompress_image()
1215 unsigned int yblocks = (image_out.dim_y + block_y - 1) / block_y; in astcenc_decompress_image()
1216 unsigned int zblocks = (image_out.dim_z + block_z - 1) / block_z; in astcenc_decompress_image()
1236 if (ctx->thread_count == 1) in astcenc_decompress_image()
1242 ctxo->manage_decompress.init(block_count, nullptr); in astcenc_decompress_image()
1248 unsigned int base = ctxo->manage_decompress.get_task_assignment(128, count); in astcenc_decompress_image()
1258 unsigned int rem = i - (z * plane_blocks); in astcenc_decompress_image()
1260 int x = rem - (y * row_blocks); in astcenc_decompress_image()
1267 physical_to_symbolic(*ctx->bsd, bp, scb); in astcenc_decompress_image()
1269 decompress_symbolic_block(ctx->config.profile, *ctx->bsd, in astcenc_decompress_image()
1273 store_image_block(image_out, blk, *ctx->bsd, in astcenc_decompress_image()
1277 ctxo->manage_decompress.complete_task_assignment(count); in astcenc_decompress_image()
1287 ctxo->manage_decompress.reset(); in astcenc_decompress_reset()
1303 astcenc_contexti* ctx = &ctxo->context; in astcenc_get_block_info()
1307 physical_to_symbolic(*ctx->bsd, data, scb); in astcenc_get_block_info()
1310 block_size_descriptor& bsd = *ctx->bsd; in astcenc_get_block_info()
1316 info->profile = ctx->config.profile; in astcenc_get_block_info()
1318 info->block_x = ctx->config.block_x; in astcenc_get_block_info()
1319 info->block_y = ctx->config.block_y; in astcenc_get_block_info()
1320 info->block_z = ctx->config.block_z; in astcenc_get_block_info()
1321 info->texel_count = bsd.texel_count; in astcenc_get_block_info()
1324 info->is_error_block = scb.block_type == SYM_BTYPE_ERROR; in astcenc_get_block_info()
1325 if (info->is_error_block) in astcenc_get_block_info()
1331 info->is_constant_block = scb.block_type == SYM_BTYPE_CONST_F16 || in astcenc_get_block_info()
1333 if (info->is_constant_block) in astcenc_get_block_info()
1345 info->weight_x = di.weight_x; in astcenc_get_block_info()
1346 info->weight_y = di.weight_y; in astcenc_get_block_info()
1347 info->weight_z = di.weight_z; in astcenc_get_block_info()
1349 info->is_dual_plane_block = bm.is_dual_plane != 0; in astcenc_get_block_info()
1351 info->partition_count = scb.partition_count; in astcenc_get_block_info()
1352 info->partition_index = scb.partition_index; in astcenc_get_block_info()
1353 info->dual_plane_component = scb.plane2_component; in astcenc_get_block_info()
1355 info->color_level_count = get_quant_level(scb.get_color_quant_mode()); in astcenc_get_block_info()
1356 info->weight_level_count = get_quant_level(bm.get_weight_quant_mode()); in astcenc_get_block_info()
1365 unpack_color_endpoints(ctx->config.profile, in astcenc_get_block_info()
1372 info->color_endpoint_modes[i] = scb.color_formats[i]; in astcenc_get_block_info()
1373 info->is_hdr_block = info->is_hdr_block || rgb_hdr || a_hdr; in astcenc_get_block_info()
1382 store(float16_to_float(datai), info->color_endpoints[i][j]); in astcenc_get_block_info()
1393 info->weight_values_plane1[i] = static_cast<float>(weight_plane1[i]) * (1.0f / WEIGHTS_TEXEL_SUM); in astcenc_get_block_info()
1394 if (info->is_dual_plane_block) in astcenc_get_block_info()
1396 … info->weight_values_plane2[i] = static_cast<float>(weight_plane2[i]) * (1.0f / WEIGHTS_TEXEL_SUM); in astcenc_get_block_info()
1403 info->partition_assignment[i] = pi.partition_of_texel[i]; in astcenc_get_block_info()