VK_KHR_get_physical_device_properties2 doesn't report a valid LUID on non-Windows hosts. Extension VK_EXT_acquire_xlib_display is needed for the use of vkGetRandROutputDisplayEXT(), which will be used to fill in the LUID property of Vulkan devices.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/vulkan-1/tests/vulkan.c | 1 + dlls/winex11.drv/vulkan.c | 55 +++++++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c index 63fd48b33d3..4ebfe6815bf 100644 --- a/dlls/vulkan-1/tests/vulkan.c +++ b/dlls/vulkan-1/tests/vulkan.c @@ -352,6 +352,7 @@ static void test_unsupported_instance_extensions(void) { "VK_KHR_xcb_surface", "VK_KHR_xlib_surface", + "VK_EXT_acquire_xlib_display", };
for (i = 0; i < ARRAY_SIZE(extensions); ++i) diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index c988b1a6b27..9ee79220f76 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -155,9 +155,9 @@ fail: * Caller is responsible for allocation and cleanup of 'dst'. */ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src, - VkInstanceCreateInfo *dst) + VkInstanceCreateInfo *dst, BOOL enable_acquire_xlib_display) { - unsigned int i; + unsigned int i, extension_count; const char **enabled_extensions = NULL;
dst->sType = src->sType; @@ -169,9 +169,13 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo dst->enabledExtensionCount = 0; dst->ppEnabledExtensionNames = NULL;
- if (src->enabledExtensionCount > 0) + extension_count = src->enabledExtensionCount; + if (enable_acquire_xlib_display) + ++extension_count; + + if (extension_count) { - enabled_extensions = heap_calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames)); + enabled_extensions = heap_calloc(extension_count, sizeof(*src->ppEnabledExtensionNames)); if (!enabled_extensions) { ERR("Failed to allocate memory for enabled extensions\n"); @@ -192,8 +196,12 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo enabled_extensions[i] = src->ppEnabledExtensionNames[i]; } } + + if (enable_acquire_xlib_display) + enabled_extensions[i] = "VK_EXT_acquire_xlib_display"; + dst->ppEnabledExtensionNames = enabled_extensions; - dst->enabledExtensionCount = src->enabledExtensionCount; + dst->enabledExtensionCount = extension_count; }
return VK_SUCCESS; @@ -232,6 +240,7 @@ static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info, const VkAllocationCallbacks *allocator, VkInstance *instance) { VkInstanceCreateInfo create_info_host; + unsigned int i; VkResult res; TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
@@ -240,9 +249,33 @@ static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info,
/* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan * performed a first pass in which it handles everything except for WSI - * functionality such as VK_KHR_win32_surface. Handle this now. + * functionality such as VK_KHR_win32_surface. Handle this now. And try + * to enable VK_EXT_acquire_xlib_display if VK_KHR_get_physical_device_properties2 + * is enabled for getting valid LUIDs. */ - res = wine_vk_instance_convert_create_info(create_info, &create_info_host); + for (i = 0; i < create_info->enabledExtensionCount; ++i) + { + if (!strcmp(create_info->ppEnabledExtensionNames[i], + VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) + break; + } + + if (i < create_info->enabledExtensionCount) + { + res = wine_vk_instance_convert_create_info(create_info, &create_info_host, TRUE); + if (res != VK_SUCCESS) + { + ERR("Failed to convert instance create info, res=%d\n", res); + return res; + } + + res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance); + heap_free((void *)create_info_host.ppEnabledExtensionNames); + if (res != VK_ERROR_EXTENSION_NOT_PRESENT) + return res; + } + + res = wine_vk_instance_convert_create_info(create_info, &create_info_host, FALSE); if (res != VK_SUCCESS) { ERR("Failed to convert instance create info, res=%d\n", res); @@ -413,6 +446,14 @@ static VkResult X11DRV_vkEnumerateInstanceExtensionProperties(const char *layer_ VK_KHR_WIN32_SURFACE_EXTENSION_NAME); properties[i].specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION; } + + /* Do not report VK_EXT_acquire_xlib_display */ + if (!strcmp(properties[i].extensionName, "VK_EXT_acquire_xlib_display")) + { + if (i + 1 < *count) + memmove(&properties[i], &properties[i + 1], sizeof(*properties) * (*count - (i + 1))); + *count = *count - 1; + } }
TRACE("Returning %u extensions.\n", *count);