Module: wine Branch: master Commit: ccd332c8544c22bdf3d2c3b9b0329ba5c97fb015 URL: https://gitlab.winehq.org/wine/wine/-/commit/ccd332c8544c22bdf3d2c3b9b0329ba...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Mar 29 10:20:06 2024 +0100
winex11: Get rid of ref held from the HWND to its Vk surface.
---
dlls/winex11.drv/vulkan.c | 31 +++++++++---------------------- dlls/winex11.drv/window.c | 2 +- dlls/winex11.drv/x11drv.h | 2 +- 3 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index f51fb79b362..6f43164b074 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -51,8 +51,6 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
static pthread_mutex_t vulkan_mutex;
-static XContext vulkan_hwnd_context; - #define VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR 1000004000
static struct list surface_list = LIST_INIT( surface_list ); @@ -91,13 +89,7 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) return (struct wine_vk_surface *)(uintptr_t)handle; }
-static struct wine_vk_surface *wine_vk_surface_grab(struct wine_vk_surface *surface) -{ - InterlockedIncrement(&surface->ref); - return surface; -} - -static void wine_vk_surface_release(struct wine_vk_surface *surface) +static void wine_vk_surface_release( struct wine_vk_surface *surface ) { if (InterlockedDecrement(&surface->ref)) return; @@ -115,18 +107,18 @@ static void wine_vk_surface_release(struct wine_vk_surface *surface) free(surface); }
-void wine_vk_surface_destroy(HWND hwnd) +void destroy_vk_surface( HWND hwnd ) { - struct wine_vk_surface *surface; - pthread_mutex_lock(&vulkan_mutex); - if (!XFindContext(gdi_display, (XID)hwnd, vulkan_hwnd_context, (char **)&surface)) + struct wine_vk_surface *surface, *next; + + pthread_mutex_lock( &vulkan_mutex ); + LIST_FOR_EACH_ENTRY_SAFE( surface, next, &surface_list, struct wine_vk_surface, entry ) { + if (surface->hwnd != hwnd) continue; surface->hwnd_thread_id = 0; surface->hwnd = NULL; - wine_vk_surface_release(surface); } - XDeleteContext(gdi_display, (XID)hwnd, vulkan_hwnd_context); - pthread_mutex_unlock(&vulkan_mutex); + pthread_mutex_unlock( &vulkan_mutex ); }
void vulkan_thread_detach(void) @@ -143,7 +135,6 @@ void vulkan_thread_detach(void) TRACE("Detaching surface %p, hwnd %p.\n", surface, surface->hwnd); XReparentWindow(gdi_display, surface->window, get_dummy_parent(), 0, 0); XSync(gdi_display, False); - wine_vk_surface_destroy(surface->hwnd); } pthread_mutex_unlock(&vulkan_mutex); } @@ -220,9 +211,6 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, }
pthread_mutex_lock(&vulkan_mutex); - wine_vk_surface_destroy( x11_surface->hwnd ); - XSaveContext( gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, - (char *)wine_vk_surface_grab( x11_surface ) ); list_add_tail(&surface_list, &x11_surface->entry); pthread_mutex_unlock(&vulkan_mutex);
@@ -359,7 +347,6 @@ UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs * LOAD_FUNCPTR( vkQueuePresentKHR ); #undef LOAD_FUNCPTR
- vulkan_hwnd_context = XUniqueContext(); *driver_funcs = vulkan_funcs; return STATUS_SUCCESS; } @@ -372,7 +359,7 @@ UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs * return STATUS_NOT_IMPLEMENTED; }
-void wine_vk_surface_destroy(HWND hwnd) +void destroy_vk_surface( HWND hwnd ) { }
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 5ea95df17cf..a35e53079aa 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1881,7 +1881,7 @@ void X11DRV_DestroyWindow( HWND hwnd ) release_win_data( data ); free( data ); destroy_gl_drawable( hwnd ); - wine_vk_surface_destroy( hwnd ); + destroy_vk_surface( hwnd ); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 381c2c6fbe4..ef736c86522 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -640,7 +640,7 @@ extern Window get_dummy_parent(void); extern void sync_gl_drawable( HWND hwnd, BOOL known_child ); extern void set_gl_drawable_parent( HWND hwnd, HWND parent ); extern void destroy_gl_drawable( HWND hwnd ); -extern void wine_vk_surface_destroy( HWND hwnd ); +extern void destroy_vk_surface( HWND hwnd ); extern void vulkan_thread_detach(void);
extern void wait_for_withdrawn_state( HWND hwnd, BOOL set );