radeonsi: enable vcn encoder rgb input support

v2: use luma pitch when chroma not available (Ruijing)

Signed-off-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24151>
This commit is contained in:
Thong Thai 2023-07-13 21:04:25 -04:00 committed by Marge Bot
parent 043dcfad04
commit 64eab1f3ae
4 changed files with 43 additions and 9 deletions

View file

@ -223,18 +223,36 @@ static void radeon_vcn_enc_get_input_format_param(struct radeon_encoder *enc,
case PIPE_FORMAT_P010:
enc->enc_pic.enc_input_format.input_color_bit_depth = RENCODE_COLOR_BIT_DEPTH_10_BIT;
enc->enc_pic.enc_input_format.input_color_packing_format = RENCODE_COLOR_PACKING_FORMAT_P010;
enc->enc_pic.enc_input_format.input_chroma_subsampling = RENCODE_CHROMA_SUBSAMPLING_4_2_0;
enc->enc_pic.enc_input_format.input_color_space = RENCODE_COLOR_SPACE_YUV;
break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
enc->enc_pic.enc_input_format.input_color_bit_depth = RENCODE_COLOR_BIT_DEPTH_8_BIT;
enc->enc_pic.enc_input_format.input_chroma_subsampling = RENCODE_CHROMA_SUBSAMPLING_4_4_4;
enc->enc_pic.enc_input_format.input_color_packing_format = RENCODE_COLOR_PACKING_FORMAT_A8R8G8B8;
enc->enc_pic.enc_input_format.input_color_space = RENCODE_COLOR_SPACE_RGB;
break;
break;
case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_R8G8B8X8_UNORM:
enc->enc_pic.enc_input_format.input_color_bit_depth = RENCODE_COLOR_BIT_DEPTH_8_BIT;
enc->enc_pic.enc_input_format.input_chroma_subsampling = RENCODE_CHROMA_SUBSAMPLING_4_4_4;
enc->enc_pic.enc_input_format.input_color_packing_format = RENCODE_COLOR_PACKING_FORMAT_A8B8G8R8;
enc->enc_pic.enc_input_format.input_color_space = RENCODE_COLOR_SPACE_RGB;
break;
case PIPE_FORMAT_NV12: /* FALL THROUGH */
default:
enc->enc_pic.enc_input_format.input_color_bit_depth = RENCODE_COLOR_BIT_DEPTH_8_BIT;
enc->enc_pic.enc_input_format.input_color_packing_format = RENCODE_COLOR_PACKING_FORMAT_NV12;
enc->enc_pic.enc_input_format.input_chroma_subsampling = RENCODE_CHROMA_SUBSAMPLING_4_2_0;
enc->enc_pic.enc_input_format.input_color_space = RENCODE_COLOR_SPACE_YUV;
break;
}
enc->enc_pic.enc_input_format.input_color_volume = RENCODE_COLOR_VOLUME_G22_BT709;
enc->enc_pic.enc_input_format.input_color_range = RENCODE_COLOR_RANGE_FULL;
enc->enc_pic.enc_input_format.input_chroma_subsampling = RENCODE_CHROMA_SUBSAMPLING_4_2_0;
enc->enc_pic.enc_input_format.input_color_volume = RENCODE_COLOR_VOLUME_G22_BT709;
enc->enc_pic.enc_input_format.input_color_range = RENCODE_COLOR_RANGE_FULL;
enc->enc_pic.enc_input_format.input_chroma_location = RENCODE_CHROMA_LOCATION_INTERSTITIAL;
enc->enc_pic.enc_input_format.input_color_space = RENCODE_COLOR_SPACE_YUV;
}
static void radeon_vcn_enc_h264_get_param(struct radeon_encoder *enc,
@ -817,8 +835,16 @@ static void radeon_enc_begin_frame(struct pipe_video_codec *encoder,
}
}
enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma);
enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma);
if (source->buffer_format == PIPE_FORMAT_NV12 ||
source->buffer_format == PIPE_FORMAT_P010 ||
source->buffer_format == PIPE_FORMAT_P016) {
enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma);
enc->get_buffer(vid_buf->resources[1], NULL, &enc->chroma);
}
else {
enc->get_buffer(vid_buf->resources[0], &enc->handle, &enc->luma);
enc->chroma = NULL;
}
enc->need_feedback = false;

View file

@ -171,11 +171,15 @@
#define RENCODE_COLOR_BIT_DEPTH_10_BIT 1
#define RENCODE_CHROMA_SUBSAMPLING_4_2_0 0
#define RENCODE_CHROMA_SUBSAMPLING_4_4_4 1
#define RENCODE_COLOR_PACKING_FORMAT_NV12 0
#define RENCODE_COLOR_PACKING_FORMAT_P010 1
#define RENCODE_COLOR_PACKING_FORMAT_A8R8G8B8 4
#define RENCODE_COLOR_PACKING_FORMAT_A8B8G8R8 7
#define RENCODE_COLOR_SPACE_YUV 0
#define RENCODE_COLOR_SPACE_RGB 1
#define PIPE_ALIGN_IN_BLOCK_SIZE(value, alignment) DIV_ROUND_UP(value, alignment)

View file

@ -1195,14 +1195,16 @@ static void radeon_enc_encode_params(struct radeon_encoder *enc)
enc->enc_pic.enc_params.allowed_max_bitstream_size = enc->bs_size;
enc->enc_pic.enc_params.input_pic_luma_pitch = enc->luma->u.gfx9.surf_pitch;
enc->enc_pic.enc_params.input_pic_chroma_pitch = enc->chroma->u.gfx9.surf_pitch;
enc->enc_pic.enc_params.input_pic_chroma_pitch = enc->chroma ?
enc->chroma->u.gfx9.surf_pitch : enc->luma->u.gfx9.surf_pitch;
enc->enc_pic.enc_params.input_pic_swizzle_mode = enc->luma->u.gfx9.swizzle_mode;
RADEON_ENC_BEGIN(enc->cmd.enc_params);
RADEON_ENC_CS(enc->enc_pic.enc_params.pic_type);
RADEON_ENC_CS(enc->enc_pic.enc_params.allowed_max_bitstream_size);
RADEON_ENC_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->luma->u.gfx9.surf_offset);
RADEON_ENC_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma->u.gfx9.surf_offset);
RADEON_ENC_READ(enc->handle, RADEON_DOMAIN_VRAM, enc->chroma ?
enc->chroma->u.gfx9.surf_offset : enc->luma->u.gfx9.surf_pitch);
RADEON_ENC_CS(enc->enc_pic.enc_params.input_pic_luma_pitch);
RADEON_ENC_CS(enc->enc_pic.enc_params.input_pic_chroma_pitch);
RADEON_ENC_CS(enc->enc_pic.enc_params.input_pic_swizzle_mode);

View file

@ -748,7 +748,9 @@ static int si_get_video_param(struct pipe_screen *screen, enum pipe_video_profil
return 1;
else
return 0;
case PIPE_VIDEO_CAP_EFC_SUPPORTED:
return ((sscreen->info.family >= CHIP_RENOIR) &&
!(sscreen->debug_flags & DBG(NO_EFC)));
default:
return 0;
}