2018-02-26 19:42:12 +01:00
|
|
|
/* Wine Vulkan ICD implementation
|
|
|
|
*
|
|
|
|
* Copyright 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
|
|
|
|
*/
|
|
|
|
|
2021-04-16 15:49:18 +02:00
|
|
|
#if 0
|
|
|
|
#pragma makedep unix
|
|
|
|
#endif
|
|
|
|
|
2020-07-19 09:35:44 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include <time.h>
|
2021-04-13 00:53:17 +02:00
|
|
|
#include <stdlib.h>
|
2018-02-26 19:42:12 +01:00
|
|
|
|
2021-12-09 03:14:01 +01:00
|
|
|
#include "vulkan_private.h"
|
2020-03-31 02:35:24 +02:00
|
|
|
#include "winreg.h"
|
2021-12-09 03:15:49 +01:00
|
|
|
#include "ntuser.h"
|
2018-02-26 19:42:12 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
|
|
|
|
2018-07-12 11:39:42 +02:00
|
|
|
#define wine_vk_find_struct(s, t) wine_vk_find_struct_((void *)s, VK_STRUCTURE_TYPE_##t)
|
|
|
|
static void *wine_vk_find_struct_(void *s, VkStructureType t)
|
|
|
|
{
|
2019-03-01 08:43:13 +01:00
|
|
|
VkBaseOutStructure *header;
|
2018-07-12 11:39:42 +02:00
|
|
|
|
|
|
|
for (header = s; header; header = header->pNext)
|
|
|
|
{
|
|
|
|
if (header->sType == t)
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-10-13 19:28:37 +02:00
|
|
|
#define wine_vk_count_struct(s, t) wine_vk_count_struct_((void *)s, VK_STRUCTURE_TYPE_##t)
|
|
|
|
static uint32_t wine_vk_count_struct_(void *s, VkStructureType t)
|
|
|
|
{
|
|
|
|
const VkBaseInStructure *header;
|
|
|
|
uint32_t result = 0;
|
|
|
|
|
|
|
|
for (header = s; header; header = header->pNext)
|
|
|
|
{
|
|
|
|
if (header->sType == t)
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-03-29 14:53:54 +02:00
|
|
|
static const struct vulkan_funcs *vk_funcs;
|
2018-02-26 19:42:15 +01:00
|
|
|
|
2020-10-13 19:28:36 +02:00
|
|
|
#define WINE_VK_ADD_DISPATCHABLE_MAPPING(instance, object, native_handle) \
|
|
|
|
wine_vk_add_handle_mapping((instance), (uint64_t) (uintptr_t) (object), (uint64_t) (uintptr_t) (native_handle), &(object)->mapping)
|
|
|
|
#define WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, native_handle) \
|
|
|
|
wine_vk_add_handle_mapping((instance), (uint64_t) (uintptr_t) (object), (uint64_t) (native_handle), &(object)->mapping)
|
|
|
|
static void wine_vk_add_handle_mapping(struct VkInstance_T *instance, uint64_t wrapped_handle,
|
|
|
|
uint64_t native_handle, struct wine_vk_mapping *mapping)
|
|
|
|
{
|
|
|
|
if (instance->enable_wrapper_list)
|
|
|
|
{
|
|
|
|
mapping->native_handle = native_handle;
|
|
|
|
mapping->wine_wrapped_handle = wrapped_handle;
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_wrlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
list_add_tail(&instance->wrappers, &mapping->link);
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_unlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define WINE_VK_REMOVE_HANDLE_MAPPING(instance, object) \
|
|
|
|
wine_vk_remove_handle_mapping((instance), &(object)->mapping)
|
|
|
|
static void wine_vk_remove_handle_mapping(struct VkInstance_T *instance, struct wine_vk_mapping *mapping)
|
|
|
|
{
|
|
|
|
if (instance->enable_wrapper_list)
|
|
|
|
{
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_wrlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
list_remove(&mapping->link);
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_unlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t wine_vk_get_wrapper(struct VkInstance_T *instance, uint64_t native_handle)
|
|
|
|
{
|
|
|
|
struct wine_vk_mapping *mapping;
|
|
|
|
uint64_t result = 0;
|
|
|
|
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_rdlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(mapping, &instance->wrappers, struct wine_vk_mapping, link)
|
|
|
|
{
|
|
|
|
if (mapping->native_handle == native_handle)
|
|
|
|
{
|
|
|
|
result = mapping->wine_wrapped_handle;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_unlock(&instance->wrapper_lock);
|
2020-10-13 19:28:36 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-13 19:28:37 +02:00
|
|
|
static VkBool32 debug_utils_callback_conversion(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
|
|
|
|
VkDebugUtilsMessageTypeFlagsEXT message_types,
|
|
|
|
const VkDebugUtilsMessengerCallbackDataEXT_host *callback_data,
|
|
|
|
void *user_data)
|
|
|
|
{
|
2021-12-09 03:15:49 +01:00
|
|
|
struct wine_vk_debug_utils_params params;
|
2020-10-13 19:28:37 +02:00
|
|
|
VkDebugUtilsObjectNameInfoEXT *object_name_infos;
|
|
|
|
struct wine_debug_utils_messenger *object;
|
2021-12-09 03:15:49 +01:00
|
|
|
void *ret_ptr;
|
|
|
|
ULONG ret_len;
|
2020-10-13 19:28:37 +02:00
|
|
|
VkBool32 result;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("%i, %u, %p, %p\n", severity, message_types, callback_data, user_data);
|
|
|
|
|
|
|
|
object = user_data;
|
|
|
|
|
|
|
|
if (!object->instance->instance)
|
|
|
|
{
|
|
|
|
/* instance wasn't yet created, this is a message from the native loader */
|
|
|
|
return VK_FALSE;
|
|
|
|
}
|
|
|
|
|
2021-12-09 03:15:49 +01:00
|
|
|
/* FIXME: we should pack all referenced structs instead of passing pointers */
|
|
|
|
params.user_callback = object->user_callback;
|
|
|
|
params.user_data = object->user_data;
|
|
|
|
params.severity = severity;
|
|
|
|
params.message_types = message_types;
|
|
|
|
params.data = *((VkDebugUtilsMessengerCallbackDataEXT *) callback_data);
|
2020-10-13 19:28:37 +02:00
|
|
|
|
2021-12-09 03:15:49 +01:00
|
|
|
object_name_infos = calloc(params.data.objectCount, sizeof(*object_name_infos));
|
2020-10-13 19:28:37 +02:00
|
|
|
|
2021-12-09 03:15:49 +01:00
|
|
|
for (i = 0; i < params.data.objectCount; i++)
|
2020-10-13 19:28:37 +02:00
|
|
|
{
|
|
|
|
object_name_infos[i].sType = callback_data->pObjects[i].sType;
|
|
|
|
object_name_infos[i].pNext = callback_data->pObjects[i].pNext;
|
|
|
|
object_name_infos[i].objectType = callback_data->pObjects[i].objectType;
|
|
|
|
object_name_infos[i].pObjectName = callback_data->pObjects[i].pObjectName;
|
|
|
|
|
|
|
|
if (wine_vk_is_type_wrapped(callback_data->pObjects[i].objectType))
|
|
|
|
{
|
|
|
|
object_name_infos[i].objectHandle = wine_vk_get_wrapper(object->instance, callback_data->pObjects[i].objectHandle);
|
|
|
|
if (!object_name_infos[i].objectHandle)
|
|
|
|
{
|
|
|
|
WARN("handle conversion failed 0x%s\n", wine_dbgstr_longlong(callback_data->pObjects[i].objectHandle));
|
2021-12-09 03:14:01 +01:00
|
|
|
free(object_name_infos);
|
2020-10-13 19:28:37 +02:00
|
|
|
return VK_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
object_name_infos[i].objectHandle = callback_data->pObjects[i].objectHandle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 03:15:49 +01:00
|
|
|
params.data.pObjects = object_name_infos;
|
2020-10-13 19:28:37 +02:00
|
|
|
|
|
|
|
/* applications should always return VK_FALSE */
|
2021-12-09 03:15:49 +01:00
|
|
|
result = KeUserModeCallback( NtUserCallVulkanDebugUtilsCallback, ¶ms, sizeof(params),
|
|
|
|
&ret_ptr, &ret_len );
|
2020-10-13 19:28:37 +02:00
|
|
|
|
2021-12-09 03:14:01 +01:00
|
|
|
free(object_name_infos);
|
2020-10-13 19:28:37 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-10-27 21:18:54 +01:00
|
|
|
static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT object_type,
|
|
|
|
uint64_t object_handle, size_t location, int32_t code, const char *layer_prefix, const char *message, void *user_data)
|
|
|
|
{
|
2021-12-09 03:15:49 +01:00
|
|
|
struct wine_vk_debug_report_params params;
|
2020-10-27 21:18:54 +01:00
|
|
|
struct wine_debug_report_callback *object;
|
2021-12-09 03:15:49 +01:00
|
|
|
void *ret_ptr;
|
|
|
|
ULONG ret_len;
|
2020-10-27 21:18:54 +01:00
|
|
|
|
|
|
|
TRACE("%#x, %#x, 0x%s, 0x%s, %d, %p, %p, %p\n", flags, object_type, wine_dbgstr_longlong(object_handle),
|
|
|
|
wine_dbgstr_longlong(location), code, layer_prefix, message, user_data);
|
|
|
|
|
|
|
|
object = user_data;
|
|
|
|
|
|
|
|
if (!object->instance->instance)
|
|
|
|
{
|
|
|
|
/* instance wasn't yet created, this is a message from the native loader */
|
|
|
|
return VK_FALSE;
|
|
|
|
}
|
|
|
|
|
2021-12-09 03:15:49 +01:00
|
|
|
/* FIXME: we should pack all referenced structs instead of passing pointers */
|
|
|
|
params.user_callback = object->user_callback;
|
|
|
|
params.user_data = object->user_data;
|
|
|
|
params.flags = flags;
|
|
|
|
params.object_type = object_type;
|
|
|
|
params.location = location;
|
|
|
|
params.code = code;
|
|
|
|
params.layer_prefix = layer_prefix;
|
|
|
|
params.message = message;
|
|
|
|
|
|
|
|
params.object_handle = wine_vk_get_wrapper(object->instance, object_handle);
|
|
|
|
if (!params.object_handle)
|
|
|
|
params.object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
|
|
|
|
|
|
|
|
return KeUserModeCallback( NtUserCallVulkanDebugReportCallback, ¶ms, sizeof(params),
|
|
|
|
&ret_ptr, &ret_len );
|
2020-10-27 21:18:54 +01:00
|
|
|
}
|
|
|
|
|
2018-03-24 14:27:59 +01:00
|
|
|
static void wine_vk_physical_device_free(struct VkPhysicalDevice_T *phys_dev)
|
|
|
|
{
|
|
|
|
if (!phys_dev)
|
|
|
|
return;
|
|
|
|
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(phys_dev->instance, phys_dev);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(phys_dev->extensions);
|
|
|
|
free(phys_dev);
|
2018-03-24 14:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct VkPhysicalDevice_T *wine_vk_physical_device_alloc(struct VkInstance_T *instance,
|
|
|
|
VkPhysicalDevice phys_dev)
|
|
|
|
{
|
|
|
|
struct VkPhysicalDevice_T *object;
|
|
|
|
uint32_t num_host_properties, num_properties = 0;
|
|
|
|
VkExtensionProperties *host_properties = NULL;
|
|
|
|
VkResult res;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2018-03-24 14:27:59 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
object->base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
|
|
|
|
object->instance = instance;
|
|
|
|
object->phys_dev = phys_dev;
|
|
|
|
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_ADD_DISPATCHABLE_MAPPING(instance, object, phys_dev);
|
|
|
|
|
2018-03-24 14:27:59 +01:00
|
|
|
res = instance->funcs.p_vkEnumerateDeviceExtensionProperties(phys_dev,
|
|
|
|
NULL, &num_host_properties, NULL);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to enumerate device extensions, res=%d\n", res);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
host_properties = calloc(num_host_properties, sizeof(*host_properties));
|
2018-03-24 14:27:59 +01:00
|
|
|
if (!host_properties)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate memory for device properties!\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = instance->funcs.p_vkEnumerateDeviceExtensionProperties(phys_dev,
|
|
|
|
NULL, &num_host_properties, host_properties);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to enumerate device extensions, res=%d\n", res);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Count list of extensions for which we have an implementation.
|
|
|
|
* TODO: perform translation for platform specific extensions.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < num_host_properties; i++)
|
|
|
|
{
|
|
|
|
if (wine_vk_device_extension_supported(host_properties[i].extensionName))
|
|
|
|
{
|
|
|
|
TRACE("Enabling extension '%s' for physical device %p\n", host_properties[i].extensionName, object);
|
|
|
|
num_properties++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Skipping extension '%s', no implementation found in winevulkan.\n", host_properties[i].extensionName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Host supported extensions %u, Wine supported extensions %u\n", num_host_properties, num_properties);
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object->extensions = calloc(num_properties, sizeof(*object->extensions))))
|
2018-03-24 14:27:59 +01:00
|
|
|
{
|
2018-03-29 14:53:51 +02:00
|
|
|
ERR("Failed to allocate memory for device extensions!\n");
|
2018-03-24 14:27:59 +01:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < num_host_properties; i++)
|
|
|
|
{
|
|
|
|
if (wine_vk_device_extension_supported(host_properties[i].extensionName))
|
|
|
|
{
|
2018-03-29 14:53:51 +02:00
|
|
|
object->extensions[j] = host_properties[i];
|
2018-03-24 14:27:59 +01:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 14:53:51 +02:00
|
|
|
object->extension_count = num_properties;
|
2018-03-24 14:27:59 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_properties);
|
2018-03-24 14:27:59 +01:00
|
|
|
return object;
|
|
|
|
|
|
|
|
err:
|
|
|
|
wine_vk_physical_device_free(object);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_properties);
|
2018-03-24 14:27:59 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-08-30 12:22:31 +02:00
|
|
|
static void wine_vk_free_command_buffers(struct VkDevice_T *device,
|
|
|
|
struct wine_cmd_pool *pool, uint32_t count, const VkCommandBuffer *buffers)
|
2018-03-14 13:11:54 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!buffers[i])
|
|
|
|
continue;
|
|
|
|
|
2018-08-30 12:22:31 +02:00
|
|
|
device->funcs.p_vkFreeCommandBuffers(device->device, pool->command_pool, 1, &buffers[i]->command_buffer);
|
2018-08-30 12:22:32 +02:00
|
|
|
list_remove(&buffers[i]->pool_link);
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, buffers[i]);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(buffers[i]);
|
2018-03-14 13:11:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
static void wine_vk_device_get_queues(struct VkDevice_T *device,
|
|
|
|
uint32_t family_index, uint32_t queue_count, VkDeviceQueueCreateFlags flags,
|
|
|
|
struct VkQueue_T* queues)
|
2018-03-14 13:11:52 +01:00
|
|
|
{
|
2018-08-20 10:05:12 +02:00
|
|
|
VkDeviceQueueInfo2 queue_info;
|
2018-03-14 13:11:52 +01:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < queue_count; i++)
|
|
|
|
{
|
|
|
|
struct VkQueue_T *queue = &queues[i];
|
2018-07-16 15:18:19 +02:00
|
|
|
|
|
|
|
queue->base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
|
2018-03-14 13:11:52 +01:00
|
|
|
queue->device = device;
|
2021-04-14 00:31:25 +02:00
|
|
|
queue->family_index = family_index;
|
|
|
|
queue->queue_index = i;
|
2018-07-16 15:18:19 +02:00
|
|
|
queue->flags = flags;
|
2018-03-14 13:11:52 +01:00
|
|
|
|
2018-08-20 10:05:12 +02:00
|
|
|
/* The Vulkan spec says:
|
|
|
|
*
|
|
|
|
* "vkGetDeviceQueue must only be used to get queues that were created
|
|
|
|
* with the flags parameter of VkDeviceQueueCreateInfo set to zero."
|
2018-03-14 13:11:52 +01:00
|
|
|
*/
|
2018-08-20 10:05:12 +02:00
|
|
|
if (flags && device->funcs.p_vkGetDeviceQueue2)
|
|
|
|
{
|
|
|
|
queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2;
|
|
|
|
queue_info.pNext = NULL;
|
|
|
|
queue_info.flags = flags;
|
|
|
|
queue_info.queueFamilyIndex = family_index;
|
|
|
|
queue_info.queueIndex = i;
|
|
|
|
device->funcs.p_vkGetDeviceQueue2(device->device, &queue_info, &queue->queue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device->funcs.p_vkGetDeviceQueue(device->device, family_index, i, &queue->queue);
|
|
|
|
}
|
2020-10-13 19:28:36 +02:00
|
|
|
|
|
|
|
WINE_VK_ADD_DISPATCHABLE_MAPPING(device->phys_dev->instance, queue, queue->queue);
|
2018-03-14 13:11:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 15:59:34 +01:00
|
|
|
static void wine_vk_device_free_create_info(VkDeviceCreateInfo *create_info)
|
|
|
|
{
|
2019-04-10 11:59:50 +02:00
|
|
|
free_VkDeviceCreateInfo_struct_chain(create_info);
|
2019-03-19 15:59:34 +01:00
|
|
|
}
|
|
|
|
|
2018-07-12 11:39:42 +02:00
|
|
|
static VkResult wine_vk_device_convert_create_info(const VkDeviceCreateInfo *src,
|
2018-03-23 14:46:14 +01:00
|
|
|
VkDeviceCreateInfo *dst)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2019-04-10 11:59:50 +02:00
|
|
|
VkResult res;
|
2018-03-23 14:46:14 +01:00
|
|
|
|
|
|
|
*dst = *src;
|
|
|
|
|
2019-04-10 11:59:50 +02:00
|
|
|
if ((res = convert_VkDeviceCreateInfo_struct_chain(src->pNext, dst)) < 0)
|
2018-03-23 14:46:14 +01:00
|
|
|
{
|
2019-04-10 11:59:50 +02:00
|
|
|
WARN("Failed to convert VkDeviceCreateInfo pNext chain, res=%d.\n", res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2018-03-23 14:46:14 +01:00
|
|
|
/* Should be filtered out by loader as ICDs don't support layers. */
|
|
|
|
dst->enabledLayerCount = 0;
|
|
|
|
dst->ppEnabledLayerNames = NULL;
|
|
|
|
|
2018-09-10 13:07:00 +02:00
|
|
|
TRACE("Enabled %u extensions.\n", dst->enabledExtensionCount);
|
2018-03-23 14:46:14 +01:00
|
|
|
for (i = 0; i < dst->enabledExtensionCount; i++)
|
|
|
|
{
|
2018-09-10 13:07:00 +02:00
|
|
|
const char *extension_name = dst->ppEnabledExtensionNames[i];
|
|
|
|
TRACE("Extension %u: %s.\n", i, debugstr_a(extension_name));
|
|
|
|
if (!wine_vk_device_extension_supported(extension_name))
|
|
|
|
{
|
|
|
|
WARN("Extension %s is not supported.\n", debugstr_a(extension_name));
|
2019-04-10 11:59:50 +02:00
|
|
|
wine_vk_device_free_create_info(dst);
|
2018-09-10 13:07:00 +02:00
|
|
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
|
|
}
|
2018-07-12 11:39:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
2018-03-23 14:46:14 +01:00
|
|
|
}
|
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
/* Helper function used for freeing a device structure. This function supports full
|
|
|
|
* and partial object cleanups and can thus be used for vkCreateDevice failures.
|
|
|
|
*/
|
|
|
|
static void wine_vk_device_free(struct VkDevice_T *device)
|
|
|
|
{
|
2021-04-14 00:31:25 +02:00
|
|
|
struct VkQueue_T *queue;
|
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
if (!device)
|
|
|
|
return;
|
|
|
|
|
2018-03-14 13:11:52 +01:00
|
|
|
if (device->queues)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2021-04-14 00:31:25 +02:00
|
|
|
for (i = 0; i < device->queue_count; i++)
|
2018-03-14 13:11:52 +01:00
|
|
|
{
|
2021-04-14 00:31:25 +02:00
|
|
|
queue = &device->queues[i];
|
|
|
|
if (queue && queue->queue)
|
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, queue);
|
2018-03-14 13:11:52 +01:00
|
|
|
}
|
2021-04-13 00:53:17 +02:00
|
|
|
free(device->queues);
|
2018-03-14 13:11:52 +01:00
|
|
|
device->queues = NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
if (device->device && device->funcs.p_vkDestroyDevice)
|
|
|
|
{
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, device);
|
2018-03-09 17:48:48 +01:00
|
|
|
device->funcs.p_vkDestroyDevice(device->device, NULL /* pAllocator */);
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(device);
|
2018-03-09 17:48:48 +01:00
|
|
|
}
|
|
|
|
|
2021-12-09 03:14:01 +01:00
|
|
|
NTSTATUS init_vulkan(void *args)
|
2018-02-26 19:42:15 +01:00
|
|
|
{
|
2021-12-09 03:14:01 +01:00
|
|
|
vk_funcs = *(const struct vulkan_funcs **)args;
|
|
|
|
*(const struct unix_funcs **)args = &loader_funcs;
|
2021-04-16 15:49:18 +02:00
|
|
|
return STATUS_SUCCESS;
|
2020-06-27 01:21:54 +02:00
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:54 +01:00
|
|
|
/* Helper function for converting between win32 and host compatible VkInstanceCreateInfo.
|
|
|
|
* This function takes care of extensions handled at winevulkan layer, a Wine graphics
|
|
|
|
* driver is responsible for handling e.g. surface extensions.
|
|
|
|
*/
|
2018-09-10 13:06:58 +02:00
|
|
|
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
|
2020-09-08 21:46:27 +02:00
|
|
|
VkInstanceCreateInfo *dst, struct VkInstance_T *object)
|
2018-03-12 15:37:54 +01:00
|
|
|
{
|
2020-10-13 19:28:37 +02:00
|
|
|
VkDebugUtilsMessengerCreateInfoEXT *debug_utils_messenger;
|
2020-10-27 21:18:54 +01:00
|
|
|
VkDebugReportCallbackCreateInfoEXT *debug_report_callback;
|
2020-10-13 19:28:37 +02:00
|
|
|
VkBaseInStructure *header;
|
2018-03-23 14:46:15 +01:00
|
|
|
unsigned int i;
|
2019-04-10 11:59:49 +02:00
|
|
|
VkResult res;
|
2018-03-23 14:46:15 +01:00
|
|
|
|
2018-03-23 14:46:16 +01:00
|
|
|
*dst = *src;
|
2018-03-12 15:37:54 +01:00
|
|
|
|
2019-04-10 11:59:49 +02:00
|
|
|
if ((res = convert_VkInstanceCreateInfo_struct_chain(src->pNext, dst)) < 0)
|
2018-03-12 15:37:54 +01:00
|
|
|
{
|
2019-04-10 11:59:49 +02:00
|
|
|
WARN("Failed to convert VkInstanceCreateInfo pNext chain, res=%d.\n", res);
|
|
|
|
return res;
|
2018-03-12 15:37:54 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 19:28:37 +02:00
|
|
|
object->utils_messenger_count = wine_vk_count_struct(dst, DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT);
|
2021-04-13 00:53:17 +02:00
|
|
|
object->utils_messengers = calloc(object->utils_messenger_count, sizeof(*object->utils_messengers));
|
2020-10-13 19:28:37 +02:00
|
|
|
header = (VkBaseInStructure *) dst;
|
|
|
|
for (i = 0; i < object->utils_messenger_count; i++)
|
|
|
|
{
|
|
|
|
header = wine_vk_find_struct(header->pNext, DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT);
|
|
|
|
debug_utils_messenger = (VkDebugUtilsMessengerCreateInfoEXT *) header;
|
|
|
|
|
|
|
|
object->utils_messengers[i].instance = object;
|
|
|
|
object->utils_messengers[i].debug_messenger = VK_NULL_HANDLE;
|
|
|
|
object->utils_messengers[i].user_callback = debug_utils_messenger->pfnUserCallback;
|
|
|
|
object->utils_messengers[i].user_data = debug_utils_messenger->pUserData;
|
|
|
|
|
|
|
|
/* convert_VkInstanceCreateInfo_struct_chain already copied the chain,
|
|
|
|
* so we can modify it in-place.
|
|
|
|
*/
|
|
|
|
debug_utils_messenger->pfnUserCallback = (void *) &debug_utils_callback_conversion;
|
|
|
|
debug_utils_messenger->pUserData = &object->utils_messengers[i];
|
|
|
|
}
|
|
|
|
|
2020-10-27 21:18:54 +01:00
|
|
|
debug_report_callback = wine_vk_find_struct(header->pNext, DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT);
|
|
|
|
if (debug_report_callback)
|
|
|
|
{
|
|
|
|
object->default_callback.instance = object;
|
|
|
|
object->default_callback.debug_callback = VK_NULL_HANDLE;
|
|
|
|
object->default_callback.user_callback = debug_report_callback->pfnCallback;
|
|
|
|
object->default_callback.user_data = debug_report_callback->pUserData;
|
|
|
|
|
|
|
|
debug_report_callback->pfnCallback = (void *) &debug_report_callback_conversion;
|
|
|
|
debug_report_callback->pUserData = &object->default_callback;
|
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:54 +01:00
|
|
|
/* ICDs don't support any layers, so nothing to copy. Modern versions of the loader
|
|
|
|
* filter this data out as well.
|
|
|
|
*/
|
2020-09-08 21:46:27 +02:00
|
|
|
if (object->quirks & WINEVULKAN_QUIRK_IGNORE_EXPLICIT_LAYERS) {
|
|
|
|
dst->enabledLayerCount = 0;
|
|
|
|
dst->ppEnabledLayerNames = NULL;
|
|
|
|
WARN("Ignoring explicit layers!\n");
|
|
|
|
} else if (dst->enabledLayerCount) {
|
|
|
|
FIXME("Loading explicit layers is not supported by winevulkan!\n");
|
|
|
|
return VK_ERROR_LAYER_NOT_PRESENT;
|
|
|
|
}
|
2018-03-12 15:37:54 +01:00
|
|
|
|
2018-09-10 13:06:58 +02:00
|
|
|
TRACE("Enabled %u instance extensions.\n", dst->enabledExtensionCount);
|
2018-03-23 14:46:15 +01:00
|
|
|
for (i = 0; i < dst->enabledExtensionCount; i++)
|
|
|
|
{
|
2018-09-10 13:06:58 +02:00
|
|
|
const char *extension_name = dst->ppEnabledExtensionNames[i];
|
|
|
|
TRACE("Extension %u: %s.\n", i, debugstr_a(extension_name));
|
|
|
|
if (!wine_vk_instance_extension_supported(extension_name))
|
|
|
|
{
|
|
|
|
WARN("Extension %s is not supported.\n", debugstr_a(extension_name));
|
2019-04-10 11:59:49 +02:00
|
|
|
free_VkInstanceCreateInfo_struct_chain(dst);
|
2018-09-10 13:06:58 +02:00
|
|
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
|
|
}
|
2020-10-27 21:18:54 +01:00
|
|
|
if (!strcmp(extension_name, "VK_EXT_debug_utils") || !strcmp(extension_name, "VK_EXT_debug_report"))
|
2020-10-13 19:28:37 +02:00
|
|
|
{
|
|
|
|
object->enable_wrapper_list = VK_TRUE;
|
|
|
|
}
|
2018-03-23 14:46:15 +01:00
|
|
|
}
|
2018-09-10 13:06:58 +02:00
|
|
|
|
|
|
|
return VK_SUCCESS;
|
2018-03-12 15:37:54 +01:00
|
|
|
}
|
|
|
|
|
2018-03-06 17:28:48 +01:00
|
|
|
/* Helper function which stores wrapped physical devices in the instance object. */
|
|
|
|
static VkResult wine_vk_instance_load_physical_devices(struct VkInstance_T *instance)
|
|
|
|
{
|
2018-07-12 11:39:43 +02:00
|
|
|
VkPhysicalDevice *tmp_phys_devs;
|
|
|
|
uint32_t phys_dev_count;
|
2018-03-06 17:28:48 +01:00
|
|
|
unsigned int i;
|
2018-07-12 11:39:43 +02:00
|
|
|
VkResult res;
|
2018-03-06 17:28:48 +01:00
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
res = instance->funcs.p_vkEnumeratePhysicalDevices(instance->instance, &phys_dev_count, NULL);
|
2018-03-06 17:28:48 +01:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to enumerate physical devices, res=%d\n", res);
|
|
|
|
return res;
|
|
|
|
}
|
2018-07-12 11:39:43 +02:00
|
|
|
if (!phys_dev_count)
|
|
|
|
return res;
|
2018-03-06 17:28:48 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(tmp_phys_devs = calloc(phys_dev_count, sizeof(*tmp_phys_devs))))
|
2018-03-06 17:28:48 +01:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
res = instance->funcs.p_vkEnumeratePhysicalDevices(instance->instance, &phys_dev_count, tmp_phys_devs);
|
2018-03-06 17:28:48 +01:00
|
|
|
if (res != VK_SUCCESS)
|
2018-03-29 14:53:55 +02:00
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(tmp_phys_devs);
|
2018-03-29 14:53:55 +02:00
|
|
|
return res;
|
|
|
|
}
|
2018-03-06 17:28:48 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
instance->phys_devs = calloc(phys_dev_count, sizeof(*instance->phys_devs));
|
2018-03-06 17:28:48 +01:00
|
|
|
if (!instance->phys_devs)
|
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(tmp_phys_devs);
|
2018-03-29 14:53:55 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Wrap each native physical device handle into a dispatchable object for the ICD loader. */
|
2018-07-12 11:39:43 +02:00
|
|
|
for (i = 0; i < phys_dev_count; i++)
|
2018-03-06 17:28:48 +01:00
|
|
|
{
|
2018-03-14 13:11:50 +01:00
|
|
|
struct VkPhysicalDevice_T *phys_dev = wine_vk_physical_device_alloc(instance, tmp_phys_devs[i]);
|
2018-03-06 17:28:48 +01:00
|
|
|
if (!phys_dev)
|
|
|
|
{
|
|
|
|
ERR("Unable to allocate memory for physical device!\n");
|
2021-04-13 00:53:17 +02:00
|
|
|
free(tmp_phys_devs);
|
2018-03-29 14:53:55 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
instance->phys_devs[i] = phys_dev;
|
2018-07-12 11:39:43 +02:00
|
|
|
instance->phys_dev_count = i + 1;
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
2018-07-12 11:39:43 +02:00
|
|
|
instance->phys_dev_count = phys_dev_count;
|
2018-03-06 17:28:48 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(tmp_phys_devs);
|
2018-03-06 17:28:48 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
static struct VkPhysicalDevice_T *wine_vk_instance_wrap_physical_device(struct VkInstance_T *instance,
|
|
|
|
VkPhysicalDevice physical_device)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < instance->phys_dev_count; ++i)
|
|
|
|
{
|
|
|
|
struct VkPhysicalDevice_T *current = instance->phys_devs[i];
|
|
|
|
if (current->phys_dev == physical_device)
|
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("Unrecognized physical device %p.\n", physical_device);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
/* Helper function used for freeing an instance structure. This function supports full
|
|
|
|
* and partial object cleanups and can thus be used for vkCreateInstance failures.
|
|
|
|
*/
|
|
|
|
static void wine_vk_instance_free(struct VkInstance_T *instance)
|
|
|
|
{
|
|
|
|
if (!instance)
|
|
|
|
return;
|
|
|
|
|
2018-03-06 17:28:48 +01:00
|
|
|
if (instance->phys_devs)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
for (i = 0; i < instance->phys_dev_count; i++)
|
2018-03-06 17:28:48 +01:00
|
|
|
{
|
2018-03-14 13:11:50 +01:00
|
|
|
wine_vk_physical_device_free(instance->phys_devs[i]);
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
2021-04-13 00:53:17 +02:00
|
|
|
free(instance->phys_devs);
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
if (instance->instance)
|
2020-10-13 19:28:36 +02:00
|
|
|
{
|
2018-03-01 16:37:03 +01:00
|
|
|
vk_funcs->p_vkDestroyInstance(instance->instance, NULL /* allocator */);
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(instance, instance);
|
|
|
|
}
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_destroy(&instance->wrapper_lock);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(instance->utils_messengers);
|
2020-10-13 19:28:37 +02:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(instance);
|
2018-03-01 16:37:03 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkAllocateCommandBuffers(void *args)
|
2018-03-14 13:11:54 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkAllocateCommandBuffers_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
const VkCommandBufferAllocateInfo *allocate_info = params->pAllocateInfo;
|
|
|
|
VkCommandBuffer *buffers = params->pCommandBuffers;
|
2018-08-30 12:22:31 +02:00
|
|
|
struct wine_cmd_pool *pool;
|
2018-03-14 13:11:54 +01:00
|
|
|
VkResult res = VK_SUCCESS;
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-08-30 12:22:31 +02:00
|
|
|
TRACE("%p, %p, %p\n", device, allocate_info, buffers);
|
|
|
|
|
|
|
|
pool = wine_cmd_pool_from_handle(allocate_info->commandPool);
|
2018-03-14 13:11:54 +01:00
|
|
|
|
|
|
|
memset(buffers, 0, allocate_info->commandBufferCount * sizeof(*buffers));
|
|
|
|
|
|
|
|
for (i = 0; i < allocate_info->commandBufferCount; i++)
|
|
|
|
{
|
|
|
|
VkCommandBufferAllocateInfo_host allocate_info_host;
|
2021-05-31 16:17:25 +02:00
|
|
|
|
2018-03-14 13:11:54 +01:00
|
|
|
/* TODO: future extensions (none yet) may require pNext conversion. */
|
|
|
|
allocate_info_host.pNext = allocate_info->pNext;
|
|
|
|
allocate_info_host.sType = allocate_info->sType;
|
2018-08-30 12:22:31 +02:00
|
|
|
allocate_info_host.commandPool = pool->command_pool;
|
2018-03-14 13:11:54 +01:00
|
|
|
allocate_info_host.level = allocate_info->level;
|
|
|
|
allocate_info_host.commandBufferCount = 1;
|
|
|
|
|
2018-08-30 12:22:32 +02:00
|
|
|
TRACE("Allocating command buffer %u from pool 0x%s.\n",
|
|
|
|
i, wine_dbgstr_longlong(allocate_info_host.commandPool));
|
2018-03-14 13:11:54 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(buffers[i] = calloc(1, sizeof(**buffers))))
|
2018-03-14 13:11:54 +01:00
|
|
|
{
|
|
|
|
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffers[i]->base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
|
|
|
|
buffers[i]->device = device;
|
2018-08-30 12:22:34 +02:00
|
|
|
list_add_tail(&pool->command_buffers, &buffers[i]->pool_link);
|
2018-03-14 13:11:54 +01:00
|
|
|
res = device->funcs.p_vkAllocateCommandBuffers(device->device,
|
|
|
|
&allocate_info_host, &buffers[i]->command_buffer);
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_ADD_DISPATCHABLE_MAPPING(device->phys_dev->instance, buffers[i], buffers[i]->command_buffer);
|
2018-03-14 13:11:54 +01:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2018-08-30 12:22:32 +02:00
|
|
|
ERR("Failed to allocate command buffer, res=%d.\n", res);
|
2018-08-30 12:22:34 +02:00
|
|
|
buffers[i]->command_buffer = VK_NULL_HANDLE;
|
2018-03-14 13:11:54 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2018-08-30 12:22:34 +02:00
|
|
|
wine_vk_free_command_buffers(device, pool, i + 1, buffers);
|
2018-03-14 13:11:54 +01:00
|
|
|
memset(buffers, 0, allocate_info->commandBufferCount * sizeof(*buffers));
|
|
|
|
}
|
|
|
|
|
2018-08-30 12:22:34 +02:00
|
|
|
return res;
|
2018-03-14 13:11:54 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateDevice(void *args)
|
2018-03-09 17:48:48 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateDevice_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkDeviceCreateInfo *create_info = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkDevice *device = params->pDevice;
|
2018-03-23 14:46:14 +01:00
|
|
|
VkDeviceCreateInfo create_info_host;
|
2021-04-14 00:31:25 +02:00
|
|
|
struct VkQueue_T *next_queue;
|
2018-03-23 14:46:14 +01:00
|
|
|
struct VkDevice_T *object;
|
2018-03-14 13:11:52 +01:00
|
|
|
unsigned int i;
|
2018-07-12 11:39:42 +02:00
|
|
|
VkResult res;
|
2018-03-09 17:48:48 +01:00
|
|
|
|
2018-07-12 11:39:42 +02:00
|
|
|
TRACE("%p, %p, %p, %p\n", phys_dev, create_info, allocator, device);
|
2018-03-09 17:48:48 +01:00
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2018-08-28 10:27:12 +02:00
|
|
|
if (TRACE_ON(vulkan))
|
|
|
|
{
|
2021-05-31 16:17:31 +02:00
|
|
|
VkPhysicalDeviceProperties_host properties;
|
2018-08-28 10:27:12 +02:00
|
|
|
|
2021-05-31 16:17:31 +02:00
|
|
|
phys_dev->instance->funcs.p_vkGetPhysicalDeviceProperties(phys_dev->phys_dev, &properties);
|
2018-08-28 10:27:12 +02:00
|
|
|
|
|
|
|
TRACE("Device name: %s.\n", debugstr_a(properties.deviceName));
|
|
|
|
TRACE("Vendor ID: %#x, Device ID: %#x.\n", properties.vendorID, properties.deviceID);
|
|
|
|
TRACE("Driver version: %#x.\n", properties.driverVersion);
|
|
|
|
}
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2018-03-09 17:48:48 +01:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
2021-04-19 14:15:10 +02:00
|
|
|
object->base.base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
|
2020-10-13 19:28:36 +02:00
|
|
|
object->phys_dev = phys_dev;
|
2018-03-09 17:48:48 +01:00
|
|
|
|
2018-07-12 11:39:42 +02:00
|
|
|
res = wine_vk_device_convert_create_info(create_info, &create_info_host);
|
|
|
|
if (res != VK_SUCCESS)
|
2019-04-10 11:59:50 +02:00
|
|
|
goto fail;
|
2018-03-23 14:46:14 +01:00
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
res = phys_dev->instance->funcs.p_vkCreateDevice(phys_dev->phys_dev,
|
2018-03-23 14:46:14 +01:00
|
|
|
&create_info_host, NULL /* allocator */, &object->device);
|
2018-07-12 11:39:42 +02:00
|
|
|
wine_vk_device_free_create_info(&create_info_host);
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_ADD_DISPATCHABLE_MAPPING(phys_dev->instance, object, object->device);
|
2018-03-09 17:48:48 +01:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2019-04-10 11:59:50 +02:00
|
|
|
WARN("Failed to create device, res=%d.\n", res);
|
|
|
|
goto fail;
|
2018-03-09 17:48:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Just load all function pointers we are aware off. The loader takes care of filtering.
|
|
|
|
* We use vkGetDeviceProcAddr as opposed to vkGetInstanceProcAddr for efficiency reasons
|
|
|
|
* as functions pass through fewer dispatch tables within the loader.
|
|
|
|
*/
|
|
|
|
#define USE_VK_FUNC(name) \
|
|
|
|
object->funcs.p_##name = (void *)vk_funcs->p_vkGetDeviceProcAddr(object->device, #name); \
|
|
|
|
if (object->funcs.p_##name == NULL) \
|
2019-04-10 11:59:50 +02:00
|
|
|
TRACE("Not found '%s'.\n", #name);
|
2018-03-09 17:48:48 +01:00
|
|
|
ALL_VK_DEVICE_FUNCS()
|
|
|
|
#undef USE_VK_FUNC
|
|
|
|
|
2018-03-14 13:11:52 +01:00
|
|
|
/* We need to cache all queues within the device as each requires wrapping since queues are
|
|
|
|
* dispatchable objects.
|
|
|
|
*/
|
2021-04-14 00:31:25 +02:00
|
|
|
for (i = 0; i < create_info_host.queueCreateInfoCount; i++)
|
|
|
|
{
|
|
|
|
object->queue_count += create_info_host.pQueueCreateInfos[i].queueCount;
|
|
|
|
}
|
2018-03-14 13:11:52 +01:00
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
if (!(object->queues = calloc(object->queue_count, sizeof(*object->queues))))
|
2018-03-14 13:11:52 +01:00
|
|
|
{
|
2019-04-10 11:59:50 +02:00
|
|
|
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
goto fail;
|
2018-03-14 13:11:52 +01:00
|
|
|
}
|
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
next_queue = object->queues;
|
2018-03-23 14:46:14 +01:00
|
|
|
for (i = 0; i < create_info_host.queueCreateInfoCount; i++)
|
2018-03-14 13:11:52 +01:00
|
|
|
{
|
2018-07-16 15:18:19 +02:00
|
|
|
uint32_t flags = create_info_host.pQueueCreateInfos[i].flags;
|
2018-03-23 14:46:14 +01:00
|
|
|
uint32_t family_index = create_info_host.pQueueCreateInfos[i].queueFamilyIndex;
|
|
|
|
uint32_t queue_count = create_info_host.pQueueCreateInfos[i].queueCount;
|
2018-03-14 13:11:52 +01:00
|
|
|
|
2019-04-10 11:59:50 +02:00
|
|
|
TRACE("Queue family index %u, queue count %u.\n", family_index, queue_count);
|
2018-03-14 13:11:52 +01:00
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
wine_vk_device_get_queues(object, family_index, queue_count, flags, next_queue);
|
|
|
|
next_queue += queue_count;
|
2018-03-14 13:11:52 +01:00
|
|
|
}
|
|
|
|
|
2021-04-19 14:15:10 +02:00
|
|
|
object->base.quirks = phys_dev->instance->quirks;
|
2018-03-29 14:53:58 +02:00
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
*device = object;
|
2018-07-12 11:39:46 +02:00
|
|
|
TRACE("Created device %p (native device %p).\n", object, object->device);
|
2018-03-09 17:48:48 +01:00
|
|
|
return VK_SUCCESS;
|
2019-04-10 11:59:50 +02:00
|
|
|
|
|
|
|
fail:
|
|
|
|
wine_vk_device_free(object);
|
|
|
|
return res;
|
2018-03-09 17:48:48 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateInstance(void *args)
|
2018-02-26 19:42:14 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateInstance_params *params = args;
|
|
|
|
const VkInstanceCreateInfo *create_info = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkInstance *instance = params->pInstance;
|
2018-03-12 15:37:54 +01:00
|
|
|
VkInstanceCreateInfo create_info_host;
|
2018-03-29 14:53:58 +02:00
|
|
|
const VkApplicationInfo *app_info;
|
|
|
|
struct VkInstance_T *object;
|
2018-03-01 16:37:03 +01:00
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2018-03-01 16:37:03 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate memory for instance\n");
|
2018-03-29 14:53:57 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
2018-03-01 16:37:03 +01:00
|
|
|
}
|
|
|
|
object->base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
|
2020-10-13 19:28:36 +02:00
|
|
|
list_init(&object->wrappers);
|
2021-04-13 00:53:31 +02:00
|
|
|
pthread_rwlock_init(&object->wrapper_lock, NULL);
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2020-09-08 21:46:27 +02:00
|
|
|
res = wine_vk_instance_convert_create_info(create_info, &create_info_host, object);
|
2018-09-10 13:06:58 +02:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
wine_vk_instance_free(object);
|
|
|
|
return res;
|
|
|
|
}
|
2018-03-12 15:37:54 +01:00
|
|
|
|
|
|
|
res = vk_funcs->p_vkCreateInstance(&create_info_host, NULL /* allocator */, &object->instance);
|
2019-04-10 11:59:49 +02:00
|
|
|
free_VkInstanceCreateInfo_struct_chain(&create_info_host);
|
2018-03-01 16:37:03 +01:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to create instance, res=%d\n", res);
|
2018-03-29 14:53:57 +02:00
|
|
|
wine_vk_instance_free(object);
|
|
|
|
return res;
|
2018-03-01 16:37:03 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_ADD_DISPATCHABLE_MAPPING(object, object, object->instance);
|
|
|
|
|
2018-03-02 07:13:35 +01:00
|
|
|
/* Load all instance functions we are aware of. Note the loader takes care
|
|
|
|
* of any filtering for extensions which were not requested, but which the
|
|
|
|
* ICD may support.
|
|
|
|
*/
|
|
|
|
#define USE_VK_FUNC(name) \
|
2018-03-09 17:48:48 +01:00
|
|
|
object->funcs.p_##name = (void *)vk_funcs->p_vkGetInstanceProcAddr(object->instance, #name);
|
2018-03-02 07:13:35 +01:00
|
|
|
ALL_VK_INSTANCE_FUNCS()
|
|
|
|
#undef USE_VK_FUNC
|
|
|
|
|
2018-03-06 17:28:48 +01:00
|
|
|
/* Cache physical devices for vkEnumeratePhysicalDevices within the instance as
|
|
|
|
* each vkPhysicalDevice is a dispatchable object, which means we need to wrap
|
2018-03-29 14:53:57 +02:00
|
|
|
* the native physical devices and present those to the application.
|
2018-03-06 17:28:48 +01:00
|
|
|
* Cleanup happens as part of wine_vkDestroyInstance.
|
|
|
|
*/
|
|
|
|
res = wine_vk_instance_load_physical_devices(object);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2018-03-29 14:53:57 +02:00
|
|
|
ERR("Failed to load physical devices, res=%d\n", res);
|
|
|
|
wine_vk_instance_free(object);
|
|
|
|
return res;
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
|
|
|
|
2018-09-10 15:42:45 +02:00
|
|
|
if ((app_info = create_info->pApplicationInfo))
|
2018-03-29 14:53:58 +02:00
|
|
|
{
|
2018-09-10 15:42:45 +02:00
|
|
|
TRACE("Application name %s, application version %#x.\n",
|
|
|
|
debugstr_a(app_info->pApplicationName), app_info->applicationVersion);
|
|
|
|
TRACE("Engine name %s, engine version %#x.\n", debugstr_a(app_info->pEngineName),
|
|
|
|
app_info->engineVersion);
|
|
|
|
TRACE("API version %#x.\n", app_info->apiVersion);
|
|
|
|
|
2018-09-10 15:42:46 +02:00
|
|
|
if (app_info->pEngineName && !strcmp(app_info->pEngineName, "idTech"))
|
2018-03-29 14:53:58 +02:00
|
|
|
object->quirks |= WINEVULKAN_QUIRK_GET_DEVICE_PROC_ADDR;
|
|
|
|
}
|
|
|
|
|
2020-07-31 11:13:11 +02:00
|
|
|
object->quirks |= WINEVULKAN_QUIRK_ADJUST_MAX_IMAGE_COUNT;
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
*instance = object;
|
2018-07-12 11:39:46 +02:00
|
|
|
TRACE("Created instance %p (native instance %p).\n", object, object->instance);
|
2018-03-01 16:37:03 +01:00
|
|
|
return VK_SUCCESS;
|
2018-02-26 19:42:14 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroyDevice(void *args)
|
2018-03-09 17:48:50 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroyDevice_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
|
2018-03-09 17:48:50 +01:00
|
|
|
TRACE("%p %p\n", device, allocator);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
|
|
|
wine_vk_device_free(device);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-03-09 17:48:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroyInstance(void *args)
|
2018-03-01 16:37:05 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroyInstance_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
|
2018-03-01 16:37:05 +01:00
|
|
|
TRACE("%p, %p\n", instance, allocator);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support allocation allocators\n");
|
|
|
|
|
|
|
|
wine_vk_instance_free(instance);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-03-01 16:37:05 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumerateDeviceExtensionProperties(void *args)
|
2018-03-06 17:28:49 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumerateDeviceExtensionProperties_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const char *layer_name = params->pLayerName;
|
|
|
|
uint32_t *count = params->pPropertyCount;
|
|
|
|
VkExtensionProperties *properties = params->pProperties;
|
|
|
|
|
2018-03-06 17:28:49 +01:00
|
|
|
TRACE("%p, %p, %p, %p\n", phys_dev, layer_name, count, properties);
|
|
|
|
|
|
|
|
/* This shouldn't get called with layer_name set, the ICD loader prevents it. */
|
|
|
|
if (layer_name)
|
|
|
|
{
|
|
|
|
ERR("Layer enumeration not supported from ICD.\n");
|
|
|
|
return VK_ERROR_LAYER_NOT_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!properties)
|
|
|
|
{
|
2018-03-29 14:53:51 +02:00
|
|
|
*count = phys_dev->extension_count;
|
2018-03-06 17:28:49 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-03-29 14:53:51 +02:00
|
|
|
*count = min(*count, phys_dev->extension_count);
|
|
|
|
memcpy(properties, phys_dev->extensions, *count * sizeof(*properties));
|
2018-03-14 13:11:50 +01:00
|
|
|
|
2018-03-29 14:53:51 +02:00
|
|
|
TRACE("Returning %u extensions.\n", *count);
|
|
|
|
return *count < phys_dev->extension_count ? VK_INCOMPLETE : VK_SUCCESS;
|
2018-03-06 17:28:49 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumerateInstanceExtensionProperties(void *args)
|
2018-02-26 19:42:14 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumerateInstanceExtensionProperties_params *params = args;
|
|
|
|
uint32_t *count = params->pPropertyCount;
|
|
|
|
VkExtensionProperties *properties = params->pProperties;
|
2018-07-13 10:55:39 +02:00
|
|
|
uint32_t num_properties = 0, num_host_properties;
|
|
|
|
VkExtensionProperties *host_properties;
|
2018-03-15 07:39:37 +01:00
|
|
|
unsigned int i, j;
|
2018-07-13 10:55:39 +02:00
|
|
|
VkResult res;
|
2018-03-15 07:39:37 +01:00
|
|
|
|
|
|
|
res = vk_funcs->p_vkEnumerateInstanceExtensionProperties(NULL, &num_host_properties, NULL);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
return res;
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(host_properties = calloc(num_host_properties, sizeof(*host_properties))))
|
2018-03-15 07:39:37 +01:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
|
|
|
res = vk_funcs->p_vkEnumerateInstanceExtensionProperties(NULL, &num_host_properties, host_properties);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2018-07-13 10:55:39 +02:00
|
|
|
ERR("Failed to retrieve host properties, res=%d.\n", res);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_properties);
|
2018-03-15 07:39:37 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The Wine graphics driver provides us with all extensions supported by the host side
|
|
|
|
* including extension fixup (e.g. VK_KHR_xlib_surface -> VK_KHR_win32_surface). It is
|
|
|
|
* up to us here to filter the list down to extensions for which we have thunks.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < num_host_properties; i++)
|
|
|
|
{
|
|
|
|
if (wine_vk_instance_extension_supported(host_properties[i].extensionName))
|
|
|
|
num_properties++;
|
2018-05-18 12:49:18 +02:00
|
|
|
else
|
|
|
|
TRACE("Instance extension '%s' is not supported.\n", host_properties[i].extensionName);
|
2018-03-15 07:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!properties)
|
|
|
|
{
|
2018-07-13 10:55:39 +02:00
|
|
|
TRACE("Returning %u extensions.\n", num_properties);
|
2018-03-15 07:39:37 +01:00
|
|
|
*count = num_properties;
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_properties);
|
2018-03-15 07:39:37 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < num_host_properties && j < *count; i++)
|
|
|
|
{
|
|
|
|
if (wine_vk_instance_extension_supported(host_properties[i].extensionName))
|
|
|
|
{
|
2018-07-13 10:55:39 +02:00
|
|
|
TRACE("Enabling extension '%s'.\n", host_properties[i].extensionName);
|
|
|
|
properties[j++] = host_properties[i];
|
2018-03-15 07:39:37 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-16 16:30:41 +01:00
|
|
|
*count = min(*count, num_properties);
|
2018-03-15 07:39:37 +01:00
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_properties);
|
2018-03-16 16:30:41 +01:00
|
|
|
return *count < num_properties ? VK_INCOMPLETE : VK_SUCCESS;
|
2018-02-26 19:42:14 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumerateDeviceLayerProperties(void *args)
|
2021-03-22 05:17:33 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumerateDeviceLayerProperties_params *params = args;
|
|
|
|
uint32_t *count = params->pPropertyCount;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", params->physicalDevice, count, params->pProperties);
|
2021-03-22 05:17:33 +01:00
|
|
|
|
|
|
|
*count = 0;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumerateInstanceVersion(void *args)
|
2018-07-13 10:55:37 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumerateInstanceVersion_params *params = args;
|
|
|
|
uint32_t *version = params->pApiVersion;
|
2018-07-13 10:55:37 +02:00
|
|
|
VkResult res;
|
|
|
|
|
2021-12-09 03:14:01 +01:00
|
|
|
static VkResult (*p_vkEnumerateInstanceVersion)(uint32_t *version);
|
|
|
|
if (!p_vkEnumerateInstanceVersion)
|
|
|
|
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
|
|
|
|
|
2018-07-16 15:18:20 +02:00
|
|
|
if (p_vkEnumerateInstanceVersion)
|
|
|
|
{
|
|
|
|
res = p_vkEnumerateInstanceVersion(version);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*version = VK_API_VERSION_1_0;
|
|
|
|
res = VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-07-13 10:55:37 +02:00
|
|
|
TRACE("API version %u.%u.%u.\n",
|
|
|
|
VK_VERSION_MAJOR(*version), VK_VERSION_MINOR(*version), VK_VERSION_PATCH(*version));
|
|
|
|
*version = min(WINE_VK_VERSION, *version);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-01-26 11:21:14 +01:00
|
|
|
NTSTATUS wine_vkEnumeratePhysicalDevices(void *args)
|
2018-03-06 17:28:48 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumeratePhysicalDevices_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
uint32_t *count = params->pPhysicalDeviceCount;
|
|
|
|
VkPhysicalDevice *devices = params->pPhysicalDevices;
|
2018-03-15 10:26:33 +01:00
|
|
|
unsigned int i;
|
2018-03-06 17:28:48 +01:00
|
|
|
|
2018-03-15 10:26:33 +01:00
|
|
|
TRACE("%p %p %p\n", instance, count, devices);
|
2018-03-06 17:28:48 +01:00
|
|
|
|
|
|
|
if (!devices)
|
|
|
|
{
|
2018-07-12 11:39:43 +02:00
|
|
|
*count = instance->phys_dev_count;
|
2018-03-06 17:28:48 +01:00
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
*count = min(*count, instance->phys_dev_count);
|
2018-03-15 10:26:33 +01:00
|
|
|
for (i = 0; i < *count; i++)
|
2018-03-06 17:28:48 +01:00
|
|
|
{
|
|
|
|
devices[i] = instance->phys_devs[i];
|
|
|
|
}
|
|
|
|
|
2018-03-15 10:26:33 +01:00
|
|
|
TRACE("Returning %u devices.\n", *count);
|
2018-07-12 11:39:43 +02:00
|
|
|
return *count < instance->phys_dev_count ? VK_INCOMPLETE : VK_SUCCESS;
|
2018-03-06 17:28:48 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkFreeCommandBuffers(void *args)
|
2018-03-14 13:11:54 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkFreeCommandBuffers_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
struct wine_cmd_pool *pool = wine_cmd_pool_from_handle(params->commandPool);
|
|
|
|
uint32_t count = params->commandBufferCount;
|
|
|
|
const VkCommandBuffer *buffers = params->pCommandBuffers;
|
2018-03-14 13:11:54 +01:00
|
|
|
|
2021-12-10 18:40:42 +01:00
|
|
|
TRACE("%p, 0x%s, %u, %p\n", device, wine_dbgstr_longlong(params->commandPool), count, buffers);
|
2018-08-30 12:22:31 +02:00
|
|
|
|
|
|
|
wine_vk_free_command_buffers(device, pool, count, buffers);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-03-14 13:11:54 +01:00
|
|
|
}
|
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
static VkQueue wine_vk_device_find_queue(VkDevice device, const VkDeviceQueueInfo2 *info)
|
|
|
|
{
|
|
|
|
struct VkQueue_T* queue;
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < device->queue_count; i++)
|
|
|
|
{
|
|
|
|
queue = &device->queues[i];
|
|
|
|
if (queue->family_index == info->queueFamilyIndex
|
|
|
|
&& queue->queue_index == info->queueIndex
|
|
|
|
&& queue->flags == info->flags)
|
|
|
|
{
|
|
|
|
return queue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return VK_NULL_HANDLE;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetDeviceQueue(void *args)
|
2018-03-14 13:11:52 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetDeviceQueue_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
uint32_t family_index = params->queueFamilyIndex;
|
|
|
|
uint32_t queue_index = params->queueIndex;
|
|
|
|
VkQueue *queue = params->pQueue;
|
2021-04-14 00:31:25 +02:00
|
|
|
VkDeviceQueueInfo2 queue_info;
|
2021-12-10 18:40:42 +01:00
|
|
|
|
2018-07-16 15:18:19 +02:00
|
|
|
TRACE("%p, %u, %u, %p\n", device, family_index, queue_index, queue);
|
2018-03-14 13:11:52 +01:00
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2;
|
|
|
|
queue_info.pNext = NULL;
|
|
|
|
queue_info.flags = 0;
|
|
|
|
queue_info.queueFamilyIndex = family_index;
|
|
|
|
queue_info.queueIndex = queue_index;
|
|
|
|
|
|
|
|
*queue = wine_vk_device_find_queue(device, &queue_info);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-03-14 13:11:52 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetDeviceQueue2(void *args)
|
2018-07-16 15:18:19 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetDeviceQueue2_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
const VkDeviceQueueInfo2 *info = params->pQueueInfo;
|
|
|
|
VkQueue *queue = params->pQueue;
|
2019-03-01 08:43:13 +01:00
|
|
|
const VkBaseInStructure *chain;
|
2018-07-16 15:18:19 +02:00
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", device, info, queue);
|
|
|
|
|
|
|
|
if ((chain = info->pNext))
|
2019-03-20 13:11:38 +01:00
|
|
|
FIXME("Ignoring a linked structure of type %u.\n", chain->sType);
|
2018-07-16 15:18:19 +02:00
|
|
|
|
2021-04-14 00:31:25 +02:00
|
|
|
*queue = wine_vk_device_find_queue(device, info);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-07-16 15:18:19 +02:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateCommandPool(void *args)
|
2018-08-30 12:22:31 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateCommandPool_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
const VkCommandPoolCreateInfo *info = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkCommandPool *command_pool = params->pCommandPool;
|
2018-08-30 12:22:31 +02:00
|
|
|
struct wine_cmd_pool *object;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p, %p\n", device, info, allocator, command_pool);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2018-08-30 12:22:31 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
2018-08-30 12:22:32 +02:00
|
|
|
list_init(&object->command_buffers);
|
|
|
|
|
2018-08-30 12:22:31 +02:00
|
|
|
res = device->funcs.p_vkCreateCommandPool(device->device, info, NULL, &object->command_pool);
|
|
|
|
|
|
|
|
if (res == VK_SUCCESS)
|
2020-10-13 19:28:36 +02:00
|
|
|
{
|
|
|
|
WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(device->phys_dev->instance, object, object->command_pool);
|
2018-08-30 12:22:31 +02:00
|
|
|
*command_pool = wine_cmd_pool_to_handle(object);
|
2020-10-13 19:28:36 +02:00
|
|
|
}
|
2018-08-30 12:22:31 +02:00
|
|
|
else
|
2020-10-13 19:28:36 +02:00
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2020-10-13 19:28:36 +02:00
|
|
|
}
|
2018-08-30 12:22:31 +02:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroyCommandPool(void *args)
|
2018-08-30 12:22:31 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroyCommandPool_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
VkCommandPool handle = params->commandPool;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
2018-08-30 12:22:31 +02:00
|
|
|
struct wine_cmd_pool *pool = wine_cmd_pool_from_handle(handle);
|
2018-08-30 12:22:32 +02:00
|
|
|
struct VkCommandBuffer_T *buffer, *cursor;
|
2018-08-30 12:22:31 +02:00
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", device, wine_dbgstr_longlong(handle), allocator);
|
|
|
|
|
|
|
|
if (!handle)
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-08-30 12:22:31 +02:00
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2018-08-30 12:22:32 +02:00
|
|
|
/* The Vulkan spec says:
|
|
|
|
*
|
|
|
|
* "When a pool is destroyed, all command buffers allocated from the pool are freed."
|
|
|
|
*/
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(buffer, cursor, &pool->command_buffers, struct VkCommandBuffer_T, pool_link)
|
|
|
|
{
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, buffer);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(buffer);
|
2018-08-30 12:22:32 +02:00
|
|
|
}
|
|
|
|
|
2020-10-13 19:28:36 +02:00
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, pool);
|
|
|
|
|
2018-08-30 12:22:31 +02:00
|
|
|
device->funcs.p_vkDestroyCommandPool(device->device, pool->command_pool, NULL);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(pool);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2018-08-30 12:22:31 +02:00
|
|
|
}
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
static VkResult wine_vk_enumerate_physical_device_groups(struct VkInstance_T *instance,
|
|
|
|
VkResult (*p_vkEnumeratePhysicalDeviceGroups)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *),
|
|
|
|
uint32_t *count, VkPhysicalDeviceGroupProperties *properties)
|
|
|
|
{
|
|
|
|
unsigned int i, j;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
res = p_vkEnumeratePhysicalDeviceGroups(instance->instance, count, properties);
|
|
|
|
if (res < 0 || !properties)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
for (i = 0; i < *count; ++i)
|
|
|
|
{
|
|
|
|
VkPhysicalDeviceGroupProperties *current = &properties[i];
|
|
|
|
for (j = 0; j < current->physicalDeviceCount; ++j)
|
|
|
|
{
|
|
|
|
VkPhysicalDevice dev = current->physicalDevices[j];
|
|
|
|
if (!(current->physicalDevices[j] = wine_vk_instance_wrap_physical_device(instance, dev)))
|
|
|
|
return VK_ERROR_INITIALIZATION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumeratePhysicalDeviceGroups(void *args)
|
2018-07-12 11:39:43 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumeratePhysicalDeviceGroups_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
uint32_t *count = params->pPhysicalDeviceGroupCount;
|
|
|
|
VkPhysicalDeviceGroupProperties *properties = params->pPhysicalDeviceGroupProperties;
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
TRACE("%p, %p, %p\n", instance, count, properties);
|
|
|
|
return wine_vk_enumerate_physical_device_groups(instance,
|
|
|
|
instance->funcs.p_vkEnumeratePhysicalDeviceGroups, count, properties);
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkEnumeratePhysicalDeviceGroupsKHR(void *args)
|
2018-07-12 11:39:43 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkEnumeratePhysicalDeviceGroupsKHR_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
uint32_t *count = params->pPhysicalDeviceGroupCount;
|
|
|
|
VkPhysicalDeviceGroupProperties *properties = params->pPhysicalDeviceGroupProperties;
|
|
|
|
|
2018-07-12 11:39:43 +02:00
|
|
|
TRACE("%p, %p, %p\n", instance, count, properties);
|
|
|
|
return wine_vk_enumerate_physical_device_groups(instance,
|
|
|
|
instance->funcs.p_vkEnumeratePhysicalDeviceGroupsKHR, count, properties);
|
|
|
|
}
|
2018-03-15 07:39:34 +01:00
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalFenceProperties(void *args)
|
2019-03-20 13:11:33 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalFenceProperties_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalFenceInfo *fence_info = params->pExternalFenceInfo;
|
|
|
|
VkExternalFenceProperties *properties = params->pExternalFenceProperties;
|
|
|
|
|
2019-03-20 13:11:33 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, fence_info, properties);
|
|
|
|
properties->exportFromImportedHandleTypes = 0;
|
|
|
|
properties->compatibleHandleTypes = 0;
|
|
|
|
properties->externalFenceFeatures = 0;
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:33 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalFencePropertiesKHR(void *args)
|
2019-03-20 13:11:33 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalFencePropertiesKHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalFenceInfo *fence_info = params->pExternalFenceInfo;
|
|
|
|
VkExternalFenceProperties *properties = params->pExternalFenceProperties;
|
|
|
|
|
2019-03-20 13:11:33 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, fence_info, properties);
|
|
|
|
properties->exportFromImportedHandleTypes = 0;
|
|
|
|
properties->compatibleHandleTypes = 0;
|
|
|
|
properties->externalFenceFeatures = 0;
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:33 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalBufferProperties(void *args)
|
2019-03-20 13:11:34 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalBufferProperties_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalBufferInfo *buffer_info = params->pExternalBufferInfo;
|
|
|
|
VkExternalBufferProperties *properties = params->pExternalBufferProperties;
|
|
|
|
|
2019-03-20 13:11:34 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, buffer_info, properties);
|
|
|
|
memset(&properties->externalMemoryProperties, 0, sizeof(properties->externalMemoryProperties));
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:34 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalBufferPropertiesKHR(void *args)
|
2019-03-20 13:11:34 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalBufferPropertiesKHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalBufferInfo *buffer_info = params->pExternalBufferInfo;
|
|
|
|
VkExternalBufferProperties *properties = params->pExternalBufferProperties;
|
|
|
|
|
2019-03-20 13:11:34 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, buffer_info, properties);
|
|
|
|
memset(&properties->externalMemoryProperties, 0, sizeof(properties->externalMemoryProperties));
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:34 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceImageFormatProperties2(void *args)
|
2019-03-20 13:11:34 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceImageFormatProperties2_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceImageFormatInfo2 *format_info = params->pImageFormatInfo;
|
|
|
|
VkImageFormatProperties2 *properties = params->pImageFormatProperties;
|
2019-03-20 13:11:34 +01:00
|
|
|
VkExternalImageFormatProperties *external_image_properties;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", phys_dev, format_info, properties);
|
|
|
|
|
|
|
|
res = thunk_vkGetPhysicalDeviceImageFormatProperties2(phys_dev, format_info, properties);
|
|
|
|
|
|
|
|
if ((external_image_properties = wine_vk_find_struct(properties, EXTERNAL_IMAGE_FORMAT_PROPERTIES)))
|
|
|
|
{
|
|
|
|
VkExternalMemoryProperties *p = &external_image_properties->externalMemoryProperties;
|
|
|
|
p->externalMemoryFeatures = 0;
|
|
|
|
p->exportFromImportedHandleTypes = 0;
|
|
|
|
p->compatibleHandleTypes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceImageFormatProperties2KHR(void *args)
|
2019-03-20 13:11:34 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceImageFormatProperties2KHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceImageFormatInfo2 *format_info = params->pImageFormatInfo;
|
|
|
|
VkImageFormatProperties2 *properties = params->pImageFormatProperties;
|
2019-03-20 13:11:34 +01:00
|
|
|
VkExternalImageFormatProperties *external_image_properties;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", phys_dev, format_info, properties);
|
|
|
|
|
|
|
|
res = thunk_vkGetPhysicalDeviceImageFormatProperties2KHR(phys_dev, format_info, properties);
|
|
|
|
|
|
|
|
if ((external_image_properties = wine_vk_find_struct(properties, EXTERNAL_IMAGE_FORMAT_PROPERTIES)))
|
|
|
|
{
|
|
|
|
VkExternalMemoryProperties *p = &external_image_properties->externalMemoryProperties;
|
|
|
|
p->externalMemoryFeatures = 0;
|
|
|
|
p->exportFromImportedHandleTypes = 0;
|
|
|
|
p->compatibleHandleTypes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-07-19 09:35:44 +02:00
|
|
|
/* From ntdll/unix/sync.c */
|
|
|
|
#define NANOSECONDS_IN_A_SECOND 1000000000
|
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
|
|
|
|
static inline VkTimeDomainEXT get_performance_counter_time_domain(void)
|
|
|
|
{
|
|
|
|
#if !defined(__APPLE__) && defined(HAVE_CLOCK_GETTIME)
|
|
|
|
# ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
return VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT;
|
|
|
|
# else
|
|
|
|
return VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT;
|
|
|
|
# endif
|
|
|
|
#else
|
2021-03-02 20:18:44 +01:00
|
|
|
FIXME("No mapping for VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT on this platform.\n");
|
2020-07-19 09:35:44 +02:00
|
|
|
return VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static VkTimeDomainEXT map_to_host_time_domain(VkTimeDomainEXT domain)
|
|
|
|
{
|
|
|
|
/* Matches ntdll/unix/sync.c's performance counter implementation. */
|
|
|
|
if (domain == VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT)
|
|
|
|
return get_performance_counter_time_domain();
|
|
|
|
|
|
|
|
return domain;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t convert_monotonic_timestamp(uint64_t value)
|
|
|
|
{
|
|
|
|
return value / (NANOSECONDS_IN_A_SECOND / TICKSPERSEC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t convert_timestamp(VkTimeDomainEXT host_domain, VkTimeDomainEXT target_domain, uint64_t value)
|
|
|
|
{
|
|
|
|
if (host_domain == target_domain)
|
|
|
|
return value;
|
|
|
|
|
|
|
|
/* Convert between MONOTONIC time in ns -> QueryPerformanceCounter */
|
|
|
|
if ((host_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT || host_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT)
|
|
|
|
&& target_domain == VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT)
|
|
|
|
return convert_monotonic_timestamp(value);
|
|
|
|
|
2021-03-02 20:18:44 +01:00
|
|
|
FIXME("Couldn't translate between host domain %d and target domain %d\n", host_domain, target_domain);
|
2020-07-19 09:35:44 +02:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetCalibratedTimestampsEXT(void *args)
|
2020-07-19 09:35:44 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetCalibratedTimestampsEXT_params *params = args;
|
|
|
|
VkDevice device = params->device;
|
|
|
|
uint32_t timestamp_count = params->timestampCount;
|
|
|
|
const VkCalibratedTimestampInfoEXT *timestamp_infos = params->pTimestampInfos;
|
|
|
|
uint64_t *timestamps = params->pTimestamps;
|
|
|
|
uint64_t *max_deviation = params->pMaxDeviation;
|
2020-07-19 09:35:44 +02:00
|
|
|
VkCalibratedTimestampInfoEXT* host_timestamp_infos;
|
|
|
|
unsigned int i;
|
|
|
|
VkResult res;
|
|
|
|
TRACE("%p, %u, %p, %p, %p\n", device, timestamp_count, timestamp_infos, timestamps, max_deviation);
|
|
|
|
|
2021-04-16 15:49:00 +02:00
|
|
|
if (!(host_timestamp_infos = malloc(sizeof(VkCalibratedTimestampInfoEXT) * timestamp_count)))
|
2020-07-19 09:35:44 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
|
|
|
for (i = 0; i < timestamp_count; i++)
|
|
|
|
{
|
|
|
|
host_timestamp_infos[i].sType = timestamp_infos[i].sType;
|
|
|
|
host_timestamp_infos[i].pNext = timestamp_infos[i].pNext;
|
|
|
|
host_timestamp_infos[i].timeDomain = map_to_host_time_domain(timestamp_infos[i].timeDomain);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = device->funcs.p_vkGetCalibratedTimestampsEXT(device->device, timestamp_count, host_timestamp_infos, timestamps, max_deviation);
|
2020-08-03 18:28:51 +02:00
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
return res;
|
2020-07-19 09:35:44 +02:00
|
|
|
|
|
|
|
for (i = 0; i < timestamp_count; i++)
|
|
|
|
timestamps[i] = convert_timestamp(host_timestamp_infos[i].timeDomain, timestamp_infos[i].timeDomain, timestamps[i]);
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_timestamp_infos);
|
2020-07-19 09:35:44 +02:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-01-26 11:21:14 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(void *args)
|
2020-07-19 09:35:44 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceCalibrateableTimeDomainsEXT_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
uint32_t *time_domain_count = params->pTimeDomainCount;
|
|
|
|
VkTimeDomainEXT *time_domains = params->pTimeDomains;
|
2020-07-19 09:35:44 +02:00
|
|
|
BOOL supports_device = FALSE, supports_monotonic = FALSE, supports_monotonic_raw = FALSE;
|
|
|
|
const VkTimeDomainEXT performance_counter_domain = get_performance_counter_time_domain();
|
|
|
|
VkTimeDomainEXT *host_time_domains;
|
|
|
|
uint32_t host_time_domain_count;
|
|
|
|
VkTimeDomainEXT out_time_domains[2];
|
|
|
|
uint32_t out_time_domain_count;
|
|
|
|
unsigned int i;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", phys_dev, time_domain_count, time_domains);
|
|
|
|
|
|
|
|
/* Find out the time domains supported on the host */
|
|
|
|
res = phys_dev->instance->funcs.p_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(phys_dev->phys_dev, &host_time_domain_count, NULL);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
return res;
|
|
|
|
|
2021-04-16 15:49:00 +02:00
|
|
|
if (!(host_time_domains = malloc(sizeof(VkTimeDomainEXT) * host_time_domain_count)))
|
2020-07-19 09:35:44 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
|
|
|
res = phys_dev->instance->funcs.p_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(phys_dev->phys_dev, &host_time_domain_count, host_time_domains);
|
|
|
|
if (res != VK_SUCCESS)
|
2020-08-03 18:28:51 +02:00
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_time_domains);
|
2020-07-19 09:35:44 +02:00
|
|
|
return res;
|
2020-08-03 18:28:51 +02:00
|
|
|
}
|
2020-07-19 09:35:44 +02:00
|
|
|
|
|
|
|
for (i = 0; i < host_time_domain_count; i++)
|
|
|
|
{
|
|
|
|
if (host_time_domains[i] == VK_TIME_DOMAIN_DEVICE_EXT)
|
|
|
|
supports_device = TRUE;
|
|
|
|
else if (host_time_domains[i] == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT)
|
|
|
|
supports_monotonic = TRUE;
|
|
|
|
else if (host_time_domains[i] == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT)
|
|
|
|
supports_monotonic_raw = TRUE;
|
|
|
|
else
|
2021-03-02 20:18:44 +01:00
|
|
|
FIXME("Unknown time domain %d\n", host_time_domains[i]);
|
2020-07-19 09:35:44 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(host_time_domains);
|
2020-07-19 09:35:44 +02:00
|
|
|
|
|
|
|
out_time_domain_count = 0;
|
|
|
|
|
|
|
|
/* Map our monotonic times -> QPC */
|
|
|
|
if (supports_monotonic_raw && performance_counter_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT)
|
|
|
|
out_time_domains[out_time_domain_count++] = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT;
|
|
|
|
else if (supports_monotonic && performance_counter_domain == VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT)
|
|
|
|
out_time_domains[out_time_domain_count++] = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT;
|
|
|
|
else
|
2021-03-02 20:18:44 +01:00
|
|
|
FIXME("VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT not supported on this platform.\n");
|
2020-07-19 09:35:44 +02:00
|
|
|
|
|
|
|
/* Forward the device domain time */
|
|
|
|
if (supports_device)
|
|
|
|
out_time_domains[out_time_domain_count++] = VK_TIME_DOMAIN_DEVICE_EXT;
|
|
|
|
|
|
|
|
/* Send the count/domains back to the app */
|
|
|
|
if (!time_domains)
|
|
|
|
{
|
|
|
|
*time_domain_count = out_time_domain_count;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < min(*time_domain_count, out_time_domain_count); i++)
|
|
|
|
time_domains[i] = out_time_domains[i];
|
|
|
|
|
|
|
|
res = *time_domain_count < out_time_domain_count ? VK_INCOMPLETE : VK_SUCCESS;
|
|
|
|
*time_domain_count = out_time_domain_count;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalSemaphoreProperties(void *args)
|
2019-03-20 13:11:35 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalSemaphoreProperties_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalSemaphoreInfo *semaphore_info = params->pExternalSemaphoreInfo;
|
|
|
|
VkExternalSemaphoreProperties *properties = params->pExternalSemaphoreProperties;
|
|
|
|
|
2019-03-20 13:11:35 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, semaphore_info, properties);
|
|
|
|
properties->exportFromImportedHandleTypes = 0;
|
|
|
|
properties->compatibleHandleTypes = 0;
|
|
|
|
properties->externalSemaphoreFeatures = 0;
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:35 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(void *args)
|
2019-03-20 13:11:35 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceExternalSemaphorePropertiesKHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceExternalSemaphoreInfo *semaphore_info = params->pExternalSemaphoreInfo;
|
|
|
|
VkExternalSemaphoreProperties *properties = params->pExternalSemaphoreProperties;
|
|
|
|
|
2019-03-20 13:11:35 +01:00
|
|
|
TRACE("%p, %p, %p\n", phys_dev, semaphore_info, properties);
|
|
|
|
properties->exportFromImportedHandleTypes = 0;
|
|
|
|
properties->compatibleHandleTypes = 0;
|
|
|
|
properties->externalSemaphoreFeatures = 0;
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2019-03-20 13:11:35 +01:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateWin32SurfaceKHR(void *args)
|
2021-01-22 18:31:56 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateWin32SurfaceKHR_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
const VkWin32SurfaceCreateInfoKHR *createInfo = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkSurfaceKHR *surface = params->pSurface;
|
2021-01-22 18:31:56 +01:00
|
|
|
struct wine_surface *object;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p, %p\n", instance, createInfo, allocator, surface);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
object = calloc(1, sizeof(*object));
|
2021-01-22 18:31:56 +01:00
|
|
|
|
|
|
|
if (!object)
|
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
2021-01-26 13:32:24 +01:00
|
|
|
res = instance->funcs.p_vkCreateWin32SurfaceKHR(instance->instance, createInfo, NULL, &object->driver_surface);
|
2021-01-22 18:31:56 +01:00
|
|
|
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2021-01-22 18:31:56 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-01-26 13:32:24 +01:00
|
|
|
object->surface = vk_funcs->p_wine_get_native_surface(object->driver_surface);
|
|
|
|
|
|
|
|
WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->surface);
|
|
|
|
|
|
|
|
*surface = wine_surface_to_handle(object);
|
2021-01-22 18:31:56 +01:00
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroySurfaceKHR(void *args)
|
2021-01-22 18:31:56 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroySurfaceKHR_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
VkSurfaceKHR surface = params->surface;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
2021-01-22 18:31:56 +01:00
|
|
|
struct wine_surface *object = wine_surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", instance, wine_dbgstr_longlong(surface), allocator);
|
|
|
|
|
|
|
|
if (!object)
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2021-01-22 18:31:56 +01:00
|
|
|
|
2021-01-26 13:32:24 +01:00
|
|
|
instance->funcs.p_vkDestroySurfaceKHR(instance->instance, object->driver_surface, NULL);
|
2021-01-22 18:31:56 +01:00
|
|
|
|
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(instance, object);
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2021-01-22 18:31:56 +01:00
|
|
|
}
|
|
|
|
|
2020-07-31 11:13:11 +02:00
|
|
|
static inline void adjust_max_image_count(VkPhysicalDevice phys_dev, VkSurfaceCapabilitiesKHR* capabilities)
|
|
|
|
{
|
|
|
|
/* Many Windows games, for example Strange Brigade, No Man's Sky, Path of Exile
|
|
|
|
* and World War Z, do not expect that maxImageCount can be set to 0.
|
|
|
|
* A value of 0 means that there is no limit on the number of images.
|
|
|
|
* Nvidia reports 8 on Windows, AMD 16.
|
|
|
|
* https://vulkan.gpuinfo.org/displayreport.php?id=9122#surface
|
|
|
|
* https://vulkan.gpuinfo.org/displayreport.php?id=9121#surface
|
|
|
|
*/
|
|
|
|
if ((phys_dev->instance->quirks & WINEVULKAN_QUIRK_ADJUST_MAX_IMAGE_COUNT) && !capabilities->maxImageCount)
|
|
|
|
{
|
|
|
|
capabilities->maxImageCount = max(capabilities->minImageCount, 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(void *args)
|
2020-07-31 11:13:11 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceSurfaceCapabilitiesKHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
VkSurfaceKHR surface = params->surface;
|
|
|
|
VkSurfaceCapabilitiesKHR *capabilities = params->pSurfaceCapabilities;
|
2020-07-31 11:13:11 +02:00
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", phys_dev, wine_dbgstr_longlong(surface), capabilities);
|
|
|
|
|
|
|
|
res = thunk_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, surface, capabilities);
|
|
|
|
|
|
|
|
if (res == VK_SUCCESS)
|
|
|
|
adjust_max_image_count(phys_dev, capabilities);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(void *args)
|
2020-07-31 11:13:11 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkGetPhysicalDeviceSurfaceCapabilities2KHR_params *params = args;
|
|
|
|
VkPhysicalDevice phys_dev = params->physicalDevice;
|
|
|
|
const VkPhysicalDeviceSurfaceInfo2KHR *surface_info = params->pSurfaceInfo;
|
|
|
|
VkSurfaceCapabilities2KHR *capabilities = params->pSurfaceCapabilities;
|
2020-07-31 11:13:11 +02:00
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", phys_dev, surface_info, capabilities);
|
|
|
|
|
2021-05-13 18:18:44 +02:00
|
|
|
res = thunk_vkGetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev, surface_info, capabilities);
|
2020-07-31 11:13:11 +02:00
|
|
|
|
|
|
|
if (res == VK_SUCCESS)
|
|
|
|
adjust_max_image_count(phys_dev, &capabilities->surfaceCapabilities);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateDebugUtilsMessengerEXT(void *args)
|
2020-10-13 19:28:37 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateDebugUtilsMessengerEXT_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
const VkDebugUtilsMessengerCreateInfoEXT *create_info = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkDebugUtilsMessengerEXT *messenger = params->pMessenger;
|
2020-10-13 19:28:37 +02:00
|
|
|
VkDebugUtilsMessengerCreateInfoEXT wine_create_info;
|
|
|
|
struct wine_debug_utils_messenger *object;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p, %p\n", instance, create_info, allocator, messenger);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2020-10-13 19:28:37 +02:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
|
|
|
object->instance = instance;
|
|
|
|
object->user_callback = create_info->pfnUserCallback;
|
|
|
|
object->user_data = create_info->pUserData;
|
|
|
|
|
|
|
|
wine_create_info = *create_info;
|
|
|
|
|
|
|
|
wine_create_info.pfnUserCallback = (void *) &debug_utils_callback_conversion;
|
|
|
|
wine_create_info.pUserData = object;
|
|
|
|
|
|
|
|
res = instance->funcs.p_vkCreateDebugUtilsMessengerEXT(instance->instance, &wine_create_info, NULL, &object->debug_messenger);
|
|
|
|
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2020-10-13 19:28:37 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_messenger);
|
|
|
|
*messenger = wine_debug_utils_messenger_to_handle(object);
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroyDebugUtilsMessengerEXT(void *args)
|
2020-10-13 19:28:37 +02:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroyDebugUtilsMessengerEXT_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
VkDebugUtilsMessengerEXT messenger = params->messenger;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
2020-10-13 19:28:37 +02:00
|
|
|
struct wine_debug_utils_messenger *object;
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", instance, wine_dbgstr_longlong(messenger), allocator);
|
|
|
|
|
|
|
|
object = wine_debug_utils_messenger_from_handle(messenger);
|
|
|
|
|
2021-02-03 21:13:34 +01:00
|
|
|
if (!object)
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2021-02-03 21:13:34 +01:00
|
|
|
|
2020-10-13 19:28:37 +02:00
|
|
|
instance->funcs.p_vkDestroyDebugUtilsMessengerEXT(instance->instance, object->debug_messenger, NULL);
|
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(instance, object);
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2020-10-13 19:28:37 +02:00
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkCreateDebugReportCallbackEXT(void *args)
|
2020-10-27 21:18:54 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkCreateDebugReportCallbackEXT_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
const VkDebugReportCallbackCreateInfoEXT *create_info = params->pCreateInfo;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
|
|
|
VkDebugReportCallbackEXT *callback = params->pCallback;
|
2020-10-27 21:18:54 +01:00
|
|
|
VkDebugReportCallbackCreateInfoEXT wine_create_info;
|
|
|
|
struct wine_debug_report_callback *object;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p, %p\n", instance, create_info, allocator, callback);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2020-10-27 21:18:54 +01:00
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
|
|
|
object->instance = instance;
|
|
|
|
object->user_callback = create_info->pfnCallback;
|
|
|
|
object->user_data = create_info->pUserData;
|
|
|
|
|
|
|
|
wine_create_info = *create_info;
|
|
|
|
|
|
|
|
wine_create_info.pfnCallback = (void *) debug_report_callback_conversion;
|
|
|
|
wine_create_info.pUserData = object;
|
|
|
|
|
|
|
|
res = instance->funcs.p_vkCreateDebugReportCallbackEXT(instance->instance, &wine_create_info, NULL, &object->debug_callback);
|
|
|
|
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2020-10-27 21:18:54 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_callback);
|
|
|
|
*callback = wine_debug_report_callback_to_handle(object);
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:41:08 +01:00
|
|
|
NTSTATUS wine_vkDestroyDebugReportCallbackEXT(void *args)
|
2020-10-27 21:18:54 +01:00
|
|
|
{
|
2021-12-10 18:40:42 +01:00
|
|
|
struct vkDestroyDebugReportCallbackEXT_params *params = args;
|
|
|
|
VkInstance instance = params->instance;
|
|
|
|
VkDebugReportCallbackEXT callback = params->callback;
|
|
|
|
const VkAllocationCallbacks *allocator = params->pAllocator;
|
2020-10-27 21:18:54 +01:00
|
|
|
struct wine_debug_report_callback *object;
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", instance, wine_dbgstr_longlong(callback), allocator);
|
|
|
|
|
|
|
|
object = wine_debug_report_callback_from_handle(callback);
|
|
|
|
|
2021-02-03 21:13:35 +01:00
|
|
|
if (!object)
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2021-02-03 21:13:35 +01:00
|
|
|
|
2020-10-27 21:18:54 +01:00
|
|
|
instance->funcs.p_vkDestroyDebugReportCallbackEXT(instance->instance, object->debug_callback, NULL);
|
|
|
|
|
|
|
|
WINE_VK_REMOVE_HANDLE_MAPPING(instance, object);
|
|
|
|
|
2021-04-13 00:53:17 +02:00
|
|
|
free(object);
|
2021-12-10 18:40:42 +01:00
|
|
|
return STATUS_SUCCESS;
|
2020-10-27 21:18:54 +01:00
|
|
|
}
|
2021-08-20 13:24:49 +02:00
|
|
|
|
|
|
|
BOOL WINAPI wine_vk_is_available_instance_function(VkInstance instance, const char *name)
|
|
|
|
{
|
|
|
|
return !!vk_funcs->p_vkGetInstanceProcAddr(instance->instance, name);
|
|
|
|
}
|
2021-08-20 13:24:50 +02:00
|
|
|
|
|
|
|
BOOL WINAPI wine_vk_is_available_device_function(VkDevice device, const char *name)
|
|
|
|
{
|
|
|
|
return !!vk_funcs->p_vkGetDeviceProcAddr(device->device, name);
|
|
|
|
}
|