From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/ntuser_private.h | 4 ++++ dlls/win32u/vulkan.c | 23 +++++++++++++++++++++++ dlls/win32u/window.c | 3 +++ 3 files changed, 30 insertions(+)
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index bb2169998b6..b41599e34e5 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -77,6 +77,7 @@ typedef struct tagWND UINT dpi; /* window DPI */ DPI_AWARENESS dpi_awareness; /* DPI awareness */ struct window_surface *surface; /* Window surface if any */ + struct list vulkan_surfaces; /* list of vulkan surfaces created for this window */ struct tagDIALOGINFO *dlgInfo; /* Dialog additional info (dialogs only) */ int pixel_format; /* Pixel format set by the graphics driver */ int internal_pixel_format; /* Internal pixel format set via WGL_WINE_pixel_format_passthrough */ @@ -254,6 +255,9 @@ extern BOOL set_keyboard_auto_repeat( BOOL enable ); /* systray.c */ extern LRESULT system_tray_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, void *data );
+/* vulkan.c */ +extern void vulkan_window_detach( WND *win ); + /* window.c */ HANDLE alloc_user_handle( struct user_object *ptr, unsigned int type ); void *free_user_handle( HANDLE handle, unsigned int type ); diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 5677d02e128..5a990d10bfd 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -30,6 +30,7 @@ #include "ntstatus.h" #define WIN32_NO_STATUS #include "win32u_private.h" +#include "ntuser_private.h"
#define VK_NO_PROTOTYPES #define WINE_VK_HOST @@ -51,6 +52,7 @@ static void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *);
struct surface { + struct list entry; VkSurfaceKHR host_surface; void *driver_private; HWND hwnd; @@ -71,6 +73,7 @@ static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance instance, const VkWin { struct surface *surface; VkResult res; + WND *win;
TRACE( "instance %p, info %p, allocator %p, handle %p\n", instance, info, allocator, handle ); if (allocator) FIXME( "Support for allocation callbacks not implemented yet\n" ); @@ -82,6 +85,14 @@ static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance instance, const VkWin return res; }
+ if (!(win = get_win_ptr( info->hwnd )) || win == WND_DESKTOP || win == WND_OTHER_PROCESS) + list_init( &surface->entry ); + else + { + list_add_tail( &win->vulkan_surfaces, &surface->entry ); + release_win_ptr( win ); + } + surface->hwnd = info->hwnd; *handle = surface_to_handle( surface ); return VK_SUCCESS; @@ -94,6 +105,7 @@ static void win32u_vkDestroySurfaceKHR( VkInstance instance, VkSurfaceKHR handle TRACE( "instance %p, handle 0x%s, allocator %p\n", instance, wine_dbgstr_longlong(handle), allocator ); if (allocator) FIXME( "Support for allocation callbacks not implemented yet\n" );
+ list_remove( &surface->entry ); p_vkDestroySurfaceKHR( instance, surface->host_surface, NULL /* allocator */ ); driver_funcs->p_vulkan_surface_destroy( surface->hwnd, surface->driver_private ); free( surface ); @@ -239,6 +251,17 @@ static void vulkan_init(void) #undef LOAD_FUNCPTR }
+void vulkan_window_detach( WND *win ) +{ + struct surface *surface; + + LIST_FOR_EACH_ENTRY( surface, &win->vulkan_surfaces, struct surface, entry ) + { + list_remove( &surface->entry ); + list_init( &surface->entry ); + } +} + /*********************************************************************** * __wine_get_vulkan_driver (win32u.so) */ diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 73a0fa9e896..8357be6b43e 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -4763,6 +4763,7 @@ LRESULT destroy_window( HWND hwnd ) window_surface_release( surface ); }
+ vulkan_window_detach( win ); user_driver->pDestroyWindow( hwnd );
free_window_handle( hwnd ); @@ -4864,6 +4865,7 @@ void destroy_thread_windows(void) while ((win = next_process_user_handle_ptr( &handle, NTUSER_OBJ_WINDOW ))) { if (win->tid != GetCurrentThreadId()) continue; + vulkan_window_detach( win ); free_dce( win->dce, win->obj.handle ); set_user_handle_ptr( handle, NULL ); win->obj.handle = free_list; @@ -4987,6 +4989,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, win->cbWndExtra = extra_bytes; win->dpi = dpi; win->dpi_awareness = awareness; + list_init( &win->vulkan_surfaces ); set_user_handle_ptr( handle, &win->obj ); if (is_winproc_unicode( win->winproc, !ansi )) win->flags |= WIN_ISUNICODE; return win;