winemac: Use pthread_once for wine_vk_init.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
43993a3986
commit
f7ffa59079
|
@ -101,12 +101,12 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
|
|||
|
||||
static void *vulkan_handle;
|
||||
|
||||
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
||||
static void wine_vk_init(void)
|
||||
{
|
||||
if (!(vulkan_handle = dlopen(SONAME_LIBMOLTENVK, RTLD_NOW)))
|
||||
{
|
||||
ERR("Failed to load %s\n", SONAME_LIBMOLTENVK);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
#define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) goto fail;
|
||||
|
@ -130,12 +130,11 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
|||
LOAD_FUNCPTR(vkQueuePresentKHR)
|
||||
#undef LOAD_FUNCPTR
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
|
||||
fail:
|
||||
dlclose(vulkan_handle);
|
||||
vulkan_handle = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo.
|
||||
|
@ -625,7 +624,7 @@ static void *macdrv_get_vk_instance_proc_addr(VkInstance instance, const char *n
|
|||
|
||||
static const struct vulkan_funcs *get_vulkan_driver(UINT version)
|
||||
{
|
||||
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
||||
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
|
||||
|
||||
if (version != WINE_VULKAN_DRIVER_VERSION)
|
||||
{
|
||||
|
@ -633,7 +632,7 @@ static const struct vulkan_funcs *get_vulkan_driver(UINT version)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL);
|
||||
pthread_once(&init_once, wine_vk_init);
|
||||
if (vulkan_handle)
|
||||
return &vulkan_funcs;
|
||||
|
||||
|
|
Loading…
Reference in New Issue