diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c index 638a467de93..68b8491688d 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_enc.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc.c @@ -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; diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc.h b/src/gallium/drivers/radeonsi/radeon_vcn_enc.h index 8a3c165dfbd..cbf7d58f275 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_enc.h +++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc.h @@ -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) diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_enc_1_2.c b/src/gallium/drivers/radeonsi/radeon_vcn_enc_1_2.c index 969a4810e3b..2e11dcfa4ef 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_enc_1_2.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_enc_1_2.c @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c index 53506a09483..6c475e9bd48 100644 --- a/src/gallium/drivers/radeonsi/si_get.c +++ b/src/gallium/drivers/radeonsi/si_get.c @@ -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; }