radv: determine supported syncobj types directly in the physical device

To remove the dependency on the winsys.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41755>
This commit is contained in:
Samuel Pitoiset 2026-05-22 11:19:15 +02:00 committed by Marge Bot
parent b5403ff331
commit 473551ecd0
5 changed files with 24 additions and 36 deletions

View file

@ -16,6 +16,7 @@
#include <sys/sysmacros.h>
#endif
#include "vk_drm_syncobj.h"
#include "vk_log.h"
#include "vk_shader_module.h"
@ -2530,9 +2531,25 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
goto fail_base;
}
pdev->vk.supported_sync_types = pdev->ws->get_sync_types(pdev->ws);
pdev->ws->query_info(pdev->ws, &pdev->info);
pdev->syncobj_sync_type = vk_drm_syncobj_get_type(pdev->ws->get_fd(pdev->ws));
int num_sync_types = 0;
if (pdev->syncobj_sync_type.features) {
if (!pdev->info.has_timeline_syncobj && pdev->syncobj_sync_type.features & VK_SYNC_FEATURE_TIMELINE) {
pdev->syncobj_sync_type.get_value = NULL;
pdev->syncobj_sync_type.features &= ~VK_SYNC_FEATURE_TIMELINE;
}
pdev->sync_types[num_sync_types++] = &pdev->syncobj_sync_type;
if (!(pdev->syncobj_sync_type.features & VK_SYNC_FEATURE_TIMELINE)) {
pdev->emulated_timeline_sync_type = vk_sync_timeline_get_type(&pdev->syncobj_sync_type);
pdev->sync_types[num_sync_types++] = &pdev->emulated_timeline_sync_type.sync;
}
}
pdev->sync_types[num_sync_types++] = NULL;
pdev->vk.supported_sync_types = pdev->sync_types;
for (uint32_t p = VK_QUEUE_GLOBAL_PRIORITY_LOW; p <= VK_QUEUE_GLOBAL_PRIORITY_REALTIME; p <<= 1) {
if (pdev->ws->ctx_is_priority_permitted(pdev->ws, vk_to_radeon_priority(p)) != VK_SUCCESS)
continue;

View file

@ -25,6 +25,8 @@
#include "nir_shader_compiler_options.h"
#include "vk_physical_device.h"
#include "vk_sync.h"
#include "vk_sync_timeline.h"
#ifndef _WIN32
#include <xf86drm.h>
@ -185,6 +187,10 @@ struct radv_physical_device {
uint32_t max_array_layers;
} image_props;
struct vk_sync_type syncobj_sync_type;
struct vk_sync_timeline_type emulated_timeline_sync_type;
const struct vk_sync_type *sync_types[3];
};
VK_DEFINE_HANDLE_CASTS(radv_physical_device, vk.base, VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE)

View file

@ -315,8 +315,6 @@ struct radeon_winsys {
int (*get_fd)(struct radeon_winsys *ws);
const struct vk_sync_type *const *(*get_sync_types)(struct radeon_winsys *ws);
struct util_sync_provider *(*get_sync_provider)(struct radeon_winsys *ws);
VkResult (*copy_sync_payloads)(struct vk_device *device,

View file

@ -188,13 +188,6 @@ radv_amdgpu_winsys_get_fd(struct radeon_winsys *rws)
return ws->fd;
}
static const struct vk_sync_type *const *
radv_amdgpu_winsys_get_sync_types(struct radeon_winsys *rws)
{
struct radv_amdgpu_winsys *ws = (struct radv_amdgpu_winsys *)rws;
return ws->sync_types;
}
static struct util_sync_provider *
radv_amdgpu_winsys_get_sync_provider(struct radeon_winsys *rws)
{
@ -332,27 +325,6 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags,
fprintf(stderr, "radv/amdgpu: Failed to create /tmp/radv_bo_history.log.\n");
}
int num_sync_types = 0;
ws->syncobj_sync_type = vk_drm_syncobj_get_type_from_provider(ac_drm_device_get_sync_provider(dev));
if (ws->syncobj_sync_type.features) {
if (!ws->info.has_timeline_syncobj && ws->syncobj_sync_type.features & VK_SYNC_FEATURE_TIMELINE) {
/* Disable timeline feature if it was disabled in the driver. */
assert(is_virtio);
ws->syncobj_sync_type.get_value = NULL;
ws->syncobj_sync_type.features &= ~VK_SYNC_FEATURE_TIMELINE;
}
ws->sync_types[num_sync_types++] = &ws->syncobj_sync_type;
if (!(ws->syncobj_sync_type.features & VK_SYNC_FEATURE_TIMELINE)) {
ws->emulated_timeline_sync_type = vk_sync_timeline_get_type(&ws->syncobj_sync_type);
ws->sync_types[num_sync_types++] = &ws->emulated_timeline_sync_type.sync;
}
}
ws->sync_types[num_sync_types++] = NULL;
assert(num_sync_types <= ARRAY_SIZE(ws->sync_types));
if (ac_drm_cs_create_syncobj2(ws->dev, 0, &ws->vm_timeline_syncobj))
goto winsys_fail;
@ -370,7 +342,6 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags,
ws->base.query_gpuvm_fault = radv_amdgpu_winsys_query_gpuvm_fault;
ws->base.destroy = radv_amdgpu_winsys_destroy;
ws->base.get_fd = radv_amdgpu_winsys_get_fd;
ws->base.get_sync_types = radv_amdgpu_winsys_get_sync_types;
ws->base.get_sync_provider = radv_amdgpu_winsys_get_sync_provider;
ws->base.copy_sync_payloads = vk_drm_syncobj_copy_payloads;
ws->base.reserve_vmid = radv_amdgpu_winsys_reserve_vmid;

View file

@ -54,10 +54,6 @@ struct radv_amdgpu_winsys {
struct u_rwlock log_bo_list_lock;
struct list_head log_bo_list;
const struct vk_sync_type *sync_types[3];
struct vk_sync_type syncobj_sync_type;
struct vk_sync_timeline_type emulated_timeline_sync_type;
simple_mtx_t vm_ioctl_lock;
uint32_t vm_timeline_syncobj;
uint64_t vm_timeline_seq_num;