From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/d3dkmt.c | 9 ++++--- dlls/win32u/ntuser_private.h | 5 ++++ dlls/win32u/vulkan.c | 51 +++++++++++++++++++----------------- 3 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/dlls/win32u/d3dkmt.c b/dlls/win32u/d3dkmt.c index 5f3804c165d..a97ab5d3c33 100644 --- a/dlls/win32u/d3dkmt.c +++ b/dlls/win32u/d3dkmt.c @@ -28,6 +28,7 @@ #define WIN32_NO_STATUS #include "ntgdi_private.h" #include "win32u_private.h" +#include "ntuser_private.h" #include "wine/vulkan.h" #include "wine/vulkan_driver.h"
@@ -83,13 +84,13 @@ static void d3dkmt_init_vulkan(void) PFN_vkCreateInstance p_vkCreateInstance; VkResult vr;
- if (!(vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ))) + if (!vulkan_init()) { WARN( "Failed to open the Vulkan driver\n" ); return; }
- p_vkCreateInstance = vulkan_funcs->p_vkGetInstanceProcAddr( NULL, "vkCreateInstance" ); + p_vkCreateInstance = p_vkGetInstanceProcAddr( NULL, "vkCreateInstance" ); if ((vr = p_vkCreateInstance( &create_info, NULL, &d3dkmt_vk_instance ))) { WARN( "Failed to create a Vulkan instance, vr %d.\n", vr ); @@ -97,9 +98,9 @@ static void d3dkmt_init_vulkan(void) return; }
- p_vkDestroyInstance = vulkan_funcs->p_vkGetInstanceProcAddr( d3dkmt_vk_instance, "vkDestroyInstance" ); + p_vkDestroyInstance = p_vkGetInstanceProcAddr( d3dkmt_vk_instance, "vkDestroyInstance" ); #define LOAD_VK_FUNC( f ) \ - if (!(p##f = (void *)vulkan_funcs->p_vkGetInstanceProcAddr( d3dkmt_vk_instance, #f ))) \ + if (!(p##f = (void *)p_vkGetInstanceProcAddr( d3dkmt_vk_instance, #f ))) \ { \ WARN( "Failed to load " #f ".\n" ); \ p_vkDestroyInstance( d3dkmt_vk_instance, NULL ); \ diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 020c98005df..62e65d71d31 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -25,6 +25,7 @@ #include "ntuser.h" #include "shellapi.h" #include "wine/list.h" +#include "wine/vulkan.h"
#define WM_POPUPSYSTEMMENU 0x0313 @@ -250,6 +251,10 @@ extern int peek_message( MSG *msg, const struct peek_message_filter *filter ); extern LRESULT system_tray_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, void *data );
/* vulkan.c */ +extern void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *); +extern void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *); + +extern BOOL vulkan_init(void); extern void vulkan_detach_surfaces( struct list *surfaces );
/* window.c */ diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 5b128afe3cb..471a4459ec3 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -39,16 +39,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
-#ifdef SONAME_LIBVULKAN +void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *) = NULL; +void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *) = NULL;
static void *vulkan_handle; -static const struct vulkan_driver_funcs *driver_funcs; static struct vulkan_funcs vulkan_funcs;
+#ifdef SONAME_LIBVULKAN + +static const struct vulkan_driver_funcs *driver_funcs; + static void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *); static VkResult (*p_vkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *); -static void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *); -static void *(*p_vkGetInstanceProcAddr)(VkInstance, const char *);
struct surface { @@ -283,7 +285,7 @@ static const struct vulkan_driver_funcs lazydrv_funcs = .p_vulkan_surface_presented = lazydrv_vulkan_surface_presented, };
-static void vulkan_init(void) +static void vulkan_init_once(void) { if (!(vulkan_handle = dlopen( SONAME_LIBVULKAN, RTLD_NOW ))) { @@ -323,27 +325,24 @@ void vulkan_detach_surfaces( struct list *surfaces ) } }
-/*********************************************************************** - * __wine_get_vulkan_driver (win32u.so) - */ -const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version ) -{ - static pthread_once_t init_once = PTHREAD_ONCE_INIT; +#else /* SONAME_LIBVULKAN */
- if (version != WINE_VULKAN_DRIVER_VERSION) - { - ERR( "version mismatch, vulkan wants %u but win32u has %u\n", version, WINE_VULKAN_DRIVER_VERSION ); - return NULL; - } +void vulkan_detach_surfaces( struct list *surfaces ) +{ +}
- pthread_once( &init_once, vulkan_init ); - return vulkan_handle ? &vulkan_funcs : NULL; +static void vulkan_init_once(void) +{ + ERR( "Wine was built without Vulkan support.\n" ); }
-#else /* SONAME_LIBVULKAN */ +#endif /* SONAME_LIBVULKAN */
-void vulkan_detach_surfaces( struct list *surfaces ) +BOOL vulkan_init(void) { + static pthread_once_t init_once = PTHREAD_ONCE_INIT; + pthread_once( &init_once, vulkan_init_once ); + return !!vulkan_handle; }
/*********************************************************************** @@ -351,8 +350,12 @@ void vulkan_detach_surfaces( struct list *surfaces ) */ const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version ) { - ERR("Wine was built without Vulkan support.\n"); - return NULL; -} + if (version != WINE_VULKAN_DRIVER_VERSION) + { + ERR( "version mismatch, vulkan wants %u but win32u has %u\n", version, WINE_VULKAN_DRIVER_VERSION ); + return NULL; + }
-#endif /* SONAME_LIBVULKAN */ + if (!vulkan_init()) return NULL; + return &vulkan_funcs; +}