1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00
wine/dlls/win32u/vulkan.c

91 lines
2.5 KiB
C

/*
* Vulkan display driver loading
*
* Copyright (c) 2017 Roderick Colenbrander
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <dlfcn.h>
#include <pthread.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "win32u_private.h"
#include "wine/vulkan.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)
*/
const struct vulkan_funcs *__wine_get_vulkan_driver( UINT 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 */