radv/video: Check FW version before using WRITE_MEMORY

Move the version check to separate function so that it can
also be used elsewhere.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36772>
This commit is contained in:
David Rosca 2025-09-24 14:07:33 +02:00 committed by Marge Bot
parent 40c124e67a
commit a8f4a2a9ba
3 changed files with 26 additions and 42 deletions

View file

@ -150,8 +150,7 @@ radv_vcn_write_memory(struct radv_cmd_buffer *cmd_buffer, uint64_t va, unsigned
struct rvcn_sq_var sq;
struct radv_cmd_stream *cs = cmd_buffer->cs;
/* UVD doesn't support events, and probably never will */
if (pdev->vid_decode_ip == AMD_IP_UVD)
if (!radv_video_write_memory_supported(pdev))
return;
bool separate_queue = pdev->vid_decode_ip != AMD_IP_VCN_UNIFIED;
@ -307,28 +306,9 @@ radv_probe_video_decode(struct radv_physical_device *pdev)
if (instance->debug_flags & RADV_DEBUG_NO_VIDEO)
return;
/* The support for decode events are available at the same time as encode */
if (pdev->info.vcn_ip_version >= VCN_5_0_0) {
pdev->video_decode_enabled = true;
} else if (pdev->info.vcn_ip_version >= VCN_4_0_0) {
if (pdev->info.vcn_enc_major_version > 1)
pdev->video_decode_enabled = true;
/* VCN 4 FW 1.22 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_major_version == 1 && pdev->info.vcn_enc_minor_version >= 22)
pdev->video_decode_enabled = true;
} else if (pdev->info.vcn_ip_version >= VCN_3_0_0) {
if (pdev->info.vcn_enc_major_version > 1)
pdev->video_decode_enabled = true;
/* VCN 3 FW 1.33 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_major_version == 1 && pdev->info.vcn_enc_minor_version >= 33)
pdev->video_decode_enabled = true;
} else if (pdev->info.vcn_ip_version >= VCN_2_0_0) {
if (pdev->info.vcn_enc_major_version > 1)
pdev->video_decode_enabled = true;
/* VCN 2 FW 1.24 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_major_version == 1 && pdev->info.vcn_enc_minor_version >= 24)
pdev->video_decode_enabled = true;
}
/* WRITE_MEMORY is needed for SetEvent and is required to pass CTS */
pdev->video_decode_enabled = radv_video_write_memory_supported(pdev);
if (instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE) {
pdev->video_decode_enabled = true;
}

View file

@ -96,6 +96,7 @@ void radv_video_get_enc_dpb_image(struct radv_device *device, const struct VkVid
bool radv_video_decode_vp9_supported(const struct radv_physical_device *pdev);
bool radv_video_encode_av1_supported(const struct radv_physical_device *pdev);
bool radv_video_encode_qp_map_supported(const struct radv_physical_device *pdev);
bool radv_video_write_memory_supported(const struct radv_physical_device *pdev);
uint32_t radv_video_get_qp_map_texel_size(VkVideoCodecOperationFlagBitsKHR codec);
bool radv_check_vcn_fw_version(const struct radv_physical_device *pdev, uint32_t dec, uint32_t enc, uint32_t rev);

View file

@ -75,34 +75,16 @@ radv_probe_video_encode(struct radv_physical_device *pdev)
return;
if (pdev->info.vcn_enc_minor_version < RENCODE_V4_FW_INTERFACE_MINOR_VERSION)
return;
/* VCN 4 FW 1.22 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_minor_version >= 22) {
pdev->video_encode_enabled = true;
return;
}
} else if (pdev->info.vcn_ip_version >= VCN_3_0_0) {
if (pdev->info.vcn_enc_major_version != RENCODE_V3_FW_INTERFACE_MAJOR_VERSION)
return;
if (pdev->info.vcn_enc_minor_version < RENCODE_V3_FW_INTERFACE_MINOR_VERSION)
return;
/* VCN 3 FW 1.33 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_minor_version >= 33) {
pdev->video_encode_enabled = true;
return;
}
} else if (pdev->info.vcn_ip_version >= VCN_2_0_0) {
if (pdev->info.vcn_enc_major_version != RENCODE_V2_FW_INTERFACE_MAJOR_VERSION)
return;
if (pdev->info.vcn_enc_minor_version < RENCODE_V2_FW_INTERFACE_MINOR_VERSION)
return;
/* VCN 2 FW 1.24 has all the necessary pieces to pass CTS */
if (pdev->info.vcn_enc_minor_version >= 24) {
pdev->video_encode_enabled = true;
return;
}
} else {
if (pdev->info.vcn_enc_major_version != RENCODE_FW_INTERFACE_MAJOR_VERSION)
return;
@ -110,6 +92,12 @@ radv_probe_video_encode(struct radv_physical_device *pdev)
return;
}
/* WRITE_MEMORY is needed for SetEvent and is required to pass CTS */
if (radv_video_write_memory_supported(pdev)) {
pdev->video_encode_enabled = true;
return;
}
pdev->video_encode_enabled = !!(instance->perftest_flags & RADV_PERFTEST_VIDEO_ENCODE);
}
@ -3428,3 +3416,18 @@ radv_video_encode_qp_map_supported(const struct radv_physical_device *pdev)
return radv_check_vcn_fw_version(pdev, 9, 9, 28);
return true;
}
bool
radv_video_write_memory_supported(const struct radv_physical_device *pdev)
{
if (pdev->info.vcn_ip_version >= VCN_5_0_0)
return true;
else if (pdev->info.vcn_ip_version >= VCN_4_0_0)
return pdev->info.vcn_enc_minor_version >= 22;
else if (pdev->info.vcn_ip_version >= VCN_3_0_0)
return pdev->info.vcn_enc_minor_version >= 33;
else if (pdev->info.vcn_ip_version >= VCN_2_0_0)
return pdev->info.vcn_enc_minor_version >= 24;
else /* VCN 1 and UVD */
return false;
}