radv: duplicate the fd used for syncobj with KHR_display

This is required to move the winsys to logical devices.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41824>
This commit is contained in:
Samuel Pitoiset 2026-05-26 14:30:25 +02:00 committed by Marge Bot
parent 47e818c18e
commit b7cd4d718c
3 changed files with 12 additions and 2 deletions

View file

@ -9,6 +9,7 @@
*/
#include <fcntl.h>
#include "util/os_file.h"
#include "util/os_misc.h"
#include "vulkan/vulkan_core.h"
@ -2464,7 +2465,7 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
#else
VkResult result;
int fd = -1;
int wsi_master_fd = -1;
int wsi_master_fd = -1, wsi_syncobj_fd = -1;
const char *path = drm_device->nodes[DRM_NODE_RENDER];
enum radv_drm_device_type drm_device_type;
drmVersionPtr version;
@ -2582,6 +2583,9 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
wsi_master_fd = -1;
}
}
if (fd != -1)
wsi_syncobj_fd = os_dupfd_cloexec(fd);
}
/* Allow all devices on a virtual winsys, otherwise do a basic support check. */
@ -2599,6 +2603,7 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm
}
pdev->wsi_master_fd = wsi_master_fd;
pdev->wsi_syncobj_fd = wsi_syncobj_fd;
pdev->use_llvm = instance->debug_flags & RADV_DEBUG_LLVM;
#if !AMD_LLVM_AVAILABLE
@ -2814,6 +2819,8 @@ fail_fd:
close(fd);
if (wsi_master_fd != -1)
close(wsi_master_fd);
if (wsi_syncobj_fd != -1)
close(wsi_syncobj_fd);
return result;
#endif
}
@ -2861,6 +2868,8 @@ radv_physical_device_destroy(struct vk_physical_device *vk_device)
disk_cache_destroy(pdev->disk_cache_meta);
if (pdev->wsi_master_fd != -1)
close(pdev->wsi_master_fd);
if (pdev->wsi_syncobj_fd != -1)
close(pdev->wsi_syncobj_fd);
simple_mtx_destroy(&pdev->drm_device_mtx);
#ifndef _WIN32
if (pdev->drm_device)

View file

@ -90,6 +90,7 @@ struct radv_physical_device {
struct ac_addrlib *addrlib;
int wsi_master_fd;
int wsi_syncobj_fd;
struct wsi_device wsi_device;
/* Whether DCC should be enabled for MSAA textures. */

View file

@ -109,7 +109,7 @@ radv_init_wsi(struct radv_physical_device *pdev)
pdev->wsi_device.supports_protected[i] = radv_tmz_enabled(pdev);
}
wsi_device_setup_syncobj_fd(&pdev->wsi_device, pdev->ws->get_fd(pdev->ws));
wsi_device_setup_syncobj_fd(&pdev->wsi_device, pdev->wsi_syncobj_fd);
pdev->vk.wsi_device = &pdev->wsi_device;