mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-27 12:14:10 +08:00
amd/vpelib: Refactor 3D LUT code
Refactor 3D LUT code and tested with corresponding test cases Reviewed-by: Roy Chan <Roy.Chan@amd.com> Acked-by: Chih-Wei Chien <Chih-Wei.Chien@amd.com> Signed-off-by: Mike Hsieh <Mike.Hsieh@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31693>
This commit is contained in:
parent
338dd3b687
commit
b010a2eaf6
@ -856,7 +856,7 @@ void vpe10_mpc_program_3dlut(struct mpc *mpc, const struct tetrahedral_params *p
|
||||
// always use LUT_RAM_A except for bypass mode which is not the case here
|
||||
mode = LUT_RAM_A;
|
||||
|
||||
is_17x17x17 = !params->use_tetrahedral_9;
|
||||
is_17x17x17 = (params->lut_dim == LUT_DIM_17);
|
||||
is_12bits_color_channel = params->use_12bits;
|
||||
if (is_17x17x17) {
|
||||
lut0 = params->tetrahedral_17.lut0;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "3dlut_builder.h"
|
||||
|
||||
static void convert_3dlut_to_tetrahedral_params(
|
||||
struct vpe_rgb *rgb, bool is_17x17x17, bool is_12_bits, struct tetrahedral_params *params)
|
||||
struct vpe_rgb *rgb, bool is_12_bits, struct tetrahedral_params *params)
|
||||
{
|
||||
struct vpe_rgb *lut0;
|
||||
struct vpe_rgb *lut1;
|
||||
@ -35,18 +35,28 @@ static void convert_3dlut_to_tetrahedral_params(
|
||||
|
||||
int num_values;
|
||||
|
||||
if (is_17x17x17 == false) {
|
||||
switch (params->lut_dim) {
|
||||
case LUT_DIM_9:
|
||||
lut0 = params->tetrahedral_9.lut0;
|
||||
lut1 = params->tetrahedral_9.lut1;
|
||||
lut2 = params->tetrahedral_9.lut2;
|
||||
lut3 = params->tetrahedral_9.lut3;
|
||||
num_values = LUT3D_SIZE_9x9x9;
|
||||
} else {
|
||||
break;
|
||||
case LUT_DIM_17:
|
||||
lut0 = params->tetrahedral_17.lut0;
|
||||
lut1 = params->tetrahedral_17.lut1;
|
||||
lut2 = params->tetrahedral_17.lut2;
|
||||
lut3 = params->tetrahedral_17.lut3;
|
||||
num_values = LUT3D_SIZE_17x17x17;
|
||||
break;
|
||||
default:
|
||||
lut0 = params->tetrahedral_17.lut0;
|
||||
lut1 = params->tetrahedral_17.lut1;
|
||||
lut2 = params->tetrahedral_17.lut2;
|
||||
lut3 = params->tetrahedral_17.lut3;
|
||||
num_values = LUT3D_SIZE_17x17x17;
|
||||
VPE_ASSERT(false);
|
||||
}
|
||||
|
||||
for (lut_i = 0, i = 0; i < num_values - 4; lut_i++, i += 4) {
|
||||
@ -70,29 +80,42 @@ static void convert_3dlut_to_tetrahedral_params(
|
||||
lut0[lut_i].green = rgb[i].green;
|
||||
lut0[lut_i].blue = rgb[i].blue;
|
||||
|
||||
params->use_12bits = is_12_bits;
|
||||
params->use_tetrahedral_9 = !is_17x17x17;
|
||||
params->use_12bits = is_12_bits;
|
||||
}
|
||||
|
||||
bool vpe_convert_to_tetrahedral(
|
||||
struct vpe_priv *vpe_priv, uint16_t rgb_lib[17 * 17 * 17 * 3], struct vpe_3dlut *params)
|
||||
struct vpe_priv *vpe_priv, uint16_t *rgb_lib, uint16_t lut_dim, struct vpe_3dlut *params)
|
||||
{
|
||||
bool ret = false;
|
||||
struct vpe_rgb *rgb_area = NULL;
|
||||
int ind = 0;
|
||||
int ind_lut = 0;
|
||||
int nir, nig, nib;
|
||||
int effective_lut_dim;
|
||||
|
||||
rgb_area = (struct vpe_rgb *)vpe_zalloc(sizeof(struct vpe_rgb) * 17 * 17 * 17);
|
||||
switch(lut_dim) {
|
||||
case 9:
|
||||
params->lut_3d.lut_dim = LUT_DIM_9;
|
||||
effective_lut_dim = 17;
|
||||
break;
|
||||
case 17:
|
||||
params->lut_3d.lut_dim = LUT_DIM_17;
|
||||
effective_lut_dim = 17;
|
||||
break;
|
||||
default:
|
||||
params->lut_3d.lut_dim = LUT_DIM_INVALID;
|
||||
VPE_ASSERT(false);
|
||||
goto release;
|
||||
}
|
||||
|
||||
rgb_area = (struct vpe_rgb *)vpe_zalloc(sizeof(struct vpe_rgb) * effective_lut_dim * effective_lut_dim * effective_lut_dim);
|
||||
if (rgb_area == NULL)
|
||||
goto release;
|
||||
|
||||
memset(rgb_area, 0, 17 * 17 * 17 * sizeof(struct vpe_rgb));
|
||||
|
||||
for (nib = 0; nib < 17; nib++) {
|
||||
for (nig = 0; nig < 17; nig++) {
|
||||
for (nir = 0; nir < 17; nir++) {
|
||||
ind_lut = 3 * (nib + 17 * nig + 289 * nir);
|
||||
for (nib = 0; nib < effective_lut_dim; nib++) {
|
||||
for (nig = 0; nig < effective_lut_dim; nig++) {
|
||||
for (nir = 0; nir < effective_lut_dim; nir++) {
|
||||
ind_lut = 3 * (nib + effective_lut_dim * nig + effective_lut_dim * effective_lut_dim * nir);
|
||||
|
||||
rgb_area[ind].red = rgb_lib[ind_lut + 0];
|
||||
rgb_area[ind].green = rgb_lib[ind_lut + 1];
|
||||
@ -101,7 +124,8 @@ bool vpe_convert_to_tetrahedral(
|
||||
}
|
||||
}
|
||||
}
|
||||
convert_3dlut_to_tetrahedral_params(rgb_area, true, true, ¶ms->lut_3d);
|
||||
|
||||
convert_3dlut_to_tetrahedral_params(rgb_area, true, ¶ms->lut_3d);
|
||||
|
||||
vpe_free(rgb_area);
|
||||
ret = true;
|
||||
|
@ -691,7 +691,8 @@ enum vpe_status vpe_color_update_3dlut(
|
||||
|
||||
if (update) {
|
||||
vpe_convert_to_tetrahedral(
|
||||
vpe_priv, stream_ctx->stream.tm_params.lut_data, stream_ctx->lut3d_func);
|
||||
vpe_priv, stream_ctx->stream.tm_params.lut_data,
|
||||
stream_ctx->stream.tm_params.lut_dim, stream_ctx->lut3d_func);
|
||||
for (int i = 0; i < vpe_priv->pub.caps->resource_caps.num_mpc_3dlut; i++) {
|
||||
stream_ctx->lut3d_func->dirty[i] = true;
|
||||
stream_ctx->lut3d_func->config_cache[i].cached = false;
|
||||
|
@ -31,4 +31,4 @@
|
||||
#define LUT3D_SIZE_9x9x9 729
|
||||
|
||||
bool vpe_convert_to_tetrahedral(
|
||||
struct vpe_priv *vpe_priv, uint16_t rgb[17 * 17 * 17 * 3], struct vpe_3dlut *params);
|
||||
struct vpe_priv *vpe_priv, uint16_t* rgb, uint16_t lut_dim, struct vpe_3dlut *params);
|
||||
|
@ -154,6 +154,11 @@ enum gamut_remap_select {
|
||||
GAMUT_REMAP_COMA_COEFF,
|
||||
};
|
||||
|
||||
enum lut_dimension {
|
||||
LUT_DIM_INVALID = 0,
|
||||
LUT_DIM_9 = 9,
|
||||
LUT_DIM_17 = 17,
|
||||
};
|
||||
struct vpe_rgb {
|
||||
uint32_t red;
|
||||
uint32_t green;
|
||||
@ -178,8 +183,8 @@ struct tetrahedral_params {
|
||||
struct tetrahedral_17x17x17 tetrahedral_17;
|
||||
struct tetrahedral_9x9x9 tetrahedral_9;
|
||||
};
|
||||
bool use_tetrahedral_9;
|
||||
bool use_12bits;
|
||||
enum lut_dimension lut_dim;
|
||||
bool use_12bits;
|
||||
};
|
||||
|
||||
enum vpe_lut_mode {
|
||||
|
Loading…
Reference in New Issue
Block a user