radv/video: Introduce two levels of write_memory support

Print warning when using write_memory with firmwares that require
PCIe atomics support.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
(cherry picked from commit 8e1d74bbb4)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
This commit is contained in:
David Rosca 2025-10-31 15:12:00 +01:00
parent 12c82aaa82
commit 629a0a4dcc
3 changed files with 35 additions and 13 deletions

View file

@ -149,10 +149,16 @@ radv_vcn_write_memory(struct radv_cmd_buffer *cmd_buffer, uint64_t va, unsigned
struct radv_physical_device *pdev = radv_device_physical(device);
struct rvcn_sq_var sq;
struct radv_cmd_stream *cs = cmd_buffer->cs;
enum radv_video_write_memory_support support = radv_video_write_memory_supported(pdev);
if (!radv_video_write_memory_supported(pdev))
if (support == RADV_VIDEO_WRITE_MEMORY_SUPPORT_NONE)
return;
if (support == RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS) {
fprintf(stderr, "radv: VCN WRITE_MEMORY requires PCIe atomics support. Expect issues "
"if PCIe atomics are not enabled on current device.\n");
}
bool separate_queue = pdev->vid_decode_ip != AMD_IP_VCN_UNIFIED;
if (cmd_buffer->qf == RADV_QUEUE_VIDEO_DEC && separate_queue && pdev->vid_dec_reg.data2) {
radeon_check_space(device->ws, cs->b, 8);

View file

@ -73,6 +73,19 @@ struct radv_video_session {
bool session_initialized;
};
/**
* WRITE_MEMORY support in FW.
*
* none: Not supported at all. Old VCN FW and all UVD.
* pcie_atomics: Supported, relies on PCIe atomics.
* full: Supported, works also without PCIe atomics.
*/
enum radv_video_write_memory_support {
RADV_VIDEO_WRITE_MEMORY_SUPPORT_NONE = 0,
RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS,
RADV_VIDEO_WRITE_MEMORY_SUPPORT_FULL,
};
VK_DEFINE_NONDISP_HANDLE_CASTS(radv_video_session, vk.base, VkVideoSessionKHR, VK_OBJECT_TYPE_VIDEO_SESSION_KHR)
void radv_init_physical_device_decoder(struct radv_physical_device *pdev);
@ -98,7 +111,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);
enum radv_video_write_memory_support 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

@ -3456,17 +3456,20 @@ radv_video_encode_qp_map_supported(const struct radv_physical_device *pdev)
return true;
}
bool
enum radv_video_write_memory_support
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;
if (pdev->info.vcn_ip_version >= VCN_5_0_0) {
return RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS;
} else if (pdev->info.vcn_ip_version >= VCN_4_0_0) {
if (pdev->info.vcn_enc_minor_version >= 22)
return RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS;
} else if (pdev->info.vcn_ip_version >= VCN_3_0_0) {
if (pdev->info.vcn_enc_minor_version >= 33)
return RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS;
} else if (pdev->info.vcn_ip_version >= VCN_2_0_0) {
if (pdev->info.vcn_enc_minor_version >= 24)
return RADV_VIDEO_WRITE_MEMORY_SUPPORT_PCIE_ATOMICS;
}
return RADV_VIDEO_WRITE_MEMORY_SUPPORT_NONE;
}