radv/video: Use ac_uvd_alloc_stream_handle

ac_uvd_alloc_stream_handle tries to avoid collisions in the case
when PID is not unique (eg. in sandboxes like Flatpak).

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12607
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34807>
This commit is contained in:
David Rosca 2025-05-05 09:31:04 +02:00 committed by Marge Bot
parent 69455e8208
commit 5fee04bcae
2 changed files with 4 additions and 17 deletions

View file

@ -17,6 +17,7 @@
#include "radv_instance.h"
#include "radv_queue.h"
#include "radv_radeon_winsys.h"
#include "ac_uvd_dec.h"
#include "ac_vcn_enc.h"
#include "wsi_common.h"
@ -177,8 +178,7 @@ struct radv_physical_device {
} vid_dec_reg;
enum amd_ip_type vid_decode_ip;
uint32_t vid_addr_gfx_mode;
uint32_t stream_handle_base;
uint32_t stream_handle_counter;
struct ac_uvd_stream_handle stream_handle;
uint32_t av1_version;
rvcn_enc_cmd_t vcn_enc_cmds;
enum radv_video_enc_hw_ver enc_hw_ver;

View file

@ -184,16 +184,6 @@ radv_vcn_sq_start(struct radv_cmd_buffer *cmd_buffer)
memset(cmd_buffer->video.decode_buffer, 0, sizeof(struct rvcn_decode_buffer_s));
}
/* generate an stream handle */
static unsigned
radv_vid_alloc_stream_handle(struct radv_physical_device *pdev)
{
unsigned stream_handle = pdev->stream_handle_base;
stream_handle ^= ++pdev->stream_handle_counter;
return stream_handle;
}
static void
init_uvd_decoder(struct radv_physical_device *pdev)
{
@ -273,10 +263,7 @@ radv_init_physical_device_decoder(struct radv_physical_device *pdev)
pdev->vid_decode_ip = AMD_IP_VCN_DEC;
pdev->av1_version = RDECODE_AV1_VER_0;
pdev->stream_handle_counter = 0;
pdev->stream_handle_base = 0;
pdev->stream_handle_base = util_bitreverse(getpid());
ac_uvd_init_stream_handle(&pdev->stream_handle);
pdev->vid_addr_gfx_mode = RDECODE_ARRAY_MODE_LINEAR;
@ -520,7 +507,7 @@ radv_CreateVideoSessionKHR(VkDevice _device, const VkVideoSessionCreateInfoKHR *
return VK_ERROR_FEATURE_NOT_PRESENT;
}
vid->stream_handle = radv_vid_alloc_stream_handle(pdev);
vid->stream_handle = ac_uvd_alloc_stream_handle(&pdev->stream_handle);
vid->dbg_frame_cnt = 0;
vid->db_alignment = radv_video_get_db_alignment(
pdev, vid->vk.max_coded.width,