From 473551ecd0becd862d970b1a7b55c76c08372c68 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 22 May 2026 11:19:15 +0200 Subject: [PATCH] radv: determine supported syncobj types directly in the physical device To remove the dependency on the winsys. Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_physical_device.c | 19 +++++++++++- src/amd/vulkan/radv_physical_device.h | 6 ++++ src/amd/vulkan/radv_radeon_winsys.h | 2 -- .../vulkan/winsys/amdgpu/radv_amdgpu_winsys.c | 29 ------------------- .../vulkan/winsys/amdgpu/radv_amdgpu_winsys.h | 4 --- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index 32baccc0203..88e0ee2d078 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -16,6 +16,7 @@ #include #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; diff --git a/src/amd/vulkan/radv_physical_device.h b/src/amd/vulkan/radv_physical_device.h index 565f6ab59d8..96ea1387645 100644 --- a/src/amd/vulkan/radv_physical_device.h +++ b/src/amd/vulkan/radv_physical_device.h @@ -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 @@ -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) diff --git a/src/amd/vulkan/radv_radeon_winsys.h b/src/amd/vulkan/radv_radeon_winsys.h index 70e628f2594..790d544820b 100644 --- a/src/amd/vulkan/radv_radeon_winsys.h +++ b/src/amd/vulkan/radv_radeon_winsys.h @@ -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, diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c index 481065ab413..0ea5708fe5b 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c @@ -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; diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h index 7aad807a433..9db76fc9d0d 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h @@ -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;