diff --git a/src/vulkan/device-select-layer/device_select_layer.c b/src/vulkan/device-select-layer/device_select_layer.c index c26544973eb..29c2a3127df 100644 --- a/src/vulkan/device-select-layer/device_select_layer.c +++ b/src/vulkan/device-select-layer/device_select_layer.c @@ -54,6 +54,7 @@ struct instance_info { PFN_vkGetPhysicalDeviceProperties2 GetPhysicalDeviceProperties2; bool has_pci_bus, has_vulkan11; bool has_wayland, has_xcb; + bool zink, xwayland; }; static struct hash_table *device_select_instance_ht = NULL; @@ -132,6 +133,8 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; + const char *engineName = pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->pEngineName ? pCreateInfo->pApplicationInfo->pEngineName : ""; + const char *applicationName = pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->pApplicationName ? pCreateInfo->pApplicationInfo->pApplicationName : ""; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); if (result != VK_SUCCESS) { return result; @@ -139,6 +142,8 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate struct instance_info *info = (struct instance_info *)calloc(1, sizeof(struct instance_info)); info->GetInstanceProcAddr = GetInstanceProcAddr; + info->zink = !strcmp(engineName, "mesa zink"); + info->xwayland = !strcmp(applicationName, "Xwayland"); for (unsigned i = 0; i < pCreateInfo->enabledExtensionCount; i++) { #ifdef VK_USE_PLATFORM_WAYLAND_KHR @@ -549,6 +554,8 @@ static VkResult device_select_EnumeratePhysicalDevices(VkInstance instance, uint32_t selected_physical_device_count = 0; const char* selection = getenv("MESA_VK_DEVICE_SELECT"); bool expose_only_one_dev = false; + if (info->zink && info->xwayland) + return info->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); VkResult result = info->EnumeratePhysicalDevices(instance, &physical_device_count, NULL); if (!pPhysicalDevices) { *pPhysicalDeviceCount = physical_device_count; @@ -636,6 +643,8 @@ static VkResult device_select_EnumeratePhysicalDeviceGroups(VkInstance instance, struct instance_info *info = device_select_layer_get_instance(instance); uint32_t physical_device_group_count = 0; uint32_t selected_physical_device_group_count = 0; + if (info->zink && info->xwayland) + return info->EnumeratePhysicalDeviceGroups(instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroups); VkResult result = info->EnumeratePhysicalDeviceGroups(instance, &physical_device_group_count, NULL); if (!pPhysicalDeviceGroups) { *pPhysicalDeviceGroupCount = physical_device_group_count;