From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/make_vulkan | 2 +- dlls/winevulkan/vulkan.c | 58 ++++++++++++++++---------------- dlls/winevulkan/vulkan_private.h | 7 ++-- dlls/winevulkan/vulkan_thunks.c | 14 ++++---- dlls/winex11.drv/vulkan.c | 18 +++++----- include/wine/vulkan_driver.h | 11 ++++++ 6 files changed, 61 insertions(+), 49 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index a87d10af36f..5fa168d9727 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -1201,7 +1201,7 @@ class VkHandle(object): if self.name == "VkQueue": return "vulkan_queue_from_handle({0})->host.queue".format(name) if self.name == "VkSurfaceKHR": - return "wine_surface_from_handle({0})->host_surface".format(name) + return "vulkan_surface_from_handle({0})->host.surface".format(name) if self.name == "VkSwapchainKHR": return "wine_swapchain_from_handle({0})->host_swapchain".format(name) if self.is_dispatchable(): diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index bc0a476eaef..f49ad41048e 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -1688,61 +1688,61 @@ void wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(VkPhysicalDevice cli }
VkResult wine_vkCreateWin32SurfaceKHR(VkInstance client_instance, const VkWin32SurfaceCreateInfoKHR *create_info, - const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface) + const VkAllocationCallbacks *allocator, VkSurfaceKHR *ret) { struct vulkan_instance *instance = vulkan_instance_from_handle(client_instance); VkWin32SurfaceCreateInfoKHR create_info_host = *create_info; - struct wine_surface *object; + struct wine_surface *surface; 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; + if (!(surface = calloc(1, sizeof(*surface)))) return VK_ERROR_OUT_OF_HOST_MEMORY;
/* Windows allows surfaces to be created with no HWND, they return VK_ERROR_SURFACE_LOST_KHR later */ - if (!(object->hwnd = create_info->hwnd)) + if (!(surface->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; + create_info_host.hwnd = surface->hwnd = dummy; }
res = instance->p_vkCreateWin32SurfaceKHR(instance->host.instance, &create_info_host, - NULL /* allocator */, &object->driver_surface); + NULL /* allocator */, &surface->driver_surface); if (res != VK_SUCCESS) { if (dummy) NtUserDestroyWindow(dummy); - free(object); + free(surface); return res; }
- object->host_surface = vk_funcs->p_wine_get_host_surface(object->driver_surface); + surface->obj.host.surface = vk_funcs->p_wine_get_host_surface(surface->driver_surface); if (dummy) NtUserDestroyWindow(dummy); - window_surfaces_insert(object); + window_surfaces_insert(surface);
- *surface = wine_surface_to_handle(object); - add_handle_mapping(instance, *surface, object->host_surface, &object->wrapper_entry); + *ret = wine_surface_to_handle(surface); + add_handle_mapping(instance, *ret, surface->obj.host.surface, &surface->wrapper_entry); return VK_SUCCESS; }
-void wine_vkDestroySurfaceKHR(VkInstance client_instance, VkSurfaceKHR surface, +void wine_vkDestroySurfaceKHR(VkInstance client_instance, VkSurfaceKHR client_surface, const VkAllocationCallbacks *allocator) { struct vulkan_instance *instance = vulkan_instance_from_handle(client_instance); - struct wine_surface *object = wine_surface_from_handle(surface); + struct wine_surface *surface = wine_surface_from_handle(client_surface);
- if (!object) + if (!surface) return;
- instance->p_vkDestroySurfaceKHR(instance->host.instance, object->driver_surface, NULL); - remove_handle_mapping(instance, &object->wrapper_entry); - window_surfaces_remove(object); + instance->p_vkDestroySurfaceKHR(instance->host.instance, surface->driver_surface, NULL); + remove_handle_mapping(instance, &surface->wrapper_entry); + window_surfaces_remove(surface);
- free(object); + free(surface); }
static BOOL extents_equals(const VkExtent2D *extents, const RECT *rect) @@ -1817,7 +1817,7 @@ VkResult wine_vkCreateSwapchainKHR(VkDevice client_device, const VkSwapchainCrea return VK_ERROR_INITIALIZATION_FAILED; }
- if (surface) create_info_host.surface = surface->host_surface; + if (surface) create_info_host.surface = surface->obj.host.surface; if (old_swapchain) create_info_host.oldSwapchain = old_swapchain->host_swapchain;
/* update the host surface to commit any pending size change */ @@ -1825,7 +1825,7 @@ VkResult wine_vkCreateSwapchainKHR(VkDevice client_device, const VkSwapchainCrea
/* Windows allows client rect to be empty, but host Vulkan often doesn't, adjust extents back to the host capabilities */ res = instance->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device->host.physical_device, - surface->host_surface, &capabilities); + surface->obj.host.surface, &capabilities); if (res != VK_SUCCESS) return res;
create_info_host.imageExtent.width = max(create_info_host.imageExtent.width, capabilities.minImageExtent.width); @@ -2293,7 +2293,7 @@ VkResult wine_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice client_
if (!NtUserIsWindow(surface->hwnd)) return VK_ERROR_SURFACE_LOST_KHR; res = instance->p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device->host.physical_device, - surface->host_surface, capabilities); + surface->obj.host.surface, capabilities); if (res == VK_SUCCESS) adjust_surface_capabilities(instance, surface, capabilities); return res; } @@ -2315,7 +2315,7 @@ VkResult wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice client &capabilities->surfaceCapabilities); }
- surface_info_host.surface = surface->host_surface; + surface_info_host.surface = surface->obj.host.surface;
if (!NtUserIsWindow(surface->hwnd)) return VK_ERROR_SURFACE_LOST_KHR; res = instance->p_vkGetPhysicalDeviceSurfaceCapabilities2KHR(physical_device->host.physical_device, @@ -2324,11 +2324,11 @@ VkResult wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice client return res; }
-VkResult wine_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice client_physical_device, VkSurfaceKHR surface_handle, +VkResult wine_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice client_physical_device, VkSurfaceKHR client_surface, uint32_t *rect_count, VkRect2D *rects) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle(client_physical_device); - struct wine_surface *surface = wine_surface_from_handle(surface_handle); + struct wine_surface *surface = wine_surface_from_handle(client_surface); struct vulkan_instance *instance = physical_device->instance;
if (!NtUserIsWindow(surface->hwnd)) @@ -2340,17 +2340,17 @@ VkResult wine_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice client_ph }
return instance->p_vkGetPhysicalDevicePresentRectanglesKHR(physical_device->host.physical_device, - surface->host_surface, rect_count, rects); + surface->obj.host.surface, rect_count, rects); }
-VkResult wine_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice client_physical_device, VkSurfaceKHR surface_handle, +VkResult wine_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice client_physical_device, VkSurfaceKHR client_surface, uint32_t *format_count, VkSurfaceFormatKHR *formats) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle(client_physical_device); - struct wine_surface *surface = wine_surface_from_handle(surface_handle); + struct wine_surface *surface = wine_surface_from_handle(client_surface); struct vulkan_instance *instance = physical_device->instance;
- return instance->p_vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device->host.physical_device, surface->host_surface, + return instance->p_vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device->host.physical_device, surface->obj.host.surface, format_count, formats); }
@@ -2387,7 +2387,7 @@ VkResult wine_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice client_phys return res; }
- surface_info_host.surface = surface->host_surface; + surface_info_host.surface = surface->obj.host.surface;
return instance->p_vkGetPhysicalDeviceSurfaceFormats2KHR(physical_device->host.physical_device, &surface_info_host, format_count, formats); diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 99542b88376..66d8fdd0326 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -196,7 +196,7 @@ static inline VkDebugReportCallbackEXT wine_debug_report_callback_to_handle(
struct wine_surface { - VkSurfaceKHR host_surface; + struct vulkan_surface obj; VkSurfaceKHR driver_surface; HWND hwnd;
@@ -206,12 +206,13 @@ struct wine_surface
static inline struct wine_surface *wine_surface_from_handle(VkSurfaceKHR handle) { - return (struct wine_surface *)(uintptr_t)handle; + struct vulkan_surface *obj = vulkan_surface_from_handle(handle); + return CONTAINING_RECORD(obj, struct wine_surface, obj); }
static inline VkSurfaceKHR wine_surface_to_handle(struct wine_surface *surface) { - return (VkSurfaceKHR)(uintptr_t)surface; + return (VkSurfaceKHR)(uintptr_t)&surface->obj; }
struct wine_swapchain diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index 32b2fba4125..78b038a14df 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -8877,7 +8877,7 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle) case VK_OBJECT_TYPE_QUEUE: return (uint64_t) (uintptr_t) vulkan_queue_from_handle(((VkQueue) (uintptr_t) handle))->host.queue; case VK_OBJECT_TYPE_SURFACE_KHR: - return (uint64_t) wine_surface_from_handle(handle)->host_surface; + return (uint64_t) vulkan_surface_from_handle(handle)->host.surface; case VK_OBJECT_TYPE_SWAPCHAIN_KHR: return (uint64_t) wine_swapchain_from_handle(handle)->host_swapchain; default: @@ -48200,7 +48200,7 @@ static NTSTATUS thunk64_vkGetDeviceGroupSurfacePresentModesKHR(void *args)
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->surface), params->pModes);
- params->result = vulkan_device_from_handle(params->device)->p_vkGetDeviceGroupSurfacePresentModesKHR(vulkan_device_from_handle(params->device)->host.device, wine_surface_from_handle(params->surface)->host_surface, params->pModes); + params->result = vulkan_device_from_handle(params->device)->p_vkGetDeviceGroupSurfacePresentModesKHR(vulkan_device_from_handle(params->device)->host.device, vulkan_surface_from_handle(params->surface)->host.surface, params->pModes); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -48217,7 +48217,7 @@ static NTSTATUS thunk32_vkGetDeviceGroupSurfacePresentModesKHR(void *args)
TRACE("%#x, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->surface), params->pModes);
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetDeviceGroupSurfacePresentModesKHR(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, wine_surface_from_handle(params->surface)->host_surface, (VkDeviceGroupPresentModeFlagsKHR *)UlongToPtr(params->pModes)); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetDeviceGroupSurfacePresentModesKHR(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_surface_from_handle(params->surface)->host.surface, (VkDeviceGroupPresentModeFlagsKHR *)UlongToPtr(params->pModes)); return STATUS_SUCCESS; }
@@ -50872,7 +50872,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceSurfacePresentModesKHR(void *args)
TRACE("%p, 0x%s, %p, %p\n", params->physicalDevice, wine_dbgstr_longlong(params->surface), params->pPresentModeCount, params->pPresentModes);
- params->result = vulkan_physical_device_from_handle(params->physicalDevice)->instance->p_vkGetPhysicalDeviceSurfacePresentModesKHR(vulkan_physical_device_from_handle(params->physicalDevice)->host.physical_device, params->surface ? wine_surface_from_handle(params->surface)->host_surface : 0, params->pPresentModeCount, params->pPresentModes); + params->result = vulkan_physical_device_from_handle(params->physicalDevice)->instance->p_vkGetPhysicalDeviceSurfacePresentModesKHR(vulkan_physical_device_from_handle(params->physicalDevice)->host.physical_device, params->surface ? vulkan_surface_from_handle(params->surface)->host.surface : 0, params->pPresentModeCount, params->pPresentModes); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -50890,7 +50890,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceSurfacePresentModesKHR(void *args)
TRACE("%#x, 0x%s, %#x, %#x\n", params->physicalDevice, wine_dbgstr_longlong(params->surface), params->pPresentModeCount, params->pPresentModes);
- params->result = vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->p_vkGetPhysicalDeviceSurfacePresentModesKHR(vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host.physical_device, params->surface ? wine_surface_from_handle(params->surface)->host_surface : 0, (uint32_t *)UlongToPtr(params->pPresentModeCount), (VkPresentModeKHR *)UlongToPtr(params->pPresentModes)); + params->result = vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->p_vkGetPhysicalDeviceSurfacePresentModesKHR(vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host.physical_device, params->surface ? vulkan_surface_from_handle(params->surface)->host.surface : 0, (uint32_t *)UlongToPtr(params->pPresentModeCount), (VkPresentModeKHR *)UlongToPtr(params->pPresentModes)); return STATUS_SUCCESS; }
@@ -50901,7 +50901,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceSurfaceSupportKHR(void *args)
TRACE("%p, %u, 0x%s, %p\n", params->physicalDevice, params->queueFamilyIndex, wine_dbgstr_longlong(params->surface), params->pSupported);
- params->result = vulkan_physical_device_from_handle(params->physicalDevice)->instance->p_vkGetPhysicalDeviceSurfaceSupportKHR(vulkan_physical_device_from_handle(params->physicalDevice)->host.physical_device, params->queueFamilyIndex, wine_surface_from_handle(params->surface)->host_surface, params->pSupported); + params->result = vulkan_physical_device_from_handle(params->physicalDevice)->instance->p_vkGetPhysicalDeviceSurfaceSupportKHR(vulkan_physical_device_from_handle(params->physicalDevice)->host.physical_device, params->queueFamilyIndex, vulkan_surface_from_handle(params->surface)->host.surface, params->pSupported); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -50919,7 +50919,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceSupportKHR(void *args)
TRACE("%#x, %u, 0x%s, %#x\n", params->physicalDevice, params->queueFamilyIndex, wine_dbgstr_longlong(params->surface), params->pSupported);
- params->result = vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->p_vkGetPhysicalDeviceSurfaceSupportKHR(vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host.physical_device, params->queueFamilyIndex, wine_surface_from_handle(params->surface)->host_surface, (VkBool32 *)UlongToPtr(params->pSupported)); + params->result = vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->p_vkGetPhysicalDeviceSurfaceSupportKHR(vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host.physical_device, params->queueFamilyIndex, vulkan_surface_from_handle(params->surface)->host.surface, (VkBool32 *)UlongToPtr(params->pSupported)); return STATUS_SUCCESS; }
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index e7c187d5c67..e1ac9ede8fe 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -65,7 +65,7 @@ static VkBool32 (*pvkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevi
static const struct vulkan_driver_funcs x11drv_vulkan_driver_funcs;
-struct vulkan_surface +struct x11drv_vulkan_surface { Window window; RECT rect; @@ -75,7 +75,7 @@ struct vulkan_surface HDC hdc_dst; };
-static void vulkan_surface_destroy( HWND hwnd, struct vulkan_surface *surface ) +static void vulkan_surface_destroy( HWND hwnd, struct x11drv_vulkan_surface *surface ) { destroy_client_window( hwnd, surface->window ); if (surface->hdc_dst) NtGdiDeleteObjectApp( surface->hdc_dst ); @@ -90,7 +90,7 @@ static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, Vk .sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, .dpy = gdi_display, }; - struct vulkan_surface *surface; + struct x11drv_vulkan_surface *surface;
TRACE( "%p %p %p %p\n", hwnd, instance, handle, private );
@@ -123,7 +123,7 @@ static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, Vk
static void X11DRV_vulkan_surface_destroy( HWND hwnd, void *private ) { - struct vulkan_surface *surface = private; + struct x11drv_vulkan_surface *surface = private;
TRACE( "%p %p\n", hwnd, private );
@@ -132,7 +132,7 @@ static void X11DRV_vulkan_surface_destroy( HWND hwnd, void *private )
static void X11DRV_vulkan_surface_detach( HWND hwnd, void *private ) { - struct vulkan_surface *surface = private; + struct x11drv_vulkan_surface *surface = private; Window client_window = surface->window; struct x11drv_win_data *data;
@@ -145,7 +145,7 @@ static void X11DRV_vulkan_surface_detach( HWND hwnd, void *private ) } }
-static void vulkan_surface_update_size( HWND hwnd, struct vulkan_surface *surface ) +static void vulkan_surface_update_size( HWND hwnd, struct x11drv_vulkan_surface *surface ) { XWindowChanges changes; RECT rect; @@ -159,7 +159,7 @@ static void vulkan_surface_update_size( HWND hwnd, struct vulkan_surface *surfac surface->rect = rect; }
-static void vulkan_surface_update_offscreen( HWND hwnd, struct vulkan_surface *surface ) +static void vulkan_surface_update_offscreen( HWND hwnd, struct x11drv_vulkan_surface *surface ) { BOOL offscreen = needs_offscreen_rendering( hwnd, FALSE ); struct x11drv_win_data *data; @@ -205,7 +205,7 @@ static void vulkan_surface_update_offscreen( HWND hwnd, struct vulkan_surface *s
static void X11DRV_vulkan_surface_update( HWND hwnd, void *private ) { - struct vulkan_surface *surface = private; + struct x11drv_vulkan_surface *surface = private;
TRACE( "%p %p\n", hwnd, private );
@@ -215,7 +215,7 @@ static void X11DRV_vulkan_surface_update( HWND hwnd, void *private )
static void X11DRV_vulkan_surface_presented( HWND hwnd, void *private, VkResult result ) { - struct vulkan_surface *surface = private; + struct x11drv_vulkan_surface *surface = private; HWND toplevel = NtUserGetAncestor( hwnd, GA_ROOT ); struct x11drv_win_data *data; RECT rect_dst, rect; diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index db4192a350a..af829b04fdc 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -116,6 +116,17 @@ static inline struct vulkan_queue *vulkan_queue_from_handle( VkQueue handle ) return (struct vulkan_queue *)(UINT_PTR)client->unix_handle; }
+struct vulkan_surface +{ + VULKAN_OBJECT_HEADER( VkSurfaceKHR, surface ); + struct vulkan_instance *instance; +}; + +static inline struct vulkan_surface *vulkan_surface_from_handle( VkSurfaceKHR handle ) +{ + return (struct vulkan_surface *)(UINT_PTR)handle; +} + struct vulkan_funcs { /* Vulkan global functions. These are the only calls at this point a graphics driver