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

winevulkan: Refactor extra extensions handling in wine_vk_device_convert_create_info.

parent 64914849
...@@ -391,10 +391,21 @@ static void wine_vk_device_get_queues(struct wine_device *device, ...@@ -391,10 +391,21 @@ static void wine_vk_device_get_queues(struct wine_device *device,
} }
} }
static const char *find_extension(const char *const *extensions, uint32_t count, const char *ext)
{
while (count--)
{
if (!strcmp(extensions[count], ext))
return extensions[count];
}
return NULL;
}
static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_dev, static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_dev,
struct conversion_context *ctx, const VkDeviceCreateInfo *src, VkDeviceCreateInfo *dst) struct conversion_context *ctx, const VkDeviceCreateInfo *src, VkDeviceCreateInfo *dst)
{ {
unsigned int i; const char *extra_extensions[2], * const*extensions = src->ppEnabledExtensionNames;
unsigned int i, extra_count = 0, extensions_count = src->enabledExtensionCount;
*dst = *src; *dst = *src;
...@@ -402,10 +413,10 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de ...@@ -402,10 +413,10 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de
dst->enabledLayerCount = 0; dst->enabledLayerCount = 0;
dst->ppEnabledLayerNames = NULL; dst->ppEnabledLayerNames = NULL;
TRACE("Enabled %u extensions.\n", dst->enabledExtensionCount); TRACE("Enabled %u extensions.\n", extensions_count);
for (i = 0; i < dst->enabledExtensionCount; i++) for (i = 0; i < extensions_count; i++)
{ {
const char *extension_name = dst->ppEnabledExtensionNames[i]; const char *extension_name = extensions[i];
TRACE("Extension %u: %s.\n", i, debugstr_a(extension_name)); TRACE("Extension %u: %s.\n", i, debugstr_a(extension_name));
if (!wine_vk_device_extension_supported(extension_name)) if (!wine_vk_device_extension_supported(extension_name))
{ {
...@@ -416,14 +427,20 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de ...@@ -416,14 +427,20 @@ static VkResult wine_vk_device_convert_create_info(struct wine_phys_dev *phys_de
if (phys_dev->external_memory_align) if (phys_dev->external_memory_align)
{ {
if (!find_extension(extensions, extensions_count, "VK_KHR_external_memory"))
extra_extensions[extra_count++] = "VK_KHR_external_memory";
if (!find_extension(extensions, extensions_count, "VK_EXT_external_memory_host"))
extra_extensions[extra_count++] = "VK_EXT_external_memory_host";
}
if (extra_count)
{
const char **new_extensions; const char **new_extensions;
new_extensions = conversion_context_alloc(ctx, (dst->enabledExtensionCount + 2) * dst->enabledExtensionCount += extra_count;
sizeof(*dst->ppEnabledExtensionNames)); new_extensions = conversion_context_alloc(ctx, dst->enabledExtensionCount * sizeof(*new_extensions));
memcpy(new_extensions, src->ppEnabledExtensionNames, memcpy(new_extensions, extensions, extensions_count * sizeof(*new_extensions));
dst->enabledExtensionCount * sizeof(*dst->ppEnabledExtensionNames)); memcpy(new_extensions + extensions_count, extra_extensions, extra_count * sizeof(*new_extensions));
new_extensions[dst->enabledExtensionCount++] = "VK_KHR_external_memory";
new_extensions[dst->enabledExtensionCount++] = "VK_EXT_external_memory_host";
dst->ppEnabledExtensionNames = new_extensions; dst->ppEnabledExtensionNames = new_extensions;
} }
......
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