Commit cc3c23c3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Move wine_vk_init to loader.c.

parent 2d3309d8
...@@ -206,6 +206,73 @@ VkResult WINAPI wine_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supporte ...@@ -206,6 +206,73 @@ VkResult WINAPI wine_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *supporte
return VK_SUCCESS; return VK_SUCCESS;
} }
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
{
const struct vulkan_funcs *driver;
HDC hdc;
hdc = GetDC(0);
driver = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION);
ReleaseDC(0, hdc);
if (!driver)
ERR("Failed to load Wine graphics driver supporting Vulkan.\n");
else
unix_vk_init(driver);
return driver != NULL;
}
static BOOL wine_vk_init_once(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
return InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL);
}
VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance)
{
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
if(!wine_vk_init_once())
return VK_ERROR_INITIALIZATION_FAILED;
return unix_vkCreateInstance(create_info, allocator, instance);
}
VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties *properties)
{
TRACE("%p, %p, %p\n", layer_name, count, properties);
if (layer_name)
{
WARN("Layer enumeration not supported from ICD.\n");
return VK_ERROR_LAYER_NOT_PRESENT;
}
if (!wine_vk_init_once())
{
*count = 0;
return VK_SUCCESS;
}
return unix_vkEnumerateInstanceExtensionProperties(layer_name, count, properties);
}
VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version)
{
TRACE("%p\n", version);
if (!wine_vk_init_once())
{
*version = VK_API_VERSION_1_0;
return VK_SUCCESS;
}
return unix_vkEnumerateInstanceVersion(version);
}
static HANDLE get_display_device_init_mutex(void) static HANDLE get_display_device_init_mutex(void)
{ {
static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0}; static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0};
......
...@@ -450,26 +450,10 @@ static void wine_vk_device_free(struct VkDevice_T *device) ...@@ -450,26 +450,10 @@ static void wine_vk_device_free(struct VkDevice_T *device)
free(device); free(device);
} }
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) void unix_vk_init(const struct vulkan_funcs *driver)
{ {
HDC hdc; vk_funcs = driver;
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
hdc = GetDC(0);
vk_funcs = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION);
ReleaseDC(0, hdc);
if (!vk_funcs)
ERR("Failed to load Wine graphics driver supporting Vulkan.\n");
else
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
return TRUE;
}
static void wine_vk_init_once(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL);
} }
/* Helper function for converting between win32 and host compatible VkInstanceCreateInfo. /* Helper function for converting between win32 and host compatible VkInstanceCreateInfo.
...@@ -845,7 +829,7 @@ fail: ...@@ -845,7 +829,7 @@ fail:
return res; return res;
} }
VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, VkResult WINAPI unix_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance) const VkAllocationCallbacks *allocator, VkInstance *instance)
{ {
VkInstanceCreateInfo create_info_host; VkInstanceCreateInfo create_info_host;
...@@ -853,12 +837,6 @@ VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, ...@@ -853,12 +837,6 @@ VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *create_info,
struct VkInstance_T *object; struct VkInstance_T *object;
VkResult res; VkResult res;
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
wine_vk_init_once();
if (!vk_funcs)
return VK_ERROR_INITIALIZATION_FAILED;
if (allocator) if (allocator)
FIXME("Support for allocation callbacks not implemented yet\n"); FIXME("Support for allocation callbacks not implemented yet\n");
...@@ -975,7 +953,7 @@ VkResult WINAPI wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice phys_ ...@@ -975,7 +953,7 @@ VkResult WINAPI wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice phys_
return *count < phys_dev->extension_count ? VK_INCOMPLETE : VK_SUCCESS; return *count < phys_dev->extension_count ? VK_INCOMPLETE : VK_SUCCESS;
} }
VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_name, VkResult WINAPI unix_vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties *properties) uint32_t *count, VkExtensionProperties *properties)
{ {
uint32_t num_properties = 0, num_host_properties; uint32_t num_properties = 0, num_host_properties;
...@@ -983,21 +961,6 @@ VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_na ...@@ -983,21 +961,6 @@ VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_na
unsigned int i, j; unsigned int i, j;
VkResult res; VkResult res;
TRACE("%p, %p, %p\n", layer_name, count, properties);
if (layer_name)
{
WARN("Layer enumeration not supported from ICD.\n");
return VK_ERROR_LAYER_NOT_PRESENT;
}
wine_vk_init_once();
if (!vk_funcs)
{
*count = 0;
return VK_SUCCESS;
}
res = vk_funcs->p_vkEnumerateInstanceExtensionProperties(NULL, &num_host_properties, NULL); res = vk_funcs->p_vkEnumerateInstanceExtensionProperties(NULL, &num_host_properties, NULL);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
return res; return res;
...@@ -1055,14 +1018,10 @@ VkResult WINAPI wine_vkEnumerateDeviceLayerProperties(VkPhysicalDevice phys_dev, ...@@ -1055,14 +1018,10 @@ VkResult WINAPI wine_vkEnumerateDeviceLayerProperties(VkPhysicalDevice phys_dev,
return VK_SUCCESS; return VK_SUCCESS;
} }
VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version) VkResult WINAPI unix_vkEnumerateInstanceVersion(uint32_t *version)
{ {
VkResult res; VkResult res;
TRACE("%p\n", version);
wine_vk_init_once();
if (p_vkEnumerateInstanceVersion) if (p_vkEnumerateInstanceVersion)
{ {
res = p_vkEnumerateInstanceVersion(version); res = p_vkEnumerateInstanceVersion(version);
......
...@@ -243,4 +243,12 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN; ...@@ -243,4 +243,12 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN;
BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN; BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN;
uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle) DECLSPEC_HIDDEN; uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle) DECLSPEC_HIDDEN;
void unix_vk_init(const struct vulkan_funcs *driver) DECLSPEC_HIDDEN;
VkResult WINAPI unix_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance) DECLSPEC_HIDDEN;
VkResult WINAPI unix_vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties *properties) DECLSPEC_HIDDEN;
VkResult WINAPI unix_vkEnumerateInstanceVersion(uint32_t *version) DECLSPEC_HIDDEN;
#endif /* __WINE_VULKAN_PRIVATE_H */ #endif /* __WINE_VULKAN_PRIVATE_H */
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