mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
amd/vpelib: Fix output_ctx gamma curve cache bug
[Why] Reprogramming gamma curve unnecessary and wastes power/time. [How] Bool array checked instead of bool inside said array, add index. [Testing] Tested with corresponding test cases. Reviewed-by: Roy Chan <Roy.Chan@amd.com> Reviewed-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com> Acked-by: Chih-Wei Chien <Chih-Wei.Chien@amd.com> Signed-off-by: Brendan Leder <breleder@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31605>
This commit is contained in:
parent
259b44d97b
commit
bd6f3e30f2
4 changed files with 34 additions and 32 deletions
|
|
@ -120,11 +120,11 @@ void vpe10_cm_helper_program_color_matrices(struct config_writer *config_writer,
|
|||
void vpe10_cm_helper_program_gamcor_xfer_func(struct config_writer *config_writer,
|
||||
const struct pwl_params *params, const struct vpe10_xfer_func_reg *reg);
|
||||
|
||||
bool vpe10_cm_helper_translate_curve_to_hw_format(
|
||||
const struct transfer_func *output_tf, struct pwl_params *lut_params, bool fixpoint);
|
||||
bool vpe10_cm_helper_translate_curve_to_hw_format(const struct transfer_func *tf,
|
||||
struct pwl_params *lut_params, bool fixpoint, bool dirty);
|
||||
|
||||
bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
||||
const struct transfer_func *output_tf, struct pwl_params *lut_params);
|
||||
const struct transfer_func *tf, struct pwl_params *lut_params, bool dirty);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ static bool cm_helper_convert_to_custom_float(struct pwl_result_data *rgb_result
|
|||
#define NUMBER_SW_SEGMENTS 16
|
||||
|
||||
bool vpe10_cm_helper_translate_curve_to_hw_format(
|
||||
const struct transfer_func *output_tf, struct pwl_params *lut_params, bool fixpoint)
|
||||
const struct transfer_func *tf, struct pwl_params *lut_params, bool fixpoint, bool dirty)
|
||||
{
|
||||
struct curve_points3 *corner_points;
|
||||
struct pwl_result_data *rgb_resulted;
|
||||
|
|
@ -232,8 +232,8 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
int32_t i;
|
||||
uint32_t j, k, seg_distr[MAX_REGIONS_NUMBER], increment, start_index, hw_points;
|
||||
|
||||
if (output_tf == NULL || lut_params == NULL || output_tf->type == TF_TYPE_BYPASS ||
|
||||
(!output_tf->dirty && (lut_params->hw_points_num != 0)))
|
||||
if (tf == NULL || lut_params == NULL || tf->type == TF_TYPE_BYPASS ||
|
||||
(!dirty && (lut_params->hw_points_num != 0)))
|
||||
return false;
|
||||
|
||||
corner_points = lut_params->corner_points;
|
||||
|
|
@ -243,7 +243,7 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
memset(lut_params, 0, sizeof(struct pwl_params));
|
||||
memset(seg_distr, 0, sizeof(seg_distr));
|
||||
|
||||
if (output_tf->tf == TRANSFER_FUNC_PQ2084) {
|
||||
if (tf->tf == TRANSFER_FUNC_PQ2084) {
|
||||
|
||||
for (i = 0; i < MAX_LOW_POINT; i++)
|
||||
seg_distr[i] = 3;
|
||||
|
|
@ -252,7 +252,7 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
seg_distr[i] = 1;
|
||||
region_start = -MAX_LOW_POINT;
|
||||
region_end = 1;
|
||||
} else if (output_tf->tf == TRANSFER_FUNC_LINEAR) {
|
||||
} else if (tf->tf == TRANSFER_FUNC_LINEAR) {
|
||||
|
||||
int num_regions_linear = MAX_LOW_POINT + 3;
|
||||
|
||||
|
|
@ -296,18 +296,18 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
i += increment) {
|
||||
if (j == hw_points - 1)
|
||||
break;
|
||||
rgb_resulted[j].red = output_tf->tf_pts.red[i];
|
||||
rgb_resulted[j].green = output_tf->tf_pts.green[i];
|
||||
rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
|
||||
rgb_resulted[j].red = tf->tf_pts.red[i];
|
||||
rgb_resulted[j].green = tf->tf_pts.green[i];
|
||||
rgb_resulted[j].blue = tf->tf_pts.blue[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
/* last point */
|
||||
start_index = (uint32_t)((region_end + MAX_LOW_POINT) * NUMBER_SW_SEGMENTS);
|
||||
rgb_resulted[hw_points - 1].red = output_tf->tf_pts.red[start_index];
|
||||
rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
|
||||
rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
|
||||
rgb_resulted[hw_points - 1].red = tf->tf_pts.red[start_index];
|
||||
rgb_resulted[hw_points - 1].green = tf->tf_pts.green[start_index];
|
||||
rgb_resulted[hw_points - 1].blue = tf->tf_pts.blue[start_index];
|
||||
|
||||
rgb_resulted[hw_points].red = rgb_resulted[hw_points - 1].red;
|
||||
rgb_resulted[hw_points].green = rgb_resulted[hw_points - 1].green;
|
||||
|
|
@ -393,9 +393,9 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
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;
|
||||
corner_points[0].red.offset = tf->start_base;
|
||||
corner_points[0].green.offset = tf->start_base;
|
||||
corner_points[0].blue.offset = tf->start_base;
|
||||
|
||||
cm_helper_convert_to_custom_float(rgb_resulted, lut_params->corner_points, hw_points, fixpoint);
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
|
|||
#define MAX_HW_POINTS_DEGAMMA 257
|
||||
|
||||
bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
||||
const struct transfer_func *output_tf, struct pwl_params *lut_params)
|
||||
const struct transfer_func *tf, struct pwl_params *lut_params, bool dirty)
|
||||
{
|
||||
struct curve_points3 *corner_points;
|
||||
struct pwl_result_data *rgb_resulted;
|
||||
|
|
@ -418,8 +418,8 @@ bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
|||
int32_t i;
|
||||
uint32_t k, seg_distr[MAX_REGIONS_NUMBER_DEGAMMA], num_segments, hw_points;
|
||||
|
||||
if (output_tf == NULL || lut_params == NULL || output_tf->type == TF_TYPE_BYPASS ||
|
||||
(!output_tf->dirty && (lut_params->hw_points_num != 0)))
|
||||
if (tf == NULL || lut_params == NULL || tf->type == TF_TYPE_BYPASS ||
|
||||
(!dirty && (lut_params->hw_points_num != 0)))
|
||||
return false;
|
||||
|
||||
corner_points = lut_params->corner_points;
|
||||
|
|
@ -433,9 +433,9 @@ bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
|||
region_end = 0;
|
||||
|
||||
for (i = 0; i < MAX_HW_POINTS_DEGAMMA; i++) {
|
||||
rgb_resulted[i].red = output_tf->tf_pts.red[i];
|
||||
rgb_resulted[i].green = output_tf->tf_pts.green[i];
|
||||
rgb_resulted[i].blue = output_tf->tf_pts.blue[i];
|
||||
rgb_resulted[i].red = tf->tf_pts.red[i];
|
||||
rgb_resulted[i].green = tf->tf_pts.green[i];
|
||||
rgb_resulted[i].blue = tf->tf_pts.blue[i];
|
||||
}
|
||||
|
||||
for (k = (uint32_t)(region_end - region_start); k < MAX_REGIONS_NUMBER_DEGAMMA; k++)
|
||||
|
|
@ -512,9 +512,9 @@ bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
|||
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;
|
||||
corner_points[0].red.offset = tf->start_base;
|
||||
corner_points[0].green.offset = tf->start_base;
|
||||
corner_points[0].blue.offset = tf->start_base;
|
||||
|
||||
cm_helper_convert_to_custom_float(rgb_resulted, lut_params->corner_points, hw_points, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,8 @@ void vpe10_dpp_program_input_transfer_func(struct dpp *dpp, struct transfer_func
|
|||
// VPE always do NL scaling using gamcor, thus skipping dgam (default bypass)
|
||||
// dpp->funcs->program_pre_dgam(dpp, tf);
|
||||
if (input_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
|
||||
vpe10_cm_helper_translate_curve_to_degamma_hw_format(input_tf, &dpp->degamma_params);
|
||||
vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
||||
input_tf, &dpp->degamma_params, input_tf->dirty[dpp->inst]);
|
||||
params = &dpp->degamma_params;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1253,8 +1253,8 @@ void vpe10_mpc_set_mpc_shaper_3dlut(
|
|||
// get the shaper lut params
|
||||
if (func_shaper) {
|
||||
if (func_shaper->type == TF_TYPE_DISTRIBUTED_POINTS) {
|
||||
vpe10_cm_helper_translate_curve_to_hw_format(
|
||||
func_shaper, &mpc->shaper_params, true); // should init shaper_params first
|
||||
vpe10_cm_helper_translate_curve_to_hw_format(func_shaper, &mpc->shaper_params, true,
|
||||
func_shaper->dirty[mpc->inst]); // should init shaper_params first
|
||||
shaper_lut = &mpc->shaper_params; // are there shaper prams in dpp instead?
|
||||
} else if (func_shaper->type == TF_TYPE_HWPWL) {
|
||||
shaper_lut = &func_shaper->pwl;
|
||||
|
|
@ -1286,7 +1286,7 @@ void vpe10_mpc_set_output_transfer_func(struct mpc *mpc, struct output_ctx *outp
|
|||
if (output_ctx->output_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
|
||||
vpe10_cm_helper_translate_curve_to_hw_format( // this is cm3.0 version instead 1.0
|
||||
// as DCN3.2
|
||||
output_ctx->output_tf, &mpc->regamma_params, false);
|
||||
output_ctx->output_tf, &mpc->regamma_params, false, output_ctx->output_tf->dirty[mpc->inst]);
|
||||
params = &mpc->regamma_params;
|
||||
}
|
||||
/* there are no ROM LUTs in OUTGAM */
|
||||
|
|
@ -1317,9 +1317,10 @@ void vpe10_mpc_set_blend_lut(struct mpc *mpc, struct transfer_func *blend_tf)
|
|||
|
||||
if (gamma_type == CM_DEGAM)
|
||||
vpe10_cm_helper_translate_curve_to_degamma_hw_format(
|
||||
blend_tf, &mpc->blender_params); // TODO should init regamma_params first
|
||||
blend_tf, &mpc->blender_params, blend_tf->dirty[mpc->inst]); // TODO should init regamma_params first
|
||||
else
|
||||
vpe10_cm_helper_translate_curve_to_hw_format(blend_tf, &mpc->blender_params, false);
|
||||
vpe10_cm_helper_translate_curve_to_hw_format(
|
||||
blend_tf, &mpc->blender_params, false, blend_tf->dirty[mpc->inst]);
|
||||
|
||||
blend_lut = &mpc->blender_params;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue