Module: Mesa Branch: main Commit: 16c1628f73904875f9ad25a11909c6939ba21477 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16c1628f73904875f9ad25a11909c6939ba21477
Author: Agate, Jesse <jesse.ag...@amd.com> Date: Mon Dec 4 16:51:57 2023 -0500 amd/vpelib: VPT Failing Test Cases Fix failing studio range test cases. - Cause of issue was negative values being mirrored in the pipe by studio range gamma conversion were getting clipped at the end of the pipeline. Fix is to move bias outside of the gamma lut and into the gamma bias. Reviewed-by: Roy Chan <roy.c...@amd.com> Acked-by: Alan Liu <haoping....@amd.com> Signed-off-by: Jesse Agate <jesse.ag...@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26841> --- src/amd/vpelib/src/chip/vpe10/vpe10_cm_common.c | 82 +++++++++++++------------ src/amd/vpelib/src/core/color.c | 2 - src/amd/vpelib/src/core/color_gamma.c | 57 +++++++---------- src/amd/vpelib/src/core/inc/color_gamma.h | 6 +- 4 files changed, 68 insertions(+), 79 deletions(-) diff --git a/src/amd/vpelib/src/chip/vpe10/vpe10_cm_common.c b/src/amd/vpelib/src/chip/vpe10/vpe10_cm_common.c index 109de042cc8..720b4572e3a 100644 --- a/src/amd/vpelib/src/chip/vpe10/vpe10_cm_common.c +++ b/src/amd/vpelib/src/chip/vpe10/vpe10_cm_common.c @@ -61,39 +61,21 @@ static bool cm_helper_convert_to_custom_float(struct pwl_result_data *rgb_result VPE_ASSERT(0); return false; } - - if (!vpe_convert_to_custom_float_format( - corner_points[0].red.y, &fmt, &corner_points[0].red.custom_float_y)) { - VPE_ASSERT(0); - return false; - } if (!vpe_convert_to_custom_float_format( - corner_points[0].green.y, &fmt, &corner_points[0].green.custom_float_y)) { + corner_points[0].red.y, &fmt, &corner_points[0].red.custom_float_y)) { VPE_ASSERT(0); return false; } if (!vpe_convert_to_custom_float_format( - corner_points[0].blue.y, &fmt, &corner_points[0].blue.custom_float_y)) { - VPE_ASSERT(0); - return false; - } - - if (!vpe_convert_to_custom_float_format( - corner_points[0].red.offset, &fmt, &corner_points[0].red.custom_float_offset)) { + corner_points[0].green.y, &fmt, &corner_points[0].green.custom_float_y)) { VPE_ASSERT(0); return false; } if (!vpe_convert_to_custom_float_format( - corner_points[0].green.offset, &fmt, &corner_points[0].green.custom_float_offset)) { + corner_points[0].blue.y, &fmt, &corner_points[0].blue.custom_float_y)) { VPE_ASSERT(0); return false; } - if (!vpe_convert_to_custom_float_format( - corner_points[0].blue.offset, &fmt, &corner_points[0].blue.custom_float_offset)) { - VPE_ASSERT(0); - return false; - } - if (!vpe_convert_to_custom_float_format( corner_points[0].red.slope, &fmt, &corner_points[0].red.custom_float_slope)) { VPE_ASSERT(0); @@ -207,6 +189,27 @@ static bool cm_helper_convert_to_custom_float(struct pwl_result_data *rgb_result ++i; } + fmt.exponenta_bits = 6; + fmt.mantissa_bits = 12; + fmt.sign = 1; + + if (!vpe_convert_to_custom_float_format( + corner_points[0].red.offset, &fmt, &corner_points[0].red.custom_float_offset)) { + VPE_ASSERT(0); + return false; + } + + if (!vpe_convert_to_custom_float_format( + corner_points[0].green.offset, &fmt, &corner_points[0].green.custom_float_offset)) { + VPE_ASSERT(0); + return false; + } + + if (!vpe_convert_to_custom_float_format( + corner_points[0].blue.offset, &fmt, &corner_points[0].blue.custom_float_offset)) { + VPE_ASSERT(0); + return false; + } return true; } @@ -386,15 +389,12 @@ bool vpe10_cm_helper_translate_curve_to_hw_format( ++i; } - corner_points[0].red.y = output_tf->start_base; - corner_points[0].green.y = output_tf->start_base; - corner_points[0].blue.y = output_tf->start_base; - - if (output_tf->start_base.value != vpe_fixpt_zero.value) { - corner_points[0].red.slope = vpe_fixpt_zero; - corner_points[0].green.slope = vpe_fixpt_zero; - corner_points[0].blue.slope = vpe_fixpt_zero; - } + corner_points[0].red.y = vpe_fixpt_zero; + corner_points[0].green.y = vpe_fixpt_zero; + corner_points[0].blue.y = vpe_fixpt_zero; + corner_points[0].red.offset = output_tf->start_base; + corner_points[0].green.offset = output_tf->start_base; + corner_points[0].blue.offset = output_tf->start_base; cm_helper_convert_to_custom_float(rgb_resulted, lut_params->corner_points, hw_points, fixpoint); @@ -507,15 +507,12 @@ bool vpe10_cm_helper_translate_curve_to_degamma_hw_format( ++i; } - corner_points[0].red.y = output_tf->start_base; - corner_points[0].green.y = output_tf->start_base; - corner_points[0].blue.y = output_tf->start_base; - - if (output_tf->start_base.value != vpe_fixpt_zero.value) { - corner_points[0].red.slope = vpe_fixpt_zero; - corner_points[0].green.slope = vpe_fixpt_zero; - corner_points[0].blue.slope = vpe_fixpt_zero; - } + corner_points[0].red.y = vpe_fixpt_zero; + corner_points[0].green.y = vpe_fixpt_zero; + corner_points[0].blue.y = vpe_fixpt_zero; + corner_points[0].red.offset = output_tf->start_base; + corner_points[0].green.offset = output_tf->start_base; + corner_points[0].blue.offset = output_tf->start_base; cm_helper_convert_to_custom_float(rgb_resulted, lut_params->corner_points, hw_points, false); @@ -605,6 +602,13 @@ void vpe10_cm_helper_program_gamcor_xfer_func(struct config_writer *config_write REG_SET_CM(reg->start_base_cntl_b, 0, field_region_start_base, params->corner_points[0].blue.custom_float_y); + REG_SET_CM(reg->offset_r, 0, field_offset, + params->corner_points[0].red.custom_float_offset); + REG_SET_CM(reg->offset_g, 0, field_offset, + params->corner_points[0].green.custom_float_offset); + REG_SET_CM(reg->offset_b, 0, field_offset, + params->corner_points[0].blue.custom_float_offset); + REG_SET_CM(reg->start_slope_cntl_b, 0, // linear slope at start of curve field_region_linear_slope, params->corner_points[0].blue.custom_float_slope); REG_SET_CM(reg->start_slope_cntl_g, 0, field_region_linear_slope, diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index a1d7399d512..2725221382e 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -182,7 +182,6 @@ static bool color_update_regamma_tf(struct vpe_priv *vpe_priv, vpe_color_calculate_regamma_params(vpe_priv, x_scale, y_scale, - y_bias, &vpe_priv->cal_buffer, output_tf); @@ -236,7 +235,6 @@ static bool color_update_degamma_tf(struct vpe_priv *vpe_priv, vpe_color_calculate_degamma_params(vpe_priv, x_scale, y_scale, - y_bias, input_tf); } diff --git a/src/amd/vpelib/src/core/color_gamma.c b/src/amd/vpelib/src/core/color_gamma.c index 254631f3681..69f8ebd7a38 100644 --- a/src/amd/vpelib/src/core/color_gamma.c +++ b/src/amd/vpelib/src/core/color_gamma.c @@ -336,10 +336,8 @@ static struct fixed31_32 translate_from_linear_space_ex(struct fixed31_32 arg, return translate_from_linear_space(&scratch_gamma_args); } -static void build_pq(uint32_t hw_points_num, - const struct hw_x_point *coordinate_x, - struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct fixed31_32 y_bias, - struct pwl_float_data_ex *rgb_regamma) +static void build_pq(uint32_t hw_points_num, const struct hw_x_point *coordinate_x, + struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct pwl_float_data_ex *rgb_regamma) { uint32_t i, curve_start_index; @@ -359,7 +357,6 @@ static void build_pq(uint32_t hw_points_num, for (i = 0; i < curve_start_index; i++) { output = vpe_fixpt_mul(coord_x->x, slope); - output = vpe_fixpt_add(output, y_bias); rgb->r = output; rgb->g = output; rgb->b = output; @@ -372,7 +369,6 @@ static void build_pq(uint32_t hw_points_num, vpe_compute_pq(vpe_fixpt_mul(coord_x->x, x_scale), &output); output = vpe_fixpt_mul(output, y_scale); - output = vpe_fixpt_add(output, y_bias); rgb->r = output; rgb->g = output; rgb->b = output; @@ -382,25 +378,23 @@ static void build_pq(uint32_t hw_points_num, } } -static void build_de_pq(uint32_t hw_points_num, - const struct hw_x_point *coordinate_x_degamma, struct fixed31_32 x_scale, - struct fixed31_32 y_scale, struct fixed31_32 y_bias, struct transfer_func_distributed_points *de_pq) +static void build_de_pq(uint32_t hw_points_num, const struct hw_x_point *coordinate_x_degamma, + struct fixed31_32 x_scale, struct fixed31_32 y_scale, + struct transfer_func_distributed_points *de_pq) { struct fixed31_32 output; for (uint32_t i = 0; i < hw_points_num; i++) { compute_de_pq(vpe_fixpt_mul(coordinates_x_degamma[i].x, x_scale), &output); output = vpe_fixpt_mul(output, y_scale); - output = vpe_fixpt_add(output, y_bias); de_pq->red[i] = output; de_pq->green[i] = output; de_pq->blue[i] = output; } } -static bool build_degamma(uint32_t hw_points_num, - const struct hw_x_point *coordinate_x_degamma, enum color_transfer_func type, - struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct fixed31_32 y_bias, +static bool build_degamma(uint32_t hw_points_num, const struct hw_x_point *coordinate_x_degamma, + enum color_transfer_func type, struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct transfer_func_distributed_points *curve) { uint32_t i; @@ -420,7 +414,6 @@ static bool build_degamma(uint32_t hw_points_num, output = translate_to_linear_space_ex(output, &coeff, 0); output = vpe_fixpt_mul(output, y_scale); - output = vpe_fixpt_add(output, y_bias); curve->red[i] = output; curve->green[i] = output; @@ -433,9 +426,9 @@ release: } static bool build_regamma(struct vpe_priv *vpe_priv, uint32_t hw_points_num, - const struct hw_x_point *coordinate_x, enum color_transfer_func type, - struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct fixed31_32 y_bias, - struct calculate_buffer *cal_buffer, struct pwl_float_data_ex *rgb_regamma) + const struct hw_x_point *coordinate_x, enum color_transfer_func type, struct fixed31_32 x_scale, + struct fixed31_32 y_scale, struct calculate_buffer *cal_buffer, + struct pwl_float_data_ex *rgb_regamma) { uint32_t i; bool ret = false; @@ -459,7 +452,7 @@ static bool build_regamma(struct vpe_priv *vpe_priv, uint32_t hw_points_num, /* TODO use y vs r,g,b */ rgb->r = vpe_fixpt_mul(coord_x->x, x_scale); rgb->r = translate_from_linear_space_ex(rgb->r, coeff, 0, cal_buffer); - rgb->r = vpe_fixpt_add(vpe_fixpt_mul(rgb->r, y_scale), y_bias); + rgb->r = vpe_fixpt_mul(rgb->r, y_scale); rgb->g = rgb->r; rgb->b = rgb->r; ++coord_x; @@ -515,9 +508,9 @@ static bool map_regamma_hw_to_x_user(struct hw_x_point *coords_x, const struct p } static bool calculate_curve(struct vpe_priv *vpe_priv, enum color_transfer_func trans, - struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct fixed31_32 y_bias, + struct fixed31_32 x_scale, struct fixed31_32 y_scale, struct transfer_func_distributed_points *points, struct pwl_float_data_ex *rgb_regamma, - struct calculate_buffer *cal_buffer) + struct calculate_buffer *cal_buffer) { int hdr_norm = vpe_priv->resource.internal_hdr_normalization; int y_norm; @@ -529,11 +522,12 @@ static bool calculate_curve(struct vpe_priv *vpe_priv, enum color_transfer_func case TRANSFER_FUNC_SRGB: case TRANSFER_FUNC_BT709: case TRANSFER_FUNC_BT1886: - build_regamma(vpe_priv, MAX_HW_POINTS, coordinates_x, trans, x_scale, y_scale, y_bias, cal_buffer, rgb_regamma); + build_regamma(vpe_priv, MAX_HW_POINTS, coordinates_x, trans, x_scale, y_scale, cal_buffer, + rgb_regamma); ret = true; break; case TRANSFER_FUNC_PQ2084: - build_pq(MAX_HW_POINTS, coordinates_x, x_scale, y_scale, y_bias, rgb_regamma); + build_pq(MAX_HW_POINTS, coordinates_x, x_scale, y_scale, rgb_regamma); ret = true; break; case TRANSFER_FUNC_LINEAR_0_125: @@ -548,7 +542,6 @@ static bool calculate_curve(struct vpe_priv *vpe_priv, enum color_transfer_func combined_scale = vpe_fixpt_mul(combined_scale, x_scale); for (int i = 0; i < MAX_HW_POINTS; i++) { rgb_regamma[i].r = vpe_fixpt_mul(coordinates_x[i].x, combined_scale); - rgb_regamma[i].r = vpe_fixpt_add(rgb_regamma[i].r, y_bias); rgb_regamma[i].g = rgb_regamma[i].r; rgb_regamma[i].b = rgb_regamma[i].r; } @@ -568,7 +561,7 @@ static bool calculate_curve(struct vpe_priv *vpe_priv, enum color_transfer_func #define _EXTRA_POINTS 3 bool vpe_color_calculate_degamma_params(struct vpe_priv *vpe_priv, struct fixed31_32 x_scale, - struct fixed31_32 y_scale, struct fixed31_32 y_bias, struct transfer_func *input_tf) + struct fixed31_32 y_scale, struct transfer_func *input_tf) { struct transfer_func_distributed_points *tf_pts = &input_tf->tf_pts; enum color_transfer_func tf = input_tf->tf; @@ -584,13 +577,13 @@ bool vpe_color_calculate_degamma_params(struct vpe_priv *vpe_priv, struct fixed3 { case TRANSFER_FUNC_PQ2084: case TRANSFER_FUNC_NORMALIZED_PQ: - build_de_pq(MAX_HW_POINTS_DEGAMMA, coordinates_x_degamma, x_scale, y_scale, y_bias, tf_pts); + build_de_pq(MAX_HW_POINTS_DEGAMMA, coordinates_x_degamma, x_scale, y_scale, tf_pts); ret = true; break; case TRANSFER_FUNC_SRGB: case TRANSFER_FUNC_BT709: case TRANSFER_FUNC_BT1886: - build_degamma(MAX_HW_POINTS_DEGAMMA, coordinates_x_degamma, tf, x_scale, y_scale, y_bias, tf_pts); + build_degamma(MAX_HW_POINTS_DEGAMMA, coordinates_x_degamma, tf, x_scale, y_scale, tf_pts); ret = true; break; case TRANSFER_FUNC_LINEAR_0_1: @@ -606,7 +599,6 @@ bool vpe_color_calculate_degamma_params(struct vpe_priv *vpe_priv, struct fixed3 for (int i = 0; i < MAX_HW_POINTS_DEGAMMA; i ++) { output = vpe_fixpt_mul(coordinates_x_degamma[i].x, scale_combined); - output = vpe_fixpt_add(output, y_bias); tf_pts->red[i] = output; tf_pts->green[i] = output; tf_pts->blue[i] = output; @@ -619,10 +611,8 @@ bool vpe_color_calculate_degamma_params(struct vpe_priv *vpe_priv, struct fixed3 return ret; } -bool vpe_color_calculate_regamma_params( - struct vpe_priv* vpe_priv, struct fixed31_32 x_scale, - struct fixed31_32 y_scale, struct fixed31_32 y_bias, - struct calculate_buffer *cal_buffer, struct transfer_func *output_tf) +bool vpe_color_calculate_regamma_params(struct vpe_priv *vpe_priv, struct fixed31_32 x_scale, + struct fixed31_32 y_scale, struct calculate_buffer *cal_buffer, struct transfer_func *output_tf) { struct transfer_func_distributed_points *tf_pts = &output_tf->tf_pts; struct pwl_float_data_ex *rgb_regamma = NULL; @@ -642,10 +632,7 @@ bool vpe_color_calculate_regamma_params( tf = output_tf->tf; - ret = calculate_curve(vpe_priv, tf, - x_scale, y_scale, y_bias, - tf_pts, rgb_regamma, - cal_buffer); + ret = calculate_curve(vpe_priv, tf, x_scale, y_scale, tf_pts, rgb_regamma, cal_buffer); if (ret) { map_regamma_hw_to_x_user(coordinates_x, rgb_regamma, MAX_HW_POINTS, tf_pts, false); diff --git a/src/amd/vpelib/src/core/inc/color_gamma.h b/src/amd/vpelib/src/core/inc/color_gamma.h index 02c42e36eaa..b443085a238 100644 --- a/src/amd/vpelib/src/core/inc/color_gamma.h +++ b/src/amd/vpelib/src/core/inc/color_gamma.h @@ -52,11 +52,11 @@ void vpe_color_setup_x_points_distribution(void); void vpe_color_setup_x_points_distribution_degamma(void); bool vpe_color_calculate_regamma_params(struct vpe_priv *vpe_priv, struct fixed31_32 x_scale, - struct fixed31_32 y_scale, struct fixed31_32 y_bias, - struct calculate_buffer *cal_buffer, struct transfer_func* output_tf); + struct fixed31_32 y_scale, struct calculate_buffer *cal_buffer, + struct transfer_func *output_tf); bool vpe_color_calculate_degamma_params(struct vpe_priv *vpe_priv, struct fixed31_32 x_scale, - struct fixed31_32 y_scale, struct fixed31_32 y_bias, struct transfer_func *input_tf); + struct fixed31_32 y_scale, struct transfer_func *input_tf); void vpe_compute_pq(struct fixed31_32 in_x, struct fixed31_32 *out_y);