amd/vpelib: Remove gamma cached table

- Remove degam/regam cached tables
- Calculate degam/regam parameters on the fly
- Remove force_tf_calculation debug flag

Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Acked-by: Jack Chih <chiachih@amd.com>
Signed-off-by: Navid Assadian <navid.assadian@amd.com>
---

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28972>
This commit is contained in:
chiachih 2024-04-27 10:20:35 +08:00 committed by Marge Bot
parent 7a41fb59d3
commit acad1328a1
14 changed files with 19 additions and 2449 deletions

View file

@ -335,7 +335,6 @@ struct vpe_debug_options {
uint32_t assert_when_not_support : 1;
uint32_t bypass_gamcor : 1;
uint32_t bypass_ogam : 1;
uint32_t force_tf_calculation : 1;
uint32_t bypass_dpp_gamut_remap : 1;
uint32_t bypass_post_csc : 1;
uint32_t clamping_setting : 1;
@ -360,7 +359,6 @@ struct vpe_debug_options {
uint32_t assert_when_not_support : 1;
uint32_t bypass_gamcor : 1;
uint32_t bypass_ogam : 1;
uint32_t force_tf_calculation : 1;
uint32_t bypass_dpp_gamut_remap : 1;
uint32_t bypass_post_csc : 1;
uint32_t clamping_setting : 1;

View file

@ -48,7 +48,6 @@ vpe_files = files(
'src/core/inc/reg_helper.h',
'src/core/inc/vpe_priv.h',
'src/core/inc/vpe_command.h',
'src/core/inc/color_pwl.h',
'src/core/inc/color_gamut.h',
'src/core/inc/vpe_assert.h',
'src/core/inc/vpec.h',

View file

@ -25,7 +25,6 @@
#include "color.h"
#include "hw_shared.h"
#include "color_pwl.h"
#ifdef __cplusplus
extern "C" {
@ -127,9 +126,6 @@ bool vpe10_cm_helper_translate_curve_to_hw_format(
bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
const struct transfer_func *output_tf, struct pwl_params *lut_params);
void vpe10_cm_get_tf_pwl_params(const struct transfer_func *output_tf,
struct pwl_params **lut_params, enum cm_type vpe_cm_type);
#ifdef __cplusplus
}
#endif

View file

@ -519,31 +519,6 @@ bool vpe10_cm_helper_translate_curve_to_degamma_hw_format(
return true;
}
void vpe10_cm_get_tf_pwl_params(
const struct transfer_func *output_tf, struct pwl_params **lut_params, enum cm_type vpe_cm_type)
{
int table_index = 0;
switch (output_tf->tf) {
case TRANSFER_FUNC_SRGB:
table_index = 0;
break;
case TRANSFER_FUNC_BT1886:
table_index = 1;
break;
case TRANSFER_FUNC_PQ2084:
table_index = 2;
break;
case TRANSFER_FUNC_BT709:
table_index = 3;
break;
default:
*lut_params = NULL;
return;
}
*lut_params = &tf_pwl_param_table[vpe_cm_type][table_index];
}
#define REG_FIELD_VALUE_CM(field, value) \
((uint32_t)((value) << reg->shifts.field) & reg->masks.field)
#define REG_FIELD_MASK_CM(field) reg->masks.field

View file

@ -4,8 +4,6 @@
#include "vpe10/inc/vpe10_cm_common.h"
#include "vpe10_dpp.h"
#include "conversion.h"
#include "color_pwl.h"
#define CTX vpe10_dpp
#define CTX_BASE dpp
@ -196,15 +194,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) {
if (!input_tf->use_pre_calculated_table || dpp->vpe_priv->init.debug.force_tf_calculation) {
vpe10_cm_helper_translate_curve_to_degamma_hw_format(input_tf, &dpp->degamma_params);
params = &dpp->degamma_params;
} else {
vpe10_cm_get_tf_pwl_params(input_tf, &params, CM_DEGAM);
VPE_ASSERT(params != NULL);
if (params == NULL)
return;
}
vpe10_cm_helper_translate_curve_to_degamma_hw_format(input_tf, &dpp->degamma_params);
params = &dpp->degamma_params;
}
vpe10_dpp_program_gamcor_lut(dpp, params);
}

View file

@ -29,7 +29,6 @@
#include "vpe10_cm_common.h"
#include "fixed31_32.h"
#include "conversion.h"
#include "color_pwl.h"
#define CTX_BASE mpc
#define CTX vpe10_mpc
@ -1275,18 +1274,10 @@ void vpe10_mpc_set_output_transfer_func(struct mpc *mpc, struct output_ctx *outp
if (ret == false && output_ctx->output_tf) {
// No support HWPWL as it is legacy
if (output_ctx->output_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
if (!output_ctx->output_tf->use_pre_calculated_table ||
mpc->vpe_priv->init.debug.force_tf_calculation) {
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);
params = &mpc->regamma_params;
} else {
vpe10_cm_get_tf_pwl_params(output_ctx->output_tf, &params, CM_REGAM);
VPE_ASSERT(params != NULL);
if (params == NULL)
return;
}
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);
params = &mpc->regamma_params;
}
/* there are no ROM LUTs in OUTGAM */
if (output_ctx->output_tf->type == TF_TYPE_PREDEFINED)
@ -1304,22 +1295,13 @@ void vpe10_mpc_set_blend_lut(struct mpc *mpc, const struct transfer_func *blend_
gamma_type = blend_tf->cm_gamma_type;
if (blend_tf->use_pre_calculated_table) {
vpe10_cm_get_tf_pwl_params(blend_tf, &blend_lut, gamma_type);
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
else
vpe10_cm_helper_translate_curve_to_hw_format(blend_tf, &mpc->blender_params, false);
VPE_ASSERT(blend_lut != NULL);
if (blend_lut == NULL)
return;
} else {
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
else
vpe10_cm_helper_translate_curve_to_hw_format(
blend_tf, &mpc->blender_params, false);
blend_lut = &mpc->blender_params;
}
blend_lut = &mpc->blender_params;
}
mpc->funcs->program_1dlut(mpc, blend_lut, gamma_type);

View file

@ -351,7 +351,6 @@ enum vpe_status vpe10_construct_resource(struct vpe_priv *vpe_priv, struct resou
res->program_frontend = vpe10_program_frontend;
res->program_backend = vpe10_program_backend;
res->get_bufs_req = vpe10_get_bufs_req;
res->get_tf_pwl_params = vpe10_cm_get_tf_pwl_params;
return VPE_STATUS_OK;
err:

View file

@ -179,7 +179,6 @@ enum vpe_status vpe11_construct_resource(struct vpe_priv *vpe_priv, struct resou
res->program_frontend = vpe10_program_frontend;
res->program_backend = vpe10_program_backend;
res->get_bufs_req = vpe10_get_bufs_req;
res->get_tf_pwl_params = vpe10_cm_get_tf_pwl_params;
return VPE_STATUS_OK;
err:

View file

@ -32,7 +32,6 @@
#include "common.h"
#include "custom_float.h"
#include "color_test_values.h"
#include "color_pwl.h"
#include "3dlut_builder.h"
#include "shaper_builder.h"
@ -155,8 +154,9 @@ static bool color_update_regamma_tf(struct vpe_priv *vpe_priv,
struct fixed31_32 y_scale, struct fixed31_32 y_bias, bool can_bypass,
struct transfer_func* output_tf)
{
struct pwl_params *params = NULL;
struct pwl_params *params = NULL;
bool ret = true;
if (can_bypass) {
output_tf->type = TF_TYPE_BYPASS;
return true;
@ -180,25 +180,10 @@ static bool color_update_regamma_tf(struct vpe_priv *vpe_priv,
break;
}
if (!vpe_priv->init.debug.force_tf_calculation &&
x_scale.value == vpe_fixpt_one.value &&
y_scale.value == vpe_fixpt_one.value &&
y_bias.value == vpe_fixpt_zero.value)
vpe_priv->resource.get_tf_pwl_params(output_tf, &params, CM_REGAM);
ret = vpe_color_calculate_regamma_params(
vpe_priv, x_scale, y_scale, &vpe_priv->cal_buffer, output_tf);
if (params)
output_tf->use_pre_calculated_table = true;
else
output_tf->use_pre_calculated_table = false;
if (!output_tf->use_pre_calculated_table)
vpe_color_calculate_regamma_params(vpe_priv,
x_scale,
y_scale,
&vpe_priv->cal_buffer,
output_tf);
return true;
return ret;
}
static bool color_update_degamma_tf(struct vpe_priv *vpe_priv,
@ -232,23 +217,7 @@ static bool color_update_degamma_tf(struct vpe_priv *vpe_priv,
break;
}
if (!vpe_priv->init.debug.force_tf_calculation &&
x_scale.value == vpe_fixpt_one.value &&
y_scale.value == vpe_fixpt_one.value &&
y_bias.value == vpe_fixpt_zero.value)
vpe_priv->resource.get_tf_pwl_params(input_tf, &params, CM_DEGAM);
if (params)
input_tf->use_pre_calculated_table = true;
else
input_tf->use_pre_calculated_table = false;
if (!input_tf->use_pre_calculated_table) {
vpe_color_calculate_degamma_params(vpe_priv,
x_scale,
y_scale,
input_tf);
}
ret = vpe_color_calculate_degamma_params(vpe_priv, x_scale, y_scale, input_tf);
return ret;
}

View file

@ -155,7 +155,6 @@ struct transfer_func {
struct pwl_params pwl;
struct transfer_func_distributed_points tf_pts;
};
bool use_pre_calculated_table;
};
enum color_white_point_type {

File diff suppressed because it is too large Load diff

View file

@ -95,9 +95,6 @@ struct resource {
void (*get_bufs_req)(struct vpe_priv *vpe_priv, struct vpe_bufs_req *req);
void (*get_tf_pwl_params)(const struct transfer_func *output_tf, struct pwl_params **lut_params,
enum cm_type vpe_cm_type);
// Indicates the nominal range hdr input content should be in during processing.
int internal_hdr_normalization;

View file

@ -59,7 +59,6 @@ static const struct vpe_debug_options debug_defaults = {
.mpc = false,
},
},
.force_tf_calculation = 1,
.expansion_mode = 1,
.clamping_setting = 1,
.clamping_params =

View file

@ -89,9 +89,6 @@ static void override_debug_option(
if (user_debug->flags.bypass_post_csc)
debug->bypass_post_csc = user_debug->bypass_post_csc;
if (user_debug->flags.force_tf_calculation)
debug->force_tf_calculation = user_debug->force_tf_calculation;
if (user_debug->flags.clamping_setting) {
debug->clamping_setting = user_debug->clamping_setting;
debug->clamping_params = user_debug->clamping_params;