mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 23:40:12 +01:00
vulkan/wsi/wl: correctly find whether the compositor uses the same GPU
Using the wl_drm protocol we can check whether the compositor uses the same GPU as the application. This allows to run vulkan applications using a DG2 GPU with the compositor using another card. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Reviewed-by: Simon Ser <contact@emersion.fr> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19224>
This commit is contained in:
parent
93dbd14ed7
commit
db42ed1e04
3 changed files with 32 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,13 @@
|
|||
#include <util/u_dynarray.h>
|
||||
#include <util/anon_file.h>
|
||||
|
||||
#ifdef MAJOR_IN_MKDEV
|
||||
#include <sys/mkdev.h>
|
||||
#endif
|
||||
#ifdef MAJOR_IN_SYSMACROS
|
||||
#include <sys/sysmacros.h>
|
||||
#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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue