diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 4d2ddd962a0..c48977606c3 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -87,8 +87,11 @@ wsi_device_init(struct wsi_device *wsi, WSI_GET_CB(GetPhysicalDeviceQueueFamilyProperties); #undef WSI_GET_CB + wsi->drm_info.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT; wsi->pci_bus_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT; + wsi->pci_bus_info.pNext = &wsi->drm_info; VkPhysicalDeviceProperties2 pdp2 = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = &wsi->pci_bus_info, diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index c180e7c70af..886bac9f800 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -100,6 +100,7 @@ struct wsi_device { VkPhysicalDeviceMemoryProperties memory_props; uint32_t queue_family_count; + VkPhysicalDeviceDrmPropertiesEXT drm_info; VkPhysicalDevicePCIBusInfoPropertiesEXT pci_bus_info; VkExternalSemaphoreHandleTypeFlags semaphore_export_handle_types; diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 1a2df70fc23..4e3381bcaab 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -50,6 +50,13 @@ #include #include +#ifdef MAJOR_IN_MKDEV +#include +#endif +#ifdef MAJOR_IN_SYSMACROS +#include +#endif + struct wsi_wayland; struct wsi_wl_format { @@ -99,6 +106,9 @@ struct wsi_wl_display { struct u_vector formats; bool sw; + + dev_t main_device; + bool same_gpu; }; struct wsi_wayland { @@ -633,7 +643,11 @@ default_dmabuf_feedback_main_device(void *data, struct zwp_linux_dmabuf_feedback_v1 *dmabuf_feedback, struct wl_array *device) { - /* ignore this event */ + struct wsi_wl_display *display = data; + + assert(device->size == sizeof(dev_t)); + dev_t *dev = device->data; + display->main_device = *dev; } static void @@ -814,6 +828,9 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, if (!get_format_list) goto out; + /* Default assumption */ + display->same_gpu = true; + /* Get the default dma-buf feedback */ if (display->wl_dmabuf && zwp_linux_dmabuf_v1_get_version(display->wl_dmabuf) >= ZWP_LINUX_DMABUF_V1_GET_DEFAULT_FEEDBACK_SINCE_VERSION) { @@ -822,6 +839,15 @@ wsi_wl_display_init(struct wsi_wayland *wsi_wl, zwp_linux_dmabuf_v1_get_default_feedback(display->wl_dmabuf); zwp_linux_dmabuf_feedback_v1_add_listener(display->wl_dmabuf_feedback, &dmabuf_feedback_listener, display); + + /* Round-trip again to fetch dma-buf feedback */ + wl_display_roundtrip_queue(display->wl_display, display->queue); + + if (wsi_wl->wsi->drm_info.hasRender) { + display->same_gpu = + major(display->main_device) == wsi_wl->wsi->drm_info.renderMajor && + minor(display->main_device) == wsi_wl->wsi->drm_info.renderMinor; + } } /* Round-trip again to get formats and modifiers */ @@ -1791,7 +1817,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, } else { drm_image_params = (struct wsi_drm_image_params) { .base.image_type = WSI_IMAGE_TYPE_DRM, - .same_gpu = true, + .same_gpu = wsi_wl_surface->display->same_gpu, }; /* Use explicit DRM format modifiers when both the server and the driver * support them.