Commit 28873ce8 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Move vulkan loading and init guard out of the drivers.

parent 1ddaa1d3
...@@ -915,9 +915,9 @@ static BOOL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr ...@@ -915,9 +915,9 @@ static BOOL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr
return FALSE; return FALSE;
} }
static const struct vulkan_funcs *nulldrv_wine_get_vulkan_driver( UINT version ) static UINT nulldrv_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs *vulkan_funcs )
{ {
return NULL; return STATUS_NOT_IMPLEMENTED;
} }
static struct opengl_funcs *nulldrv_wine_get_wgl_driver( UINT version ) static struct opengl_funcs *nulldrv_wine_get_wgl_driver( UINT version )
...@@ -1231,9 +1231,9 @@ static BOOL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWI ...@@ -1231,9 +1231,9 @@ static BOOL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWI
return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect ); return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
} }
static const struct vulkan_funcs * loaderdrv_wine_get_vulkan_driver( UINT version ) static UINT loaderdrv_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs *vulkan_funcs )
{ {
return load_driver()->pwine_get_vulkan_driver( version ); return load_driver()->pVulkanInit( version, vulkan_handle, vulkan_funcs );
} }
static const struct user_driver_funcs lazy_load_driver = static const struct user_driver_funcs lazy_load_driver =
...@@ -1302,7 +1302,7 @@ static const struct user_driver_funcs lazy_load_driver = ...@@ -1302,7 +1302,7 @@ static const struct user_driver_funcs lazy_load_driver =
/* system parameters */ /* system parameters */
nulldrv_SystemParametersInfo, nulldrv_SystemParametersInfo,
/* vulkan support */ /* vulkan support */
loaderdrv_wine_get_vulkan_driver, loaderdrv_VulkanInit,
/* opengl support */ /* opengl support */
nulldrv_wine_get_wgl_driver, nulldrv_wine_get_wgl_driver,
/* thread management */ /* thread management */
...@@ -1386,7 +1386,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version ...@@ -1386,7 +1386,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(WindowPosChanging); SET_USER_FUNC(WindowPosChanging);
SET_USER_FUNC(WindowPosChanged); SET_USER_FUNC(WindowPosChanged);
SET_USER_FUNC(SystemParametersInfo); SET_USER_FUNC(SystemParametersInfo);
SET_USER_FUNC(wine_get_vulkan_driver); SET_USER_FUNC(VulkanInit);
SET_USER_FUNC(wine_get_wgl_driver); SET_USER_FUNC(wine_get_wgl_driver);
SET_USER_FUNC(ThreadDetach); SET_USER_FUNC(ThreadDetach);
#undef SET_USER_FUNC #undef SET_USER_FUNC
......
...@@ -22,14 +22,70 @@ ...@@ -22,14 +22,70 @@
#pragma makedep unix #pragma makedep unix
#endif #endif
#include "config.h"
#include <dlfcn.h>
#include <pthread.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "win32u_private.h" #include "win32u_private.h"
#include "wine/vulkan.h" #include "wine/vulkan.h"
#include "wine/vulkan_driver.h" #include "wine/vulkan_driver.h"
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
#ifdef SONAME_LIBVULKAN
static void *vulkan_handle;
static struct vulkan_funcs vulkan_funcs;
static void vulkan_init(void)
{
UINT status;
if (!(vulkan_handle = dlopen( SONAME_LIBVULKAN, RTLD_NOW )))
{
ERR( "Failed to load %s\n", SONAME_LIBVULKAN );
return;
}
if ((status = user_driver->pVulkanInit( WINE_VULKAN_DRIVER_VERSION, vulkan_handle, &vulkan_funcs )) &&
status != STATUS_NOT_IMPLEMENTED)
{
ERR( "Failed to initialize the driver vulkan functions, status %#x\n", status );
dlclose( vulkan_handle );
vulkan_handle = NULL;
return;
}
}
/*********************************************************************** /***********************************************************************
* __wine_get_vulkan_driver (win32u.so) * __wine_get_vulkan_driver (win32u.so)
*/ */
const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version ) const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version )
{ {
return user_driver->pwine_get_vulkan_driver( version ); static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_VULKAN_DRIVER_VERSION)
{
ERR( "version mismatch, vulkan wants %u but win32u has %u\n", version, WINE_VULKAN_DRIVER_VERSION );
return NULL;
}
pthread_once( &init_once, vulkan_init );
return vulkan_handle ? &vulkan_funcs : NULL;
}
#else /* SONAME_LIBVULKAN */
/***********************************************************************
* __wine_get_vulkan_driver (win32u.so)
*/
const struct vulkan_funcs *__wine_get_vulkan_driver( UINT version )
{
ERR("Wine was built without Vulkan support.\n");
return NULL;
} }
#endif /* SONAME_LIBVULKAN */
...@@ -308,7 +308,7 @@ static const struct user_driver_funcs macdrv_funcs = ...@@ -308,7 +308,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pWindowMessage = macdrv_WindowMessage, .pWindowMessage = macdrv_WindowMessage,
.pWindowPosChanged = macdrv_WindowPosChanged, .pWindowPosChanged = macdrv_WindowPosChanged,
.pWindowPosChanging = macdrv_WindowPosChanging, .pWindowPosChanging = macdrv_WindowPosChanging,
.pwine_get_vulkan_driver = macdrv_wine_get_vulkan_driver, .pVulkanInit = macdrv_VulkanInit,
.pwine_get_wgl_driver = macdrv_wine_get_wgl_driver, .pwine_get_wgl_driver = macdrv_wine_get_wgl_driver,
}; };
......
...@@ -257,7 +257,7 @@ extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type); ...@@ -257,7 +257,7 @@ extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type);
extern void macdrv_lost_pasteboard_ownership(HWND hwnd); extern void macdrv_lost_pasteboard_ownership(HWND hwnd);
extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version); extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version);
extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version); extern UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *vulkan_funcs);
extern void sync_gl_view(struct macdrv_win_data* data, const RECT* old_whole_rect, const RECT* old_client_rect); extern void sync_gl_view(struct macdrv_win_data* data, const RECT* old_whole_rect, const RECT* old_client_rect);
extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP hbmColor, extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP hbmColor,
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <stdio.h> #include <stdio.h>
#include <dlfcn.h> #include <dlfcn.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "macdrv.h" #include "macdrv.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -96,38 +98,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) ...@@ -96,38 +98,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
return (struct wine_vk_surface *)(uintptr_t)handle; return (struct wine_vk_surface *)(uintptr_t)handle;
} }
static void *vulkan_handle;
static void wine_vk_init(void)
{
if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
{
ERR("Failed to load %s\n", SONAME_LIBVULKAN);
return;
}
#define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) goto fail;
LOAD_FUNCPTR(vkCreateInstance)
LOAD_FUNCPTR(vkCreateSwapchainKHR)
LOAD_FUNCPTR(vkCreateMacOSSurfaceMVK)
LOAD_FUNCPTR(vkCreateMetalSurfaceEXT)
LOAD_FUNCPTR(vkDestroyInstance)
LOAD_FUNCPTR(vkDestroySurfaceKHR)
LOAD_FUNCPTR(vkDestroySwapchainKHR)
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties)
LOAD_FUNCPTR(vkGetDeviceProcAddr)
LOAD_FUNCPTR(vkGetInstanceProcAddr)
LOAD_FUNCPTR(vkGetSwapchainImagesKHR)
LOAD_FUNCPTR(vkQueuePresentKHR)
#undef LOAD_FUNCPTR
return;
fail:
dlclose(vulkan_handle);
vulkan_handle = NULL;
}
/* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo. /* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo.
* Caller is responsible for allocation and cleanup of 'dst'. * Caller is responsible for allocation and cleanup of 'dst'.
*/ */
...@@ -498,34 +468,39 @@ static const struct vulkan_funcs vulkan_funcs = ...@@ -498,34 +468,39 @@ static const struct vulkan_funcs vulkan_funcs =
macdrv_wine_get_host_surface, macdrv_wine_get_host_surface,
}; };
static const struct vulkan_funcs *get_vulkan_driver(UINT version) UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs)
{ {
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_VULKAN_DRIVER_VERSION) if (version != WINE_VULKAN_DRIVER_VERSION)
{ {
ERR("version mismatch, vulkan wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION); ERR("version mismatch, win32u wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION);
return NULL; return STATUS_INVALID_PARAMETER;
} }
pthread_once(&init_once, wine_vk_init); #define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) return STATUS_PROCEDURE_NOT_FOUND;
if (vulkan_handle) LOAD_FUNCPTR(vkCreateInstance)
return &vulkan_funcs; LOAD_FUNCPTR(vkCreateSwapchainKHR)
LOAD_FUNCPTR(vkCreateMacOSSurfaceMVK)
LOAD_FUNCPTR(vkCreateMetalSurfaceEXT)
LOAD_FUNCPTR(vkDestroyInstance)
LOAD_FUNCPTR(vkDestroySurfaceKHR)
LOAD_FUNCPTR(vkDestroySwapchainKHR)
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties)
LOAD_FUNCPTR(vkGetDeviceProcAddr)
LOAD_FUNCPTR(vkGetInstanceProcAddr)
LOAD_FUNCPTR(vkGetSwapchainImagesKHR)
LOAD_FUNCPTR(vkQueuePresentKHR)
#undef LOAD_FUNCPTR
return NULL; *driver_funcs = vulkan_funcs;
return STATUS_SUCCESS;
} }
#else /* No vulkan */ #else /* No vulkan */
static const struct vulkan_funcs *get_vulkan_driver(UINT version) UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs)
{ {
ERR("Wine was built without Vulkan support.\n"); ERR("Wine was built without Vulkan support.\n");
return NULL; return STATUS_NOT_IMPLEMENTED;
} }
#endif /* SONAME_LIBVULKAN */ #endif /* SONAME_LIBVULKAN */
const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version)
{
return get_vulkan_driver( version );
}
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <stdlib.h> #include <stdlib.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "waylanddrv.h" #include "waylanddrv.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -64,7 +66,6 @@ static VkBool32 (*pvkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalD ...@@ -64,7 +66,6 @@ static VkBool32 (*pvkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalD
static VkResult (*pvkGetSwapchainImagesKHR)(VkDevice, VkSwapchainKHR, uint32_t *, VkImage *); static VkResult (*pvkGetSwapchainImagesKHR)(VkDevice, VkSwapchainKHR, uint32_t *, VkImage *);
static VkResult (*pvkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *); static VkResult (*pvkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *);
static void *vulkan_handle;
static const struct vulkan_funcs vulkan_funcs; static const struct vulkan_funcs vulkan_funcs;
static pthread_mutex_t wine_vk_swapchain_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t wine_vk_swapchain_mutex = PTHREAD_MUTEX_INITIALIZER;
...@@ -542,38 +543,6 @@ static VkSurfaceKHR wayland_wine_get_host_surface(VkSurfaceKHR surface) ...@@ -542,38 +543,6 @@ static VkSurfaceKHR wayland_wine_get_host_surface(VkSurfaceKHR surface)
return wine_vk_surface_from_handle(surface)->host_surface; return wine_vk_surface_from_handle(surface)->host_surface;
} }
static void wine_vk_init(void)
{
if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
{
ERR("Failed to load %s.\n", SONAME_LIBVULKAN);
return;
}
#define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail
#define LOAD_OPTIONAL_FUNCPTR(f) p##f = dlsym(vulkan_handle, #f)
LOAD_FUNCPTR(vkCreateInstance);
LOAD_FUNCPTR(vkCreateSwapchainKHR);
LOAD_FUNCPTR(vkCreateWaylandSurfaceKHR);
LOAD_FUNCPTR(vkDestroyInstance);
LOAD_FUNCPTR(vkDestroySurfaceKHR);
LOAD_FUNCPTR(vkDestroySwapchainKHR);
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties);
LOAD_FUNCPTR(vkGetDeviceProcAddr);
LOAD_FUNCPTR(vkGetInstanceProcAddr);
LOAD_FUNCPTR(vkGetPhysicalDeviceWaylandPresentationSupportKHR);
LOAD_FUNCPTR(vkGetSwapchainImagesKHR);
LOAD_FUNCPTR(vkQueuePresentKHR);
#undef LOAD_FUNCPTR
#undef LOAD_OPTIONAL_FUNCPTR
return;
fail:
dlclose(vulkan_handle);
vulkan_handle = NULL;
}
static const struct vulkan_funcs vulkan_funcs = static const struct vulkan_funcs vulkan_funcs =
{ {
.p_vkCreateInstance = wayland_vkCreateInstance, .p_vkCreateInstance = wayland_vkCreateInstance,
...@@ -592,31 +561,41 @@ static const struct vulkan_funcs vulkan_funcs = ...@@ -592,31 +561,41 @@ static const struct vulkan_funcs vulkan_funcs =
}; };
/********************************************************************** /**********************************************************************
* WAYLAND_wine_get_vulkan_driver * WAYLAND_VulkanInit
*/ */
const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version) UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs)
{ {
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_VULKAN_DRIVER_VERSION) if (version != WINE_VULKAN_DRIVER_VERSION)
{ {
ERR("version mismatch, vulkan wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION); ERR("version mismatch, win32u wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION);
return NULL; return STATUS_INVALID_PARAMETER;
} }
pthread_once(&init_once, wine_vk_init); #define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) return STATUS_PROCEDURE_NOT_FOUND;
if (vulkan_handle) LOAD_FUNCPTR(vkCreateInstance);
return &vulkan_funcs; LOAD_FUNCPTR(vkCreateSwapchainKHR);
LOAD_FUNCPTR(vkCreateWaylandSurfaceKHR);
LOAD_FUNCPTR(vkDestroyInstance);
LOAD_FUNCPTR(vkDestroySurfaceKHR);
LOAD_FUNCPTR(vkDestroySwapchainKHR);
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties);
LOAD_FUNCPTR(vkGetDeviceProcAddr);
LOAD_FUNCPTR(vkGetInstanceProcAddr);
LOAD_FUNCPTR(vkGetPhysicalDeviceWaylandPresentationSupportKHR);
LOAD_FUNCPTR(vkGetSwapchainImagesKHR);
LOAD_FUNCPTR(vkQueuePresentKHR);
#undef LOAD_FUNCPTR
return NULL; *driver_funcs = vulkan_funcs;
return STATUS_SUCCESS;
} }
#else /* No vulkan */ #else /* No vulkan */
const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version) UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs)
{ {
ERR("Wine was built without Vulkan support.\n"); ERR( "Wine was built without Vulkan support.\n" );
return NULL; return STATUS_NOT_IMPLEMENTED;
} }
#endif /* SONAME_LIBVULKAN */ #endif /* SONAME_LIBVULKAN */
...@@ -338,7 +338,7 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, ...@@ -338,7 +338,7 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags,
BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags,
const RECT *window_rect, const RECT *client_rect, const RECT *window_rect, const RECT *client_rect,
RECT *visible_rect, struct window_surface **surface); RECT *visible_rect, struct window_surface **surface);
const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version); UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs);
struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version); struct opengl_funcs *WAYLAND_wine_get_wgl_driver(UINT version);
#endif /* __WINE_WAYLANDDRV_H */ #endif /* __WINE_WAYLANDDRV_H */
...@@ -42,7 +42,7 @@ static const struct user_driver_funcs waylanddrv_funcs = ...@@ -42,7 +42,7 @@ static const struct user_driver_funcs waylanddrv_funcs =
.pWindowMessage = WAYLAND_WindowMessage, .pWindowMessage = WAYLAND_WindowMessage,
.pWindowPosChanged = WAYLAND_WindowPosChanged, .pWindowPosChanged = WAYLAND_WindowPosChanged,
.pWindowPosChanging = WAYLAND_WindowPosChanging, .pWindowPosChanging = WAYLAND_WindowPosChanging,
.pwine_get_vulkan_driver = WAYLAND_wine_get_vulkan_driver, .pVulkanInit = WAYLAND_VulkanInit,
.pwine_get_wgl_driver = WAYLAND_wine_get_wgl_driver, .pwine_get_wgl_driver = WAYLAND_wine_get_wgl_driver,
}; };
......
...@@ -333,14 +333,6 @@ static struct opengl_funcs *X11DRV_wine_get_wgl_driver( UINT version ) ...@@ -333,14 +333,6 @@ static struct opengl_funcs *X11DRV_wine_get_wgl_driver( UINT version )
return get_glx_driver( version ); return get_glx_driver( version );
} }
/**********************************************************************
* X11DRV_wine_get_vulkan_driver
*/
static const struct vulkan_funcs *X11DRV_wine_get_vulkan_driver( UINT version )
{
return get_vulkan_driver( version );
}
static const struct user_driver_funcs x11drv_funcs = static const struct user_driver_funcs x11drv_funcs =
{ {
...@@ -436,7 +428,7 @@ static const struct user_driver_funcs x11drv_funcs = ...@@ -436,7 +428,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pWindowPosChanging = X11DRV_WindowPosChanging, .pWindowPosChanging = X11DRV_WindowPosChanging,
.pWindowPosChanged = X11DRV_WindowPosChanged, .pWindowPosChanged = X11DRV_WindowPosChanged,
.pSystemParametersInfo = X11DRV_SystemParametersInfo, .pSystemParametersInfo = X11DRV_SystemParametersInfo,
.pwine_get_vulkan_driver = X11DRV_wine_get_vulkan_driver, .pVulkanInit = X11DRV_VulkanInit,
.pwine_get_wgl_driver = X11DRV_wine_get_wgl_driver, .pwine_get_wgl_driver = X11DRV_wine_get_wgl_driver,
.pThreadDetach = X11DRV_ThreadDetach, .pThreadDetach = X11DRV_ThreadDetach,
}; };
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <stdio.h> #include <stdio.h>
#include <dlfcn.h> #include <dlfcn.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -94,43 +96,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle) ...@@ -94,43 +96,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
return (struct wine_vk_surface *)(uintptr_t)handle; return (struct wine_vk_surface *)(uintptr_t)handle;
} }
static void *vulkan_handle;
static void wine_vk_init(void)
{
init_recursive_mutex(&vulkan_mutex);
if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
{
ERR("Failed to load %s.\n", SONAME_LIBVULKAN);
return;
}
#define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail
#define LOAD_OPTIONAL_FUNCPTR(f) p##f = dlsym(vulkan_handle, #f)
LOAD_FUNCPTR(vkCreateInstance);
LOAD_FUNCPTR(vkCreateSwapchainKHR);
LOAD_FUNCPTR(vkCreateXlibSurfaceKHR);
LOAD_FUNCPTR(vkDestroyInstance);
LOAD_FUNCPTR(vkDestroySurfaceKHR);
LOAD_FUNCPTR(vkDestroySwapchainKHR);
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties);
LOAD_FUNCPTR(vkGetDeviceProcAddr);
LOAD_FUNCPTR(vkGetInstanceProcAddr);
LOAD_FUNCPTR(vkGetPhysicalDeviceXlibPresentationSupportKHR);
LOAD_FUNCPTR(vkGetSwapchainImagesKHR);
LOAD_FUNCPTR(vkQueuePresentKHR);
#undef LOAD_FUNCPTR
#undef LOAD_OPTIONAL_FUNCPTR
vulkan_hwnd_context = XUniqueContext();
return;
fail:
dlclose(vulkan_handle);
vulkan_handle = NULL;
}
/* Helper function for converting between win32 and X11 compatible VkInstanceCreateInfo. /* Helper function for converting between win32 and X11 compatible VkInstanceCreateInfo.
* Caller is responsible for allocation and cleanup of 'dst'. * Caller is responsible for allocation and cleanup of 'dst'.
*/ */
...@@ -526,29 +491,42 @@ static const struct vulkan_funcs vulkan_funcs = ...@@ -526,29 +491,42 @@ static const struct vulkan_funcs vulkan_funcs =
X11DRV_wine_get_host_surface, X11DRV_wine_get_host_surface,
}; };
const struct vulkan_funcs *get_vulkan_driver(UINT version) UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs )
{ {
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
if (version != WINE_VULKAN_DRIVER_VERSION) if (version != WINE_VULKAN_DRIVER_VERSION)
{ {
ERR("version mismatch, vulkan wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION); ERR( "version mismatch, win32u wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION );
return NULL; return STATUS_INVALID_PARAMETER;
} }
pthread_once(&init_once, wine_vk_init); init_recursive_mutex( &vulkan_mutex );
if (vulkan_handle)
return &vulkan_funcs; #define LOAD_FUNCPTR( f ) if (!(p##f = dlsym( vulkan_handle, #f ))) return STATUS_PROCEDURE_NOT_FOUND;
LOAD_FUNCPTR( vkCreateInstance );
LOAD_FUNCPTR( vkCreateSwapchainKHR );
LOAD_FUNCPTR( vkCreateXlibSurfaceKHR );
LOAD_FUNCPTR( vkDestroyInstance );
LOAD_FUNCPTR( vkDestroySurfaceKHR );
LOAD_FUNCPTR( vkDestroySwapchainKHR );
LOAD_FUNCPTR( vkEnumerateInstanceExtensionProperties );
LOAD_FUNCPTR( vkGetDeviceProcAddr );
LOAD_FUNCPTR( vkGetInstanceProcAddr );
LOAD_FUNCPTR( vkGetPhysicalDeviceXlibPresentationSupportKHR );
LOAD_FUNCPTR( vkGetSwapchainImagesKHR );
LOAD_FUNCPTR( vkQueuePresentKHR );
#undef LOAD_FUNCPTR
return NULL; vulkan_hwnd_context = XUniqueContext();
*driver_funcs = vulkan_funcs;
return STATUS_SUCCESS;
} }
#else /* No vulkan */ #else /* No vulkan */
const struct vulkan_funcs *get_vulkan_driver(UINT version) UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs *driver_funcs )
{ {
ERR("Wine was built without Vulkan support.\n"); ERR( "Wine was built without Vulkan support.\n" );
return NULL; return STATUS_NOT_IMPLEMENTED;
} }
void wine_vk_surface_destroy(HWND hwnd) void wine_vk_surface_destroy(HWND hwnd)
......
...@@ -292,7 +292,7 @@ extern BOOL shape_layered_windows; ...@@ -292,7 +292,7 @@ extern BOOL shape_layered_windows;
extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void); extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void);
extern struct opengl_funcs *get_glx_driver(UINT); extern struct opengl_funcs *get_glx_driver(UINT);
extern const struct vulkan_funcs *get_vulkan_driver(UINT); extern UINT X11DRV_VulkanInit( UINT, void *, struct vulkan_funcs * );
extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection, extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection,
Atom *targets, UINT count, Atom *targets, UINT count,
......
...@@ -819,7 +819,7 @@ BOOL X11DRV_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, ...@@ -819,7 +819,7 @@ BOOL X11DRV_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param,
NTSTATUS X11DRV_D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER *desc ) NTSTATUS X11DRV_D3DKMTCloseAdapter( const D3DKMT_CLOSEADAPTER *desc )
{ {
const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); const struct vulkan_funcs *vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION );
struct x11_d3dkmt_adapter *adapter; struct x11_d3dkmt_adapter *adapter;
if (!vulkan_funcs) if (!vulkan_funcs)
...@@ -1003,7 +1003,7 @@ NTSTATUS X11DRV_D3DKMTOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc ) ...@@ -1003,7 +1003,7 @@ NTSTATUS X11DRV_D3DKMTOpenAdapterFromLuid( D3DKMT_OPENADAPTERFROMLUID *desc )
} }
/* Find the Vulkan device with corresponding UUID */ /* Find the Vulkan device with corresponding UUID */
if (!(vulkan_funcs = get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION))) if (!(vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION )))
{ {
WARN("Vulkan is unavailable.\n"); WARN("Vulkan is unavailable.\n");
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
...@@ -1091,7 +1091,7 @@ done: ...@@ -1091,7 +1091,7 @@ done:
NTSTATUS X11DRV_D3DKMTQueryVideoMemoryInfo( D3DKMT_QUERYVIDEOMEMORYINFO *desc ) NTSTATUS X11DRV_D3DKMTQueryVideoMemoryInfo( D3DKMT_QUERYVIDEOMEMORYINFO *desc )
{ {
const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver(WINE_VULKAN_DRIVER_VERSION); const struct vulkan_funcs *vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION );
PFN_vkGetPhysicalDeviceMemoryProperties2KHR pvkGetPhysicalDeviceMemoryProperties2KHR; PFN_vkGetPhysicalDeviceMemoryProperties2KHR pvkGetPhysicalDeviceMemoryProperties2KHR;
VkPhysicalDeviceMemoryBudgetPropertiesEXT budget; VkPhysicalDeviceMemoryBudgetPropertiesEXT budget;
VkPhysicalDeviceMemoryProperties2 properties2; VkPhysicalDeviceMemoryProperties2 properties2;
......
...@@ -639,7 +639,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid ...@@ -639,7 +639,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
"VK_KHR_display", "VK_KHR_display",
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_EXTENSION_NAME,
}; };
const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ); const struct vulkan_funcs *vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION );
VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * ); VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * );
PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR; PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR;
PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices; PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices;
......
...@@ -175,7 +175,7 @@ struct gdi_dc_funcs ...@@ -175,7 +175,7 @@ struct gdi_dc_funcs
}; };
/* increment this when you change the DC function table */ /* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 84 #define WINE_GDI_DRIVER_VERSION 85
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
...@@ -348,7 +348,7 @@ struct user_driver_funcs ...@@ -348,7 +348,7 @@ struct user_driver_funcs
/* system parameters */ /* system parameters */
BOOL (*pSystemParametersInfo)(UINT,UINT,void*,UINT); BOOL (*pSystemParametersInfo)(UINT,UINT,void*,UINT);
/* vulkan support */ /* vulkan support */
const struct vulkan_funcs * (*pwine_get_vulkan_driver)(UINT); UINT (*pVulkanInit)(UINT,void *,struct vulkan_funcs *);
/* opengl support */ /* opengl support */
struct opengl_funcs * (*pwine_get_wgl_driver)(UINT); struct opengl_funcs * (*pwine_get_wgl_driver)(UINT);
/* thread management */ /* thread management */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment