diff --git a/src/asahi/vulkan/hk_wsi.c b/src/asahi/vulkan/hk_wsi.c index b95d09a7d97..69621b291b6 100644 --- a/src/asahi/vulkan/hk_wsi.c +++ b/src/asahi/vulkan/hk_wsi.c @@ -8,6 +8,8 @@ #include "hk_instance.h" #include "wsi_common.h" +#include + static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL hk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) { @@ -15,6 +17,28 @@ hk_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) return vk_instance_get_proc_addr_unchecked(pdev->vk.instance, pName); } +static bool +hk_wsi_can_present_on_device(VkPhysicalDevice physicalDevice, int fd) +{ + VK_FROM_HANDLE(hk_physical_device, pdev, physicalDevice); + if (pdev->dev.is_virtio) { + return false; + } + + drmDevicePtr device; + if (drmGetDevice2(fd, 0, &device) != 0) { + return false; + } + + /* Allow on-device presentation for all non-virtio devices with bus type + * PLATFORM */ + bool match = device->bustype == DRM_BUS_PLATFORM; + + drmFreeDevice(&device); + + return match; +} + VkResult hk_init_wsi(struct hk_physical_device *pdev) { @@ -30,6 +54,7 @@ hk_init_wsi(struct hk_physical_device *pdev) pdev->wsi_device.supports_scanout = false; pdev->wsi_device.supports_modifiers = true; + pdev->wsi_device.can_present_on_device = hk_wsi_can_present_on_device; pdev->vk.wsi_device = &pdev->wsi_device;