From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 9c17a3b8f3a..9bad509c5ef 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -374,8 +374,8 @@ static void wine_vk_device_get_queues(struct wine_device *device, } }
-static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_dev, - struct conversion_context *ctx, const VkDeviceCreateInfo *src, VkDeviceCreateInfo *dst) +static VkResult convert_device_create_info(struct wine_phys_dev *phys_dev, const VkDeviceCreateInfo *src, + VkDeviceCreateInfo *dst, void **host_extensions) { unsigned int i;
@@ -401,10 +401,11 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de { const char **new_extensions;
- new_extensions = conversion_context_alloc(ctx, (dst->enabledExtensionCount + 2) * - sizeof(*dst->ppEnabledExtensionNames)); - memcpy(new_extensions, src->ppEnabledExtensionNames, - dst->enabledExtensionCount * sizeof(*dst->ppEnabledExtensionNames)); + if (!(new_extensions = malloc((dst->enabledExtensionCount + 2) * sizeof(*new_extensions)))) + return VK_ERROR_OUT_OF_HOST_MEMORY; + *host_extensions = new_extensions; + + memcpy(new_extensions, dst->ppEnabledExtensionNames, dst->enabledExtensionCount * sizeof(*new_extensions)); new_extensions[dst->enabledExtensionCount++] = "VK_KHR_external_memory"; new_extensions[dst->enabledExtensionCount++] = "VK_EXT_external_memory_host"; dst->ppEnabledExtensionNames = new_extensions; @@ -777,7 +778,7 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice phys_dev_handle, const VkDeviceCre VkDeviceCreateInfo create_info_host; struct VkQueue_T *queue_handles; struct wine_queue *next_queue; - struct conversion_context ctx; + void *host_extensions = NULL; struct wine_device *object; unsigned int i; VkResult res; @@ -801,19 +802,22 @@ VkResult wine_vkCreateDevice(VkPhysicalDevice phys_dev_handle, const VkDeviceCre
object->phys_dev = phys_dev;
- init_conversion_context(&ctx); - res = wine_vk_device_convert_create_info(phys_dev, &ctx, create_info, &create_info_host); - if (res == VK_SUCCESS) - res = phys_dev->instance->funcs.p_vkCreateDevice(phys_dev->phys_dev, - &create_info_host, NULL /* allocator */, &object->device); - free_conversion_context(&ctx); - WINE_VK_ADD_DISPATCHABLE_MAPPING(phys_dev->instance, device_handle, object->device, object); + if ((res = convert_device_create_info(phys_dev, create_info, &create_info_host, &host_extensions)) == VK_SUCCESS) + { + res = phys_dev->instance->funcs.p_vkCreateDevice(phys_dev->phys_dev, &create_info_host, + NULL /* allocator */, &object->device); + free(host_extensions); + } + if (res != VK_SUCCESS) { WARN("Failed to create device, res=%d.\n", res); - goto fail; + free(object); + return res; }
+ WINE_VK_ADD_DISPATCHABLE_MAPPING(phys_dev->instance, device_handle, object->device, object); + /* 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.