From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/vulkan.c | 59 ++++++++++++++++++--------------------- dlls/winex11.drv/window.c | 2 +- dlls/winex11.drv/x11drv.h | 2 +- 3 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c index 6597771c4c6..005a429f3df 100644 --- a/dlls/winex11.drv/vulkan.c +++ b/dlls/winex11.drv/vulkan.c @@ -49,8 +49,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 ); @@ -140,7 +138,6 @@ static void wine_vk_init(void) #undef LOAD_FUNCPTR #undef LOAD_OPTIONAL_FUNCPTR
- vulkan_hwnd_context = XUniqueContext(); return;
fail: @@ -196,13 +193,6 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo return VK_SUCCESS; }
-static struct wine_vk_surface *wine_vk_surface_grab( struct wine_vk_surface *surface ) -{ - int refcount = InterlockedIncrement( &surface->ref ); - TRACE( "surface %p, refcount %d.\n", surface, refcount ); - return surface; -} - static void wine_vk_surface_release( struct wine_vk_surface *surface ) { int refcount = InterlockedDecrement( &surface->ref ); @@ -232,18 +222,33 @@ static void wine_vk_surface_release( struct wine_vk_surface *surface ) free(surface); }
-void wine_vk_surface_destroy(HWND hwnd) +static void wine_vk_surface_detach( struct wine_vk_surface *surface ) { - struct wine_vk_surface *surface; - pthread_mutex_lock(&vulkan_mutex); - if (!XFindContext(gdi_display, (XID)hwnd, vulkan_hwnd_context, (char **)&surface)) + struct x11drv_win_data *data; + + TRACE( "Detaching surface %p, hwnd %p.\n", surface, surface->hwnd ); + + if (surface->window && (data = get_win_data( surface->hwnd ))) { - surface->hwnd_thread_id = 0; - surface->hwnd = NULL; - wine_vk_surface_release(surface); + detach_client_window( data, surface->window ); + release_win_data( data ); } - XDeleteContext(gdi_display, (XID)hwnd, vulkan_hwnd_context); - pthread_mutex_unlock(&vulkan_mutex); + + surface->hwnd_thread_id = 0; + surface->hwnd = 0; +} + +void destroy_vk_surface( HWND hwnd ) +{ + 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; + wine_vk_surface_detach( surface ); + } + pthread_mutex_unlock( &vulkan_mutex ); }
void vulkan_thread_detach(void) @@ -254,13 +259,8 @@ void vulkan_thread_detach(void) pthread_mutex_lock(&vulkan_mutex); LIST_FOR_EACH_ENTRY_SAFE(surface, next, &surface_list, struct wine_vk_surface, entry) { - if (surface->hwnd_thread_id != thread_id) - continue; - - 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); + if (surface->hwnd_thread_id != thread_id) continue; + wine_vk_surface_detach( surface ); } pthread_mutex_unlock(&vulkan_mutex); } @@ -371,11 +371,6 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance, }
pthread_mutex_lock(&vulkan_mutex); - if (x11_surface->hwnd) - { - 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);
@@ -754,7 +749,7 @@ const struct vulkan_funcs *get_vulkan_driver(UINT version) return NULL; }
-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 d38035e2042..96fb90e0cec 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1867,7 +1867,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 dc14d5ff372..caebb115e74 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -646,7 +646,7 @@ extern Window get_dummy_parent(void) DECLSPEC_HIDDEN; extern void sync_gl_drawable( HWND hwnd, BOOL known_child ) DECLSPEC_HIDDEN; extern void set_gl_drawable_parent( HWND hwnd, HWND parent ) DECLSPEC_HIDDEN; extern void destroy_gl_drawable( HWND hwnd ) DECLSPEC_HIDDEN; -extern void wine_vk_surface_destroy( HWND hwnd ) DECLSPEC_HIDDEN; +extern void destroy_vk_surface( HWND hwnd ) DECLSPEC_HIDDEN; extern void vulkan_thread_detach(void) DECLSPEC_HIDDEN;
extern void wait_for_withdrawn_state( HWND hwnd, BOOL set ) DECLSPEC_HIDDEN;