dlls/winevulkan/vulkan.c
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
        VkInstanceCreateInfo *dst, struct VkInstance_T *object)
{
    VkDebugUtilsMessengerCreateInfoEXT *debug_utils_messenger;
    VkDebugReportCallbackCreateInfoEXT *debug_report_callback;
    VkBaseInStructure *header;
    unsigned int i;
    VkResult res;

    *dst = *src;

    if ((res = convert_VkInstanceCreateInfo_struct_chain(src->pNext, dst)) < 0)
    {
        WARN("Failed to convert VkInstanceCreateInfo pNext chain, res=%d.\n", res);
        return res;
    }

    object->utils_messenger_count = wine_vk_count_struct(dst, DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT);
    object->utils_messengers =  calloc(object->utils_messenger_count, sizeof(*object->utils_messengers));
    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];
    }

    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;
    }

    /* ICDs don't support any layers, so nothing to copy. Modern versions of the loader
     * filter this data out as well.
     */
    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;
    }

    TRACE("Enabled %u instance extensions.\n", dst->enabledExtensionCount);
    for (i = 0; i < dst->enabledExtensionCount; i++)
    {
        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));
            free_VkInstanceCreateInfo_struct_chain(dst);
            return VK_ERROR_EXTENSION_NOT_PRESENT;
        }
        if (!strcmp(extension_name, "VK_EXT_debug_utils") || !strcmp(extension_name, "VK_EXT_debug_report"))
        {
            object->enable_wrapper_list = VK_TRUE;
        }
    }

    return VK_SUCCESS;
}
/* 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.
 */
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.
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 .
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
        VkInstanceCreateInfo *dst, struct VkInstance_T *object)
{
    VkDebugUtilsMessengerCreateInfoEXT *debug_utils_messenger;
    VkDebugReportCallbackCreateInfoEXT *debug_report_callback;
    VkBaseInStructure *header;
    unsigned int i;
    VkResult res;
    *dst = *src;
    if ((res = convert_VkInstanceCreateInfo_struct_chain(src->pNext, dst)) < 0)
    {
        WARN("Failed to convert VkInstanceCreateInfo pNext chain, res=%d.\n", res);
        return res;
    }
    object->utils_messenger_count = wine_vk_count_struct(dst, DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT);
    object->utils_messengers =  calloc(object->utils_messenger_count, sizeof(*object->utils_messengers));
    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;
        debug_utils_messenger->pfnUserCallback = (void *) &debug_utils_callback_conversion;
        debug_utils_messenger->pUserData = &object->utils_messengers[i];
    }
    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;
    }
    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;
    }
    TRACE("Enabled %u instance extensions.\n", dst->enabledExtensionCount);
    for (i = 0; i < dst->enabledExtensionCount; i++)
    {
        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));
            free_VkInstanceCreateInfo_struct_chain(dst);
            return VK_ERROR_EXTENSION_NOT_PRESENT;
        }
        if (!strcmp(extension_name, "VK_EXT_debug_utils") || !strcmp(extension_name, "VK_EXT_debug_report"))
        {
            object->enable_wrapper_list = VK_TRUE;
        }
    }
    return VK_SUCCESS;
}
static VkResult wine_vk_instance_convert_create_info ( const VkInstanceCreateInfo * src , VkInstanceCreateInfo * dst , struct VkInstance_T * object ) { VkDebugUtilsMessengerCreateInfoEXT * debug_utils_messenger ; VkDebugReportCallbackCreateInfoEXT * debug_report_callback ; VkBaseInStructure * header ; unsigned int i ; VkResult res ; * dst = * src ; if ( ( res = convert_VkInstanceCreateInfo_struct_chain ( src -> pNext , dst ) ) < 0 ) { WARN ( " \n " , res ) ; return res ; } object -> utils_messenger_count = wine_vk_count_struct ( dst , DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT ) ; object -> utils_messengers = calloc ( object -> utils_messenger_count , sizeof ( * object -> utils_messengers ) ) ; 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 ; debug_utils_messenger -> pfnUserCallback = ( void * ) & debug_utils_callback_conversion ; debug_utils_messenger -> pUserData = & object -> utils_messengers [ i ] ; } 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 ; } if ( object -> quirks & WINEVULKAN_QUIRK_IGNORE_EXPLICIT_LAYERS ) { dst -> enabledLayerCount = 0 ; dst -> ppEnabledLayerNames = NULL ; WARN ( " \n " ) ; } else if ( dst -> enabledLayerCount ) { FIXME ( " \n " ) ; return VK_ERROR_LAYER_NOT_PRESENT ; } TRACE ( " \n " , dst -> enabledExtensionCount ) ; for ( i = 0 ; i < dst -> enabledExtensionCount ; i ++ ) { const char * extension_name = dst -> ppEnabledExtensionNames [ i ] ; TRACE ( " \n " , i , debugstr_a ( extension_name ) ) ; if ( ! wine_vk_instance_extension_supported ( extension_name ) ) { WARN ( " \n " , debugstr_a ( extension_name ) ) ; free_VkInstanceCreateInfo_struct_chain ( dst ) ; return VK_ERROR_EXTENSION_NOT_PRESENT ; } if ( ! strcmp ( extension_name , " " ) || ! strcmp ( extension_name , " " ) ) { object -> enable_wrapper_list = VK_TRUE ; } } return VK_SUCCESS ; }
Helper function for converting between win32 and host compatible VkInstanceCreateInfo.
Helper function for converting between win32 and host compatible VkInstanceCreateInfo .
/* convert_VkInstanceCreateInfo_struct_chain already copied the chain,
         * so we can modify it in-place.
         */ /* ICDs don't support any layers, so nothing to copy. Modern versions of the loader
     * filter this data out as well.
     */