From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 17 +++++------------ dlls/winemac.drv/vulkan.c | 36 ++++++++++------------------------- dlls/winewayland.drv/vulkan.c | 33 ++++++++++---------------------- dlls/winex11.drv/vulkan.c | 34 +++++++++------------------------ include/wine/vulkan_driver.h | 7 +++---- 5 files changed, 37 insertions(+), 90 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index bd039b934ce..5677d02e128 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -52,7 +52,7 @@ static void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *); struct surface { VkSurfaceKHR host_surface; - VkSurfaceKHR driver_surface; + void *driver_private; HWND hwnd; };
@@ -76,14 +76,13 @@ static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance instance, const VkWin if (allocator) FIXME( "Support for allocation callbacks not implemented yet\n" );
if (!(surface = calloc( 1, sizeof(*surface) ))) return VK_ERROR_OUT_OF_HOST_MEMORY; - if ((res = driver_funcs->p_vulkan_surface_create( info->hwnd, instance, &surface->driver_surface ))) + if ((res = driver_funcs->p_vulkan_surface_create( info->hwnd, instance, &surface->host_surface, &surface->driver_private ))) { free( surface ); return res; }
surface->hwnd = info->hwnd; - surface->host_surface = driver_funcs->p_wine_get_host_surface( surface->driver_surface ); *handle = surface_to_handle( surface ); return VK_SUCCESS; } @@ -96,7 +95,7 @@ static void win32u_vkDestroySurfaceKHR( VkInstance instance, VkSurfaceKHR handle if (allocator) FIXME( "Support for allocation callbacks not implemented yet\n" );
p_vkDestroySurfaceKHR( instance, surface->host_surface, NULL /* allocator */ ); - driver_funcs->p_vulkan_surface_destroy( surface->hwnd, surface->driver_surface ); + driver_funcs->p_vulkan_surface_destroy( surface->hwnd, surface->driver_private ); free( surface ); }
@@ -164,13 +163,13 @@ static struct vulkan_funcs vulkan_funcs = .p_wine_get_host_surface = win32u_wine_get_host_surface, };
-static VkResult nulldrv_vulkan_surface_create( HWND hwnd, VkInstance instance, VkSurfaceKHR *surface ) +static VkResult nulldrv_vulkan_surface_create( HWND hwnd, VkInstance instance, VkSurfaceKHR *surface, void **private ) { FIXME( "stub!\n" ); return VK_ERROR_INCOMPATIBLE_DRIVER; }
-static void nulldrv_vulkan_surface_destroy( HWND hwnd, VkSurfaceKHR surface ) +static void nulldrv_vulkan_surface_destroy( HWND hwnd, void *private ) { }
@@ -188,11 +187,6 @@ static const char *nulldrv_get_host_surface_extension(void) return "VK_WINE_nulldrv_surface"; }
-static VkSurfaceKHR nulldrv_wine_get_host_surface( VkSurfaceKHR surface ) -{ - return surface; -} - static const struct vulkan_driver_funcs nulldrv_funcs = { .p_vulkan_surface_create = nulldrv_vulkan_surface_create, @@ -200,7 +194,6 @@ static const struct vulkan_driver_funcs nulldrv_funcs = .p_vulkan_surface_presented = nulldrv_vulkan_surface_presented, .p_vkGetPhysicalDeviceWin32PresentationSupportKHR = nulldrv_vkGetPhysicalDeviceWin32PresentationSupportKHR, .p_get_host_surface_extension = nulldrv_get_host_surface_extension, - .p_wine_get_host_surface = nulldrv_wine_get_host_surface, };
static void vulkan_init(void) diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index 42e95d91cce..d61e88f60af 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -56,7 +56,6 @@ struct wine_vk_surface { macdrv_metal_device device; macdrv_metal_view view; - VkSurfaceKHR host_surface; /* host surface */ };
typedef struct VkMacOSSurfaceCreateInfoMVK @@ -81,11 +80,6 @@ static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice,
static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs;
-static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) -{ - return (struct wine_vk_surface *)(uintptr_t)handle; -} - static void wine_vk_surface_destroy(struct wine_vk_surface *surface) { if (surface->view) @@ -97,13 +91,13 @@ static void wine_vk_surface_destroy(struct wine_vk_surface *surface) free(surface); }
-static VkResult macdrv_vulkan_surface_create(HWND hwnd, VkInstance instance, VkSurfaceKHR *surface) +static VkResult macdrv_vulkan_surface_create(HWND hwnd, VkInstance instance, VkSurfaceKHR *surface, void **private) { VkResult res; struct wine_vk_surface *mac_surface; struct macdrv_win_data *data;
- TRACE("%p %p %p\n", hwnd, instance, surface); + TRACE("%p %p %p %p\n", hwnd, instance, surface, private);
if (!(data = get_win_data(hwnd))) { @@ -144,7 +138,7 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, VkInstance instance, VkS create_info_host.flags = 0; /* reserved */ create_info_host.pLayer = macdrv_view_get_metal_layer(mac_surface->view);
- res = pvkCreateMetalSurfaceEXT(instance, &create_info_host, NULL /* allocator */, &mac_surface->host_surface); + res = pvkCreateMetalSurfaceEXT(instance, &create_info_host, NULL /* allocator */, surface); } else { @@ -154,7 +148,7 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, VkInstance instance, VkS create_info_host.flags = 0; /* reserved */ create_info_host.pView = macdrv_view_get_metal_layer(mac_surface->view);
- res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, &mac_surface->host_surface); + res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, surface); } if (res != VK_SUCCESS) { @@ -162,11 +156,11 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, VkInstance instance, VkS goto err; }
- *surface = (uintptr_t)mac_surface; - release_win_data(data);
- TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*surface)); + *private = mac_surface; + + TRACE("Created surface=0x%s, private=%p\n", wine_dbgstr_longlong(*surface), *private); return VK_SUCCESS;
err: @@ -175,11 +169,11 @@ err: return res; }
-static void macdrv_vulkan_surface_destroy(HWND hwnd, VkSurfaceKHR surface) +static void macdrv_vulkan_surface_destroy(HWND hwnd, void *private) { - struct wine_vk_surface *mac_surface = surface_from_handle(surface); + struct wine_vk_surface *mac_surface = private;
- TRACE("%p 0x%s\n", hwnd, wine_dbgstr_longlong(surface)); + TRACE("%p %p\n", hwnd, private);
wine_vk_surface_destroy(mac_surface); } @@ -201,15 +195,6 @@ static const char *macdrv_get_host_surface_extension(void) return pvkCreateMetalSurfaceEXT ? "VK_EXT_metal_surface" : "VK_MVK_macos_surface"; }
-static VkSurfaceKHR macdrv_wine_get_host_surface(VkSurfaceKHR surface) -{ - struct wine_vk_surface *mac_surface = surface_from_handle(surface); - - TRACE("0x%s\n", wine_dbgstr_longlong(surface)); - - return mac_surface->host_surface; -} - static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs = { .p_vulkan_surface_create = macdrv_vulkan_surface_create, @@ -218,7 +203,6 @@ static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs =
.p_vkGetPhysicalDeviceWin32PresentationSupportKHR = macdrv_vkGetPhysicalDeviceWin32PresentationSupportKHR, .p_get_host_surface_extension = macdrv_get_host_surface_extension, - .p_wine_get_host_surface = macdrv_wine_get_host_surface, };
UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, const struct vulkan_driver_funcs **driver_funcs) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 403da808fb5..c47277d8e5d 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -61,14 +61,8 @@ static const struct vulkan_driver_funcs wayland_vulkan_driver_funcs; struct wine_vk_surface { struct wayland_client_surface *client; - VkSurfaceKHR host_surface; };
-static struct wine_vk_surface *wine_vk_surface_from_handle(VkSurfaceKHR handle) -{ - return (struct wine_vk_surface *)(uintptr_t)handle; -} - static HWND wine_vk_surface_get_hwnd(struct wine_vk_surface *wine_vk_surface) { return wl_surface_get_user_data(wine_vk_surface->client->wl_surface); @@ -93,21 +87,20 @@ static void wine_vk_surface_destroy(struct wine_vk_surface *wine_vk_surface) free(wine_vk_surface); }
-static VkResult wayland_vulkan_surface_create(HWND hwnd, VkInstance instance, VkSurfaceKHR *vk_surface) +static VkResult wayland_vulkan_surface_create(HWND hwnd, VkInstance instance, VkSurfaceKHR *surface, void **private) { VkResult res; VkWaylandSurfaceCreateInfoKHR create_info_host; struct wine_vk_surface *wine_vk_surface; struct wayland_surface *wayland_surface;
- TRACE("%p %p %p\n", hwnd, instance, vk_surface); + TRACE("%p %p %p %p\n", hwnd, instance, surface, private);
wine_vk_surface = calloc(1, sizeof(*wine_vk_surface)); if (!wine_vk_surface) { ERR("Failed to allocate memory for wayland vulkan surface\n"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto err; + return VK_ERROR_OUT_OF_HOST_MEMORY; }
wayland_surface = wayland_surface_lock_hwnd(hwnd); @@ -138,28 +131,28 @@ static VkResult wayland_vulkan_surface_create(HWND hwnd, VkInstance instance, Vk
res = pvkCreateWaylandSurfaceKHR(instance, &create_info_host, NULL /* allocator */, - &wine_vk_surface->host_surface); + surface); if (res != VK_SUCCESS) { ERR("Failed to create vulkan wayland surface, res=%d\n", res); goto err; }
- *vk_surface = (uintptr_t)wine_vk_surface; + *private = wine_vk_surface;
- TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*vk_surface)); + TRACE("Created surface=0x%s, private=%p\n", wine_dbgstr_longlong(*surface), *private); return VK_SUCCESS;
err: - if (wine_vk_surface) wine_vk_surface_destroy(wine_vk_surface); + wine_vk_surface_destroy(wine_vk_surface); return res; }
-static void wayland_vulkan_surface_destroy(HWND hwnd, VkSurfaceKHR surface) +static void wayland_vulkan_surface_destroy(HWND hwnd, void *private) { - struct wine_vk_surface *wine_vk_surface = wine_vk_surface_from_handle(surface); + struct wine_vk_surface *wine_vk_surface = private;
- TRACE("%p 0x%s\n", hwnd, wine_dbgstr_longlong(surface)); + TRACE("%p %p\n", hwnd, private);
wine_vk_surface_destroy(wine_vk_surface); } @@ -199,11 +192,6 @@ static const char *wayland_get_host_surface_extension(void) return "VK_KHR_wayland_surface"; }
-static VkSurfaceKHR wayland_wine_get_host_surface(VkSurfaceKHR surface) -{ - return wine_vk_surface_from_handle(surface)->host_surface; -} - static const struct vulkan_driver_funcs wayland_vulkan_driver_funcs = { .p_vulkan_surface_create = wayland_vulkan_surface_create, @@ -212,7 +200,6 @@ static const struct vulkan_driver_funcs wayland_vulkan_driver_funcs =
.p_vkGetPhysicalDeviceWin32PresentationSupportKHR = wayland_vkGetPhysicalDeviceWin32PresentationSupportKHR, .p_get_host_surface_extension = wayland_get_host_surface_extension, - .p_wine_get_host_surface = wayland_wine_get_host_surface, };
/********************************************************************** diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index a49afd32a2c..baf54c28781 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -59,7 +59,6 @@ struct wine_vk_surface LONG ref; struct list entry; Window window; - VkSurfaceKHR host_surface; HWND hwnd; DWORD hwnd_thread_id; }; @@ -78,11 +77,6 @@ static VkBool32 (*pvkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevi
static const struct vulkan_driver_funcs x11drv_vulkan_driver_funcs;
-static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) -{ - return (struct wine_vk_surface *)(uintptr_t)handle; -} - static void wine_vk_surface_release( struct wine_vk_surface *surface ) { if (InterlockedDecrement(&surface->ref)) @@ -131,13 +125,13 @@ void vulkan_thread_detach(void) pthread_mutex_unlock(&vulkan_mutex); }
-static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, VkSurfaceKHR *surface ) +static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, VkSurfaceKHR *surface, void **private ) { VkResult res; VkXlibSurfaceCreateInfoKHR create_info_host; struct wine_vk_surface *x11_surface;
- TRACE( "%p %p %p\n", hwnd, instance, surface ); + TRACE( "%p %p %p %p\n", hwnd, instance, surface, private );
/* TODO: support child window rendering. */ if (NtUserGetAncestor( hwnd, GA_PARENT ) != NtUserGetDesktopWindow()) @@ -157,7 +151,7 @@ static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, Vk
if (!x11_surface->window) { - ERR( "Failed to allocate client window for hwnd=%p\n", hwnd ); + ERR("Failed to allocate client window for hwnd=%p\n", hwnd);
/* VK_KHR_win32_surface only allows out of host and device memory as errors. */ free(x11_surface); @@ -170,7 +164,7 @@ static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, Vk create_info_host.dpy = gdi_display; create_info_host.window = x11_surface->window;
- res = pvkCreateXlibSurfaceKHR( instance, &create_info_host, NULL /* allocator */, &x11_surface->host_surface ); + res = pvkCreateXlibSurfaceKHR( instance, &create_info_host, NULL /* allocator */, surface ); if (res != VK_SUCCESS) { ERR("Failed to create Xlib surface, res=%d\n", res); @@ -183,17 +177,17 @@ static VkResult X11DRV_vulkan_surface_create( HWND hwnd, VkInstance instance, Vk list_add_tail(&surface_list, &x11_surface->entry); pthread_mutex_unlock(&vulkan_mutex);
- *surface = (uintptr_t)x11_surface; + *private = x11_surface;
- TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*surface)); + TRACE("Created surface 0x%s, private %p\n", wine_dbgstr_longlong(*surface), *private); return VK_SUCCESS; }
-static void X11DRV_vulkan_surface_destroy( HWND hwnd, VkSurfaceKHR surface ) +static void X11DRV_vulkan_surface_destroy( HWND hwnd, void *private ) { - struct wine_vk_surface *x11_surface = surface_from_handle(surface); + struct wine_vk_surface *x11_surface = private;
- TRACE( "%p 0x%s\n", hwnd, wine_dbgstr_longlong(surface) ); + TRACE( "%p %p\n", hwnd, private );
wine_vk_surface_release(x11_surface); } @@ -216,15 +210,6 @@ static const char *X11DRV_get_host_surface_extension(void) return "VK_KHR_xlib_surface"; }
-static VkSurfaceKHR X11DRV_wine_get_host_surface( VkSurfaceKHR surface ) -{ - struct wine_vk_surface *x11_surface = surface_from_handle(surface); - - TRACE("0x%s\n", wine_dbgstr_longlong(surface)); - - return x11_surface->host_surface; -} - static const struct vulkan_driver_funcs x11drv_vulkan_driver_funcs = { .p_vulkan_surface_create = X11DRV_vulkan_surface_create, @@ -233,7 +218,6 @@ static const struct vulkan_driver_funcs x11drv_vulkan_driver_funcs =
.p_vkGetPhysicalDeviceWin32PresentationSupportKHR = X11DRV_vkGetPhysicalDeviceWin32PresentationSupportKHR, .p_get_host_surface_extension = X11DRV_get_host_surface_extension, - .p_wine_get_host_surface = X11DRV_wine_get_host_surface, };
UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, const struct vulkan_driver_funcs **driver_funcs ) diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index 20931374ce2..c5b2f82234a 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -21,7 +21,7 @@ #define __WINE_VULKAN_DRIVER_H
/* Wine internal vulkan driver version, needs to be bumped upon vulkan_funcs changes. */ -#define WINE_VULKAN_DRIVER_VERSION 32 +#define WINE_VULKAN_DRIVER_VERSION 33
struct vulkan_funcs { @@ -44,13 +44,12 @@ struct vulkan_funcs /* interface between win32u and the user drivers */ struct vulkan_driver_funcs { - VkResult (*p_vulkan_surface_create)(HWND, VkInstance, VkSurfaceKHR *); - void (*p_vulkan_surface_destroy)(HWND, VkSurfaceKHR); + VkResult (*p_vulkan_surface_create)(HWND, VkInstance, VkSurfaceKHR *, void **); + void (*p_vulkan_surface_destroy)(HWND, void *); void (*p_vulkan_surface_presented)(HWND, VkResult);
VkBool32 (*p_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice, uint32_t); const char *(*p_get_host_surface_extension)(void); - VkSurfaceKHR (*p_wine_get_host_surface)(VkSurfaceKHR); };
#endif /* __WINE_VULKAN_DRIVER_H */