radv/video: Support encoding multiple slices

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12285
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35070>
This commit is contained in:
David Rosca 2025-05-20 13:40:17 +02:00 committed by Marge Bot
parent b036d2ded2
commit 63e952ff2c
2 changed files with 9 additions and 4 deletions

View file

@ -750,7 +750,7 @@ radv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, cons
ext->flags = VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_KHR | ext->flags = VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_KHR |
VK_VIDEO_ENCODE_H264_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR; VK_VIDEO_ENCODE_H264_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR;
ext->maxLevelIdc = cap ? cap->max_level : 0; ext->maxLevelIdc = cap ? cap->max_level : 0;
ext->maxSliceCount = 1; ext->maxSliceCount = 128;
ext->maxPPictureL0ReferenceCount = 1; ext->maxPPictureL0ReferenceCount = 1;
ext->maxBPictureL0ReferenceCount = pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_3 ? 1 : 0; ext->maxBPictureL0ReferenceCount = pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_3 ? 1 : 0;
ext->maxL1ReferenceCount = pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_3 ? 1 : 0; ext->maxL1ReferenceCount = pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_3 ? 1 : 0;
@ -795,7 +795,7 @@ radv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, cons
ext->flags = VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR; ext->flags = VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR;
ext->maxLevelIdc = cap ? cap->max_level : 0; ext->maxLevelIdc = cap ? cap->max_level : 0;
ext->maxSliceSegmentCount = 1; ext->maxSliceSegmentCount = 128;
ext->maxTiles.width = 1; ext->maxTiles.width = 1;
ext->maxTiles.height = 1; ext->maxTiles.height = 1;
ext->ctbSizes = VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_KHR; ext->ctbSizes = VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_KHR;

View file

@ -426,11 +426,13 @@ radv_enc_slice_control(struct radv_cmd_buffer *cmd_buffer, const struct VkVideoE
{ {
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
const struct radv_physical_device *pdev = radv_device_physical(device); const struct radv_physical_device *pdev = radv_device_physical(device);
const struct VkVideoEncodeH264PictureInfoKHR *h264_picture_info =
vk_find_struct_const(enc_info->pNext, VIDEO_ENCODE_H264_PICTURE_INFO_KHR);
uint32_t num_mbs_in_slice; uint32_t num_mbs_in_slice;
uint32_t width_in_mbs = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.width, 16); uint32_t width_in_mbs = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.width, 16);
uint32_t height_in_mbs = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.height, 16); uint32_t height_in_mbs = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.height, 16);
num_mbs_in_slice = width_in_mbs * height_in_mbs; num_mbs_in_slice = DIV_ROUND_UP(width_in_mbs * height_in_mbs, h264_picture_info->naluSliceEntryCount);
RADEON_ENC_BEGIN(pdev->vcn_enc_cmds.slice_control_h264); RADEON_ENC_BEGIN(pdev->vcn_enc_cmds.slice_control_h264);
RADEON_ENC_CS(RENCODE_H264_SLICE_CONTROL_MODE_FIXED_MBS); // slice control mode RADEON_ENC_CS(RENCODE_H264_SLICE_CONTROL_MODE_FIXED_MBS); // slice control mode
@ -503,12 +505,14 @@ radv_enc_slice_control_hevc(struct radv_cmd_buffer *cmd_buffer, const struct VkV
{ {
struct radv_device *device = radv_cmd_buffer_device(cmd_buffer); struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
const struct radv_physical_device *pdev = radv_device_physical(device); const struct radv_physical_device *pdev = radv_device_physical(device);
const struct VkVideoEncodeH265PictureInfoKHR *h265_picture_info =
vk_find_struct_const(enc_info->pNext, VIDEO_ENCODE_H265_PICTURE_INFO_KHR);
uint32_t width_in_ctb, height_in_ctb, num_ctbs_in_slice; uint32_t width_in_ctb, height_in_ctb, num_ctbs_in_slice;
width_in_ctb = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.width, 64); width_in_ctb = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.width, 64);
height_in_ctb = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.height, 64); height_in_ctb = DIV_ROUND_UP(enc_info->srcPictureResource.codedExtent.height, 64);
num_ctbs_in_slice = width_in_ctb * height_in_ctb; num_ctbs_in_slice = DIV_ROUND_UP(width_in_ctb * height_in_ctb, h265_picture_info->naluSliceSegmentEntryCount);
RADEON_ENC_BEGIN(pdev->vcn_enc_cmds.slice_control_hevc); RADEON_ENC_BEGIN(pdev->vcn_enc_cmds.slice_control_hevc);
RADEON_ENC_CS(RENCODE_HEVC_SLICE_CONTROL_MODE_FIXED_CTBS); RADEON_ENC_CS(RENCODE_HEVC_SLICE_CONTROL_MODE_FIXED_CTBS);
@ -1881,6 +1885,7 @@ radv_video_patch_encode_session_parameters(struct vk_video_session_parameters *p
params->h265_enc.h265_pps[i].base.flags.cu_qp_delta_enabled_flag = 1; params->h265_enc.h265_pps[i].base.flags.cu_qp_delta_enabled_flag = 1;
params->h265_enc.h265_pps[i].base.diff_cu_qp_delta_depth = 0; params->h265_enc.h265_pps[i].base.diff_cu_qp_delta_depth = 0;
params->h265_enc.h265_pps[i].base.init_qp_minus26 = 0; params->h265_enc.h265_pps[i].base.init_qp_minus26 = 0;
params->h265_enc.h265_pps[i].base.flags.dependent_slice_segments_enabled_flag = 1;
} }
break; break;
} }