Module: wine Branch: master Commit: 8ba1b27f23684b4c26e33e60bfdcd47c998a79f6 URL: https://gitlab.winehq.org/wine/wine/-/commit/8ba1b27f23684b4c26e33e60bfdcd47...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Nov 25 15:15:44 2023 +0100
winevulkan: Handle creation of surfaces with no HWND directly.
---
dlls/winevulkan/vulkan.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 9123e65da4c..5d9d9e452b8 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -1503,18 +1503,31 @@ VkResult wine_vkCreateWin32SurfaceKHR(VkInstance handle, const VkWin32SurfaceCre const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface) { struct wine_instance *instance = wine_instance_from_handle(handle); + VkWin32SurfaceCreateInfoKHR create_info_host = *create_info; struct wine_surface *object; + HWND dummy = NULL; VkResult res;
if (allocator) FIXME("Support for allocation callbacks not implemented yet\n");
if (!(object = calloc(1, sizeof(*object)))) return VK_ERROR_OUT_OF_HOST_MEMORY; - object->hwnd = create_info->hwnd;
- res = instance->funcs.p_vkCreateWin32SurfaceKHR(instance->host_instance, create_info, + /* Windows allows surfaces to be created with no HWND, they return VK_ERROR_SURFACE_LOST_KHR later */ + if (!(object->hwnd = create_info->hwnd)) + { + static const WCHAR staticW[] = {'s','t','a','t','i','c',0}; + UNICODE_STRING static_us = RTL_CONSTANT_STRING(staticW); + dummy = NtUserCreateWindowEx(0, &static_us, &static_us, &static_us, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, NULL, NULL, 0, NULL, 0, FALSE); + WARN("Created dummy window %p for null surface window\n", dummy); + create_info_host.hwnd = object->hwnd = dummy; + } + + res = instance->funcs.p_vkCreateWin32SurfaceKHR(instance->host_instance, &create_info_host, NULL /* allocator */, &object->driver_surface); if (res != VK_SUCCESS) { + if (dummy) NtUserDestroyWindow(dummy); free(object); return res; } @@ -1522,6 +1535,9 @@ VkResult wine_vkCreateWin32SurfaceKHR(VkInstance handle, const VkWin32SurfaceCre object->host_surface = vk_funcs->p_wine_get_host_surface(object->driver_surface); WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->host_surface, object);
+ *surface = wine_surface_to_handle(object); + if (dummy) NtUserDestroyWindow(dummy); + *surface = wine_surface_to_handle(object);
return VK_SUCCESS;