amd/vpelib: skip gamma remap and cs conversion when geometric scaling

[WHY]
When geomtric scaling is enabled, many color features will be skipped.

[HOW]
Skip gamma remap, gamut conversion, blending, tone mapping and color adjustment.

Reviewed-by: Roy Chan <Roy.Chan@amd.com>
Acked-by: Alan Liu <haoping.liu@amd.com>
Signed-off-by: Mike Hsieh <Mike.Hsieh@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27239>
This commit is contained in:
Hsieh, Mike
2023-11-28 15:36:33 +08:00
committed by Marge Bot
parent cb6d928327
commit c8b2e28b66
7 changed files with 122 additions and 11 deletions

View File

@@ -575,7 +575,10 @@ struct vpe_stream {
struct {
uint32_t hdr_metadata : 1;
uint32_t geometric_scaling : 1;
uint32_t geometric_scaling : 1; /* support 1 input stream only,
* if set, gamut/gamma remapping will be disabled,
* blending will be disabled
* dst rect must equal to target rect */
uint32_t reserved : 30;
} flags;
};

View File

@@ -66,6 +66,7 @@ vpe_files = files(
'src/core/inc/color.h',
'src/core/inc/mpc.h',
'src/core/inc/3dlut_builder.h',
'src/core/inc/geometric_scaling.h',
'src/core/inc/cmd_builder.h',
'src/core/inc/background.h',
'src/core/inc/color_gamma.h',
@@ -85,6 +86,7 @@ vpe_files = files(
'src/core/vpelib.c',
'src/core/vpe_desc_writer.c',
'src/core/3dlut_builder.c',
'src/core/geometric_scaling.c',
'src/core/color_test_values.c',
'src/core/resource.c',
'src/core/color_table.c',

View File

@@ -663,7 +663,7 @@ enum vpe_status vpe_color_update_color_space_and_tf(
status = vpe_allocate_cm_memory(vpe_priv, param);
if (status == VPE_STATUS_OK) {
color_check_output_cm_update(vpe_priv, &param->dst_surface.cs);
color_check_output_cm_update(vpe_priv, &vpe_priv->output_ctx.surface.cs);
for (stream_idx = 0; stream_idx < param->num_streams; stream_idx++) {
@@ -680,7 +680,7 @@ enum vpe_status vpe_color_update_color_space_and_tf(
if (stream_ctx->dirty_bits.color_space) {
if (!color_update_input_cs(vpe_priv, stream_ctx->cs,
&param->streams[stream_idx].color_adj, stream_ctx->input_cs,
&stream_ctx->stream.color_adj, stream_ctx->input_cs,
&stream_ctx->color_adjustments, &new_matrix_scaling_factor)) {
vpe_log("err: input cs not being programmed!");
}
@@ -779,10 +779,6 @@ enum vpe_status vpe_color_update_movable_cm(
bool enable_3dlut = stream_ctx->stream.tm_params.enable_3dlut;
if (param->streams->flags.geometric_scaling) {
enable_3dlut = false;
}
if (stream_ctx->update_3dlut) {
uint32_t pqNormFactor;
@@ -838,7 +834,7 @@ enum vpe_status vpe_color_update_movable_cm(
vpe_color_update_shaper(SHAPER_EXP_MAX_IN, stream_ctx->in_shaper_func, enable_3dlut);
vpe_color_build_tm_cs(&stream_ctx->stream.tm_params, param->dst_surface, &tm_out_cs);
vpe_color_build_tm_cs(&stream_ctx->stream.tm_params, vpe_priv->output_ctx.surface, &tm_out_cs);
vpe_color_get_color_space_and_tf(&tm_out_cs, &out_lut_cs, &tf);

View File

@@ -555,7 +555,6 @@ enum vpe_status vpe_check_input_support(struct vpe *vpe, const struct vpe_stream
enum vpe_status vpe_cache_tone_map_params(
struct stream_ctx *stream_ctx, const struct vpe_stream *stream)
{
stream_ctx->update_3dlut = stream_ctx->update_3dlut || stream->tm_params.update_3dlut ||
(stream_ctx->stream.flags.geometric_scaling != stream->flags.geometric_scaling);

View File

@@ -0,0 +1,58 @@
/* Copyright 2022 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom thesrc/core/color.c
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#include "geometric_scaling.h"
/*
* Geometric scaling is to support multiple pass resizing to achieve larger resize ratio.
* User will need to set stream.flags.geometric_scaling = 1
* With the gs flag set to true, VPE will disable following feature
* 1. gamma remapping, the input tf will be used for output tf.
* 2. gamut remapping, the input primiaries/range will be used for output.
* 3. tone mapping, tone mapping will be disabled.
* 4. blending, blending will be disabled.
* 5. color adjustment, color adjustment will be set to default.
*
*/
void geometric_scaling_feature_skip(struct vpe_priv *vpe_priv, const struct vpe_build_param *param)
{
/* copy input cs to output for skiping gamut and gamma conversion */
vpe_priv->output_ctx.surface.cs.primaries = param->streams[0].surface_info.cs.primaries;
vpe_priv->output_ctx.surface.cs.range = param->streams[0].surface_info.cs.range;
vpe_priv->output_ctx.surface.cs.tf = param->streams[0].surface_info.cs.tf;
/* skip tone mapping */
vpe_priv->stream_ctx[0].stream.tm_params.enable_3dlut = false;
/* disable blending */
vpe_priv->stream_ctx[0].stream.blend_info.blending = false;
/* set color adjustment to default */
vpe_priv->stream_ctx[0].stream.color_adj.brightness = 0.0f;
vpe_priv->stream_ctx[0].stream.color_adj.contrast = 1.0f;
vpe_priv->stream_ctx[0].stream.color_adj.hue = 0.0f;
vpe_priv->stream_ctx[0].stream.color_adj.saturation = 1.0f;
}

View File

@@ -0,0 +1,32 @@
/* Copyright 2022 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#pragma once
#include <string.h>
#include "vpelib.h"
#include "vpe_priv.h"
#include "common.h"
void geometric_scaling_feature_skip(struct vpe_priv *vpe_priv, const struct vpe_build_param *param);

View File

@@ -36,6 +36,7 @@
#include "dpp.h"
#include "mpc.h"
#include "opp.h"
#include "geometric_scaling.h"
static void override_debug_option(
struct vpe_debug_options *debug, const struct vpe_debug_options *user_debug)
@@ -182,11 +183,28 @@ void vpe_destroy(struct vpe **vpe)
*vpe = NULL;
}
/*
* Geometric scaling feature has two requirement when enabled:
* 1. only support single input stream, no blending support.
* 2. the target rect must equal to destination rect.
*/
static enum vpe_status validate_geometric_scaling_support(const struct vpe_build_param *param)
{
if(param->num_streams > 1 && param->streams[0].flags.geometric_scaling)
if (param->streams[0].flags.geometric_scaling)
{
return VPE_STATUS_GEOMETRICSCALING_ERROR;
/* only support 1 stream */
if (param->num_streams > 1)
{
return VPE_STATUS_GEOMETRICSCALING_ERROR;
}
/* dest rect must equal to target rect */
if (param->target_rect.height != param->streams[0].scaling_info.dst_rect.height ||
param->target_rect.width != param->streams[0].scaling_info.dst_rect.width ||
param->target_rect.x != param->streams[0].scaling_info.dst_rect.x ||
param->target_rect.y != param->streams[0].scaling_info.dst_rect.y)
return VPE_STATUS_GEOMETRICSCALING_ERROR;
}
return VPE_STATUS_OK;
}
@@ -557,6 +575,9 @@ enum vpe_status vpe_build_commands(
}
if (status == VPE_STATUS_OK) {
if (param->streams->flags.geometric_scaling) {
geometric_scaling_feature_skip(vpe_priv, param);
}
if (bufs->cmd_buf.size == 0 || bufs->emb_buf.size == 0) {
/* Here we directly return without setting ops_support to false