radv/video: Disable rate control modes for H265 encode on VCN1

VCN1 doesn't have FW interface to enable cu_qp_delta with rate control
disabled, which means we can only support either rate control enabled or
disabled. Spec requires VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR
to always be supported, thus the rate control modes needs to be disabled
on VCN1.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36353>
This commit is contained in:
David Rosca 2025-07-24 13:14:27 +02:00 committed by Marge Bot
parent 627fdb368d
commit 1dda9d56cb
2 changed files with 11 additions and 7 deletions

View file

@ -1011,8 +1011,12 @@ radv_GetPhysicalDeviceVideoCapabilitiesKHR(VkPhysicalDevice physicalDevice, cons
pCapabilities->pNext, VIDEO_ENCODE_H265_CAPABILITIES_KHR);
pCapabilities->pictureAccessGranularity.width = VK_VIDEO_H265_CTU_MAX_WIDTH;
if (enc_caps)
if (enc_caps) {
enc_caps->encodeInputPictureGranularity = pCapabilities->pictureAccessGranularity;
/* VCN1 can't enable rate control modes due to missing cu_qp_delta FW interface. */
if (pdev->enc_hw_ver == RADV_VIDEO_ENC_HW_1_2)
enc_caps->rateControlModes = VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR;
}
ext->flags = VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_KHR |
VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR |

View file

@ -3048,13 +3048,13 @@ radv_video_patch_encode_session_parameters(struct radv_device *device, struct vk
}
break;
case VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR: {
/*
* AMD firmware requires these flags to be set in h265 with RC modes,
* VCN 3 need 1.27 and VCN 4 needs 1.7 or newer to pass the CTS tests,
* dEQP-VK.video.encode.h265_rc_*.
*/
for (unsigned i = 0; i < params->h265_enc.h265_pps_count; i++) {
params->h265_enc.h265_pps[i].base.flags.cu_qp_delta_enabled_flag = 1;
/* cu_qp_delta needs to be enabled if rate control is enabled. VCN2 and newer can also enable
* it with rate control disabled. Since we don't know what rate control will be used, we
* need to always force enable it.
* On VCN1 rate control modes are disabled.
*/
params->h265_enc.h265_pps[i].base.flags.cu_qp_delta_enabled_flag = !!(pdev->enc_hw_ver >= RADV_VIDEO_ENC_HW_2);
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.flags.dependent_slice_segments_enabled_flag = 1;