From 68f1cbde366dae693a6ab1c9f2207986b1908176 Mon Sep 17 00:00:00 2001 From: Lenny Komow Date: Mon, 2 Oct 2017 15:08:53 -0600 Subject: loader: Update loader for Vulkan 1.1 --- loader/loader.aps | Bin 0 -> 1920 bytes loader/loader.c | 249 ++++++++++++++++++++++++++++++++++++++-------------- loader/trampoline.c | 183 +++++++++++++++++++++++--------------- loader/vulkan-1.def | 28 ++++++ loader/wsi.c | 46 +++++++++- 5 files changed, 368 insertions(+), 138 deletions(-) create mode 100644 loader/loader.aps diff --git a/loader/loader.aps b/loader/loader.aps new file mode 100644 index 00000000..1ba7f211 Binary files /dev/null and b/loader/loader.aps differ diff --git a/loader/loader.c b/loader/loader.c index 570b9971..96c4c5d0 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -4705,11 +4705,11 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p // need to look for the corresponding VkDeviceGroupDeviceCreateInfoKHR struct in the device list. This is because we // need to replace all the incoming physical device values (which are really loader trampoline physical device values) // with the layer/ICD version. - if (inst->enabled_known_extensions.khr_device_group_creation == 1) { + { struct VkStructureHeader *pNext = (struct VkStructureHeader *)loader_create_info.pNext; struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&loader_create_info; while (NULL != pNext) { - if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR == pNext->sType) { + if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO == pNext->sType) { VkDeviceGroupDeviceCreateInfoKHR *cur_struct = (VkDeviceGroupDeviceCreateInfoKHR *)pNext; if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { VkDeviceGroupDeviceCreateInfoKHR *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHR)); @@ -5136,6 +5136,18 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateI loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&icd_exts); + // Create an instance, substituting the version to 1.0 if necessary + uint32_t requested_version = pCreateInfo == NULL ? VK_API_VERSION_1_0 : pCreateInfo->pApplicationInfo->apiVersion; + if (requested_version > icd_term->scanned_icd->api_version) { + VkApplicationInfo icd_app_info; + if (icd_create_info.pApplicationInfo == NULL) { + memset(&icd_app_info, 0, sizeof(icd_app_info)); + } else { + memcpy(&icd_app_info, icd_create_info.pApplicationInfo, sizeof(icd_app_info)); + } + icd_app_info.apiVersion = icd_term->scanned_icd->api_version; + icd_create_info.pApplicationInfo = &icd_app_info; + } VkResult icd_result = ptr_instance->icd_tramp_list.scanned_list[i].CreateInstance(&icd_create_info, pAllocator, &(icd_term->instance)); if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_result) { @@ -5322,21 +5334,22 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical } // Before we continue, If KHX_device_group is the list of enabled and viable extensions, then we then need to look for the - // corresponding VkDeviceGroupDeviceCreateInfoKHR struct in the device list and replace all the physical device values (which + // corresponding VkDeviceGroupDeviceCreateInfo struct in the device list and replace all the physical device values (which // are really loader physical device terminator values) with the ICD versions. - if (icd_term->this_instance->enabled_known_extensions.khr_device_group_creation == 1) { + //if (icd_term->this_instance->enabled_known_extensions.khr_device_group_creation == 1) { + { struct VkStructureHeader *pNext = (struct VkStructureHeader *)localCreateInfo.pNext; struct VkStructureHeader *pPrev = (struct VkStructureHeader *)&localCreateInfo; while (NULL != pNext) { - if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR == pNext->sType) { - VkDeviceGroupDeviceCreateInfoKHR *cur_struct = (VkDeviceGroupDeviceCreateInfoKHR *)pNext; + if (VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO == pNext->sType) { + VkDeviceGroupDeviceCreateInfo *cur_struct = (VkDeviceGroupDeviceCreateInfo *)pNext; if (0 < cur_struct->physicalDeviceCount && NULL != cur_struct->pPhysicalDevices) { - VkDeviceGroupDeviceCreateInfoKHR *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfoKHR)); + VkDeviceGroupDeviceCreateInfo *temp_struct = loader_stack_alloc(sizeof(VkDeviceGroupDeviceCreateInfo)); VkPhysicalDevice *phys_dev_array = NULL; if (NULL == temp_struct) { return VK_ERROR_OUT_OF_HOST_MEMORY; } - memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfoKHR)); + memcpy(temp_struct, cur_struct, sizeof(VkDeviceGroupDeviceCreateInfo)); phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * cur_struct->physicalDeviceCount); if (NULL == phys_dev_array) { return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -5372,19 +5385,23 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical // are not recognized by the ICD. If this causes the ICD to fail, then the items would have to be removed here. The current // implementation does not remove them because copying the pNext chain would be impossible if the loader does not recognize // the any of the struct types, as the loader would not know the size to allocate and copy. - if (icd_term->dispatch.GetPhysicalDeviceFeatures2KHR == NULL) { + //if (icd_term->dispatch.GetPhysicalDeviceFeatures2 == NULL && icd_term->dispatch.GetPhysicalDeviceFeatures2KHR == NULL) { + { const void *pNext = localCreateInfo.pNext; while (pNext != NULL) { switch (*(VkStructureType *)pNext) { - case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR: { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkCreateDevice: Emulating handling of VkPhysicalDeviceFeatures2KHR in pNext chain for ICD \"%s\"", - icd_term->scanned_icd->lib_name); + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2: { const VkPhysicalDeviceFeatures2KHR *features = pNext; - // Verify that VK_KHR_get_physical_device_properties2 is enabled - if (icd_term->this_instance->enabled_known_extensions.khr_get_physical_device_properties2) { - localCreateInfo.pEnabledFeatures = &features->features; + if (icd_term->dispatch.GetPhysicalDeviceFeatures2 == NULL && icd_term->dispatch.GetPhysicalDeviceFeatures2KHR == NULL) { + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, + "vkCreateDevice: Emulating handling of VkPhysicalDeviceFeatures2 in pNext chain for ICD \"%s\"", + icd_term->scanned_icd->lib_name); + + // Verify that VK_KHR_get_physical_device_properties2 is enabled + if (icd_term->this_instance->enabled_known_extensions.khr_get_physical_device_properties2) { + localCreateInfo.pEnabledFeatures = &features->features; + } } // Leave this item in the pNext chain for now @@ -5393,19 +5410,22 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical break; } - case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR: { - loader_log( - icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, - "vkCreateDevice: Emulating handling of VkPhysicalDeviceGroupPropertiesKHR in pNext chain for ICD \"%s\"", - icd_term->scanned_icd->lib_name); + case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO: { const VkDeviceGroupDeviceCreateInfoKHR *group_info = pNext; - // The group must contain only this one device, since physical device groups aren't actually supported - if (group_info->physicalDeviceCount != 1 || group_info->pPhysicalDevices[0] != physicalDevice) { - loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + if (icd_term->dispatch.EnumeratePhysicalDeviceGroups == NULL && icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR == NULL) { + loader_log( + icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, + "vkCreateDevice: Emulating handling of VkPhysicalDeviceGroupProperties in pNext chain for ICD \"%s\"", + icd_term->scanned_icd->lib_name); + + // The group must contain only this one device, since physical device groups aren't actually supported + if (group_info->physicalDeviceCount != 1) { + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "vkCreateDevice: Emulation failed to create device from device group info"); - res = VK_ERROR_INITIALIZATION_FAILED; - goto out; + res = VK_ERROR_INITIALIZATION_FAILED; + goto out; + } } // Nothing needs to be done here because we're leaving the item in the pNext chain and because the spec states @@ -6148,11 +6168,12 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { uint32_t cur_icd_group_count = 0; VkPhysicalDeviceGroupPropertiesKHR **new_phys_dev_groups = NULL; VkPhysicalDeviceGroupPropertiesKHR *local_phys_dev_groups = NULL; + PFN_vkEnumeratePhysicalDeviceGroups fpEnumeratePhysicalDeviceGroups = NULL; if (0 == inst->phys_dev_count_term) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Loader failed to setup physical " - "device terminator info before calling \'EnumeratePhysicalDeviceGroupsKHR\'."); + "device terminator info before calling \'EnumeratePhysicalDeviceGroups\'."); assert(false); res = VK_ERROR_INITIALIZATION_FAILED; goto out; @@ -6162,8 +6183,15 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { // internal value for those physical devices. icd_term = inst->icd_terms; for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + if (inst->enabled_known_extensions.khr_device_group_creation) { + fpEnumeratePhysicalDeviceGroups = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR; + } else { + fpEnumeratePhysicalDeviceGroups = icd_term->dispatch.EnumeratePhysicalDeviceGroups; + } + cur_icd_group_count = 0; - if (NULL == icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR) { + if (NULL == fpEnumeratePhysicalDeviceGroups) { // Treat each ICD's GPU as it's own group if the extension isn't supported res = icd_term->dispatch.EnumeratePhysicalDevices(icd_term->instance, &cur_icd_group_count, NULL); if (res != VK_SUCCESS) { @@ -6175,11 +6203,11 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { } } else { // Query the actual group info - res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR(icd_term->instance, &cur_icd_group_count, NULL); + res = fpEnumeratePhysicalDeviceGroups(icd_term->instance, &cur_icd_group_count, NULL); if (res != VK_SUCCESS) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHR\' to ICD %d to get count.", + "\'EnumeratePhysicalDeviceGroups\' to ICD %d to get count.", icd_idx); goto out; } @@ -6189,8 +6217,8 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { // Create an array for the new physical device groups, which will be stored // in the instance for the Terminator code. - new_phys_dev_groups = (VkPhysicalDeviceGroupPropertiesKHR **)loader_instance_heap_alloc( - inst, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHR *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + new_phys_dev_groups = (VkPhysicalDeviceGroupProperties **)loader_instance_heap_alloc( + inst, total_count * sizeof(VkPhysicalDeviceGroupProperties *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (NULL == new_phys_dev_groups) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Failed to allocate new physical device" @@ -6199,11 +6227,11 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { res = VK_ERROR_OUT_OF_HOST_MEMORY; goto out; } - memset(new_phys_dev_groups, 0, total_count * sizeof(VkPhysicalDeviceGroupPropertiesKHR *)); + memset(new_phys_dev_groups, 0, total_count * sizeof(VkPhysicalDeviceGroupProperties *)); // Create a temporary array (on the stack) to keep track of the // returned VkPhysicalDevice values. - local_phys_dev_groups = loader_stack_alloc(sizeof(VkPhysicalDeviceGroupPropertiesKHR) * total_count); + local_phys_dev_groups = loader_stack_alloc(sizeof(VkPhysicalDeviceGroupProperties) * total_count); if (NULL == local_phys_dev_groups) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Failed to allocate local " @@ -6213,7 +6241,7 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { goto out; } // Initialize the memory to something valid - memset(local_phys_dev_groups, 0, sizeof(VkPhysicalDeviceGroupPropertiesKHR) * total_count); + memset(local_phys_dev_groups, 0, sizeof(VkPhysicalDeviceGroupProperties) * total_count); for (uint32_t group = 0; group < total_count; group++) { local_phys_dev_groups[group].sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR; local_phys_dev_groups[group].pNext = NULL; @@ -6225,7 +6253,14 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { for (uint32_t icd_idx = 0; NULL != icd_term; icd_term = icd_term->next, icd_idx++) { uint32_t count_this_time = total_count - cur_icd_group_count; - if (NULL == icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR) { + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + if (inst->enabled_known_extensions.khr_device_group_creation) { + fpEnumeratePhysicalDeviceGroups = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR; + } else { + fpEnumeratePhysicalDeviceGroups = icd_term->dispatch.EnumeratePhysicalDeviceGroups; + } + + if (NULL == fpEnumeratePhysicalDeviceGroups) { VkPhysicalDevice* phys_dev_array = loader_stack_alloc(sizeof(VkPhysicalDevice) * count_this_time); if (NULL == phys_dev_array) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -6252,11 +6287,11 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { } } else { - res = icd_term->dispatch.EnumeratePhysicalDeviceGroupsKHR(icd_term->instance, &count_this_time, &local_phys_dev_groups[cur_icd_group_count]); + res = fpEnumeratePhysicalDeviceGroups(icd_term->instance, &count_this_time, &local_phys_dev_groups[cur_icd_group_count]); if (VK_SUCCESS != res) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Failed during dispatch call of " - "\'EnumeratePhysicalDeviceGroupsKHR\' to ICD %d to get content.", + "\'EnumeratePhysicalDeviceGroups\' to ICD %d to get content.", icd_idx); goto out; } @@ -6279,7 +6314,7 @@ VkResult setupLoaderTermPhysDevGroups(struct loader_instance *inst) { if (!found) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTermPhysDevGroups: Failed to find GPU %d in group %d" - " returned by \'EnumeratePhysicalDeviceGroupsKHR\' in list returned" + " returned by \'EnumeratePhysicalDeviceGroups\' in list returned" " by \'EnumeratePhysicalDevices\'", group_gpu, group); res = VK_ERROR_INITIALIZATION_FAILED; goto out; @@ -6408,10 +6443,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2(VkPhysicalDevic VkPhysicalDeviceFeatures2 *pFeatures) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceFeatures2 fpGetPhysicalDeviceFeatures2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceFeatures2 = icd_term->dispatch.GetPhysicalDeviceFeatures2KHR; + } else { + fpGetPhysicalDeviceFeatures2 = icd_term->dispatch.GetPhysicalDeviceFeatures2; + } - if (icd_term->dispatch.GetPhysicalDeviceFeatures2 != NULL) { + if (fpGetPhysicalDeviceFeatures2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceFeatures2(phys_dev_term->phys_dev, pFeatures); + fpGetPhysicalDeviceFeatures2(phys_dev_term->phys_dev, pFeatures); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6453,10 +6497,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2(VkPhysicalDev VkPhysicalDeviceProperties2 *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceProperties2 fpGetPhysicalDeviceProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceProperties2 = icd_term->dispatch.GetPhysicalDeviceProperties2KHR; + } else { + fpGetPhysicalDeviceProperties2 = icd_term->dispatch.GetPhysicalDeviceProperties2; + } - if (icd_term->dispatch.GetPhysicalDeviceProperties2 != NULL) { + if (fpGetPhysicalDeviceProperties2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceProperties2(phys_dev_term->phys_dev, pProperties); + fpGetPhysicalDeviceProperties2(phys_dev_term->phys_dev, pProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6505,10 +6558,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2(VkPhysi VkFormatProperties2 *pFormatProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; - if (icd_term->dispatch.GetPhysicalDeviceFormatProperties2 != NULL) { + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceFormatProperties2 fpGetPhysicalDeviceFormatProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceFormatProperties2KHR; + } else { + fpGetPhysicalDeviceFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceFormatProperties2; + } + + if (fpGetPhysicalDeviceFormatProperties2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceFormatProperties2(phys_dev_term->phys_dev, format, pFormatProperties); + fpGetPhysicalDeviceFormatProperties2(phys_dev_term->phys_dev, format, pFormatProperties); } else { // Emulate the call loader_log( @@ -6532,11 +6594,19 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties VkImageFormatProperties2KHR *pImageFormatProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; - if (icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2 != NULL) { + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceImageFormatProperties2 fpGetPhysicalDeviceImageFormatProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2KHR; + } else { + fpGetPhysicalDeviceImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2; + } + + if (fpGetPhysicalDeviceImageFormatProperties2 != NULL) { // Pass the call to the driver - return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2(phys_dev_term->phys_dev, pImageFormatInfo, - pImageFormatProperties); + return fpGetPhysicalDeviceImageFormatProperties2(phys_dev_term->phys_dev, pImageFormatInfo, pImageFormatProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6560,11 +6630,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2( VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceQueueFamilyProperties2 fpGetPhysicalDeviceQueueFamilyProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceQueueFamilyProperties2 = icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2KHR; + } else { + fpGetPhysicalDeviceQueueFamilyProperties2 = icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2; + } - if (icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2 != NULL) { + if (fpGetPhysicalDeviceQueueFamilyProperties2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, - pQueueFamilyProperties); + fpGetPhysicalDeviceQueueFamilyProperties2(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6607,10 +6685,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2( VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 *pMemoryProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceMemoryProperties2 fpGetPhysicalDeviceMemoryProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceMemoryProperties2 = icd_term->dispatch.GetPhysicalDeviceMemoryProperties2KHR; + } else { + fpGetPhysicalDeviceMemoryProperties2 = icd_term->dispatch.GetPhysicalDeviceMemoryProperties2; + } - if (icd_term->dispatch.GetPhysicalDeviceMemoryProperties2 != NULL) { + if (fpGetPhysicalDeviceMemoryProperties2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceMemoryProperties2(phys_dev_term->phys_dev, pMemoryProperties); + fpGetPhysicalDeviceMemoryProperties2(phys_dev_term->phys_dev, pMemoryProperties); } else { // Emulate the call loader_log( @@ -6634,11 +6721,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperti VkSparseImageFormatProperties2KHR *pProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 fpGetPhysicalDeviceSparseImageFormatProperties2 = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + fpGetPhysicalDeviceSparseImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2KHR; + } else { + fpGetPhysicalDeviceSparseImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2; + } - if (icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2 != NULL) { + if (fpGetPhysicalDeviceSparseImageFormatProperties2 != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2(phys_dev_term->phys_dev, pFormatInfo, pPropertyCount, - pProperties); + fpGetPhysicalDeviceSparseImageFormatProperties2(phys_dev_term->phys_dev, pFormatInfo, pPropertyCount, pProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6692,11 +6787,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalBufferProperties( VkExternalBufferProperties *pExternalBufferProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceExternalBufferProperties fpGetPhysicalDeviceExternalBufferProperties = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_external_memory_capabilities) { + fpGetPhysicalDeviceExternalBufferProperties = icd_term->dispatch.GetPhysicalDeviceExternalBufferPropertiesKHR; + } else { + fpGetPhysicalDeviceExternalBufferProperties = icd_term->dispatch.GetPhysicalDeviceExternalBufferProperties; + } - if (icd_term->dispatch.GetPhysicalDeviceExternalBufferProperties) { + if (fpGetPhysicalDeviceExternalBufferProperties) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalBufferProperties(phys_dev_term->phys_dev, pExternalBufferInfo, - pExternalBufferProperties); + fpGetPhysicalDeviceExternalBufferProperties(phys_dev_term->phys_dev, pExternalBufferInfo, pExternalBufferProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6724,11 +6827,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalSemaphoreProperti VkExternalSemaphoreProperties *pExternalSemaphoreProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; - if (icd_term->dispatch.GetPhysicalDeviceExternalSemaphoreProperties != NULL) { + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceExternalSemaphoreProperties fpGetPhysicalDeviceExternalSemaphoreProperties = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_external_semaphore_capabilities) { + fpGetPhysicalDeviceExternalSemaphoreProperties = icd_term->dispatch.GetPhysicalDeviceExternalSemaphorePropertiesKHR; + } else { + fpGetPhysicalDeviceExternalSemaphoreProperties = icd_term->dispatch.GetPhysicalDeviceExternalSemaphoreProperties; + } + + if (fpGetPhysicalDeviceExternalSemaphoreProperties != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalSemaphoreProperties(phys_dev_term->phys_dev, pExternalSemaphoreInfo, - pExternalSemaphoreProperties); + fpGetPhysicalDeviceExternalSemaphoreProperties(phys_dev_term->phys_dev, pExternalSemaphoreInfo, pExternalSemaphoreProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -6759,11 +6870,19 @@ VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalFenceProperties( VkExternalFenceProperties *pExternalFenceProperties) { struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + const struct loader_instance *inst = icd_term->this_instance; + + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + PFN_vkGetPhysicalDeviceExternalFenceProperties fpGetPhysicalDeviceExternalFenceProperties = NULL; + if (inst != NULL && inst->enabled_known_extensions.khr_external_fence_capabilities) { + fpGetPhysicalDeviceExternalFenceProperties = icd_term->dispatch.GetPhysicalDeviceExternalFencePropertiesKHR; + } else { + fpGetPhysicalDeviceExternalFenceProperties = icd_term->dispatch.GetPhysicalDeviceExternalFenceProperties; + } - if (icd_term->dispatch.GetPhysicalDeviceExternalFenceProperties != NULL) { + if (fpGetPhysicalDeviceExternalFenceProperties != NULL) { // Pass the call to the driver - icd_term->dispatch.GetPhysicalDeviceExternalFenceProperties(phys_dev_term->phys_dev, pExternalFenceInfo, - pExternalFenceProperties); + fpGetPhysicalDeviceExternalFenceProperties(phys_dev_term->phys_dev, pExternalFenceInfo, pExternalFenceProperties); } else { // Emulate the call loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, diff --git a/loader/trampoline.c b/loader/trampoline.c index f0f9bf59..8236c8aa 100644 --- a/loader/trampoline.c +++ b/loader/trampoline.c @@ -1999,25 +1999,13 @@ LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer co // ---- Vulkan core 1.1 trampolines -// TODO: The following functions need to be added tp GPA: -// - vkEnumeratePhysicalDeviceGroups -// - vkGetPhysicalDeviceFeatures2 -// - vkGetPhysicalDeviceProperties2 -// - vkGetPhysicalDeviceFormatProperties2 -// - vkGetPhysicalDeviceImageFormatProperties2 -// - vkGetPhysicalDeviceQueueFamilyProperties2 -// - vkGetPhysicalDeviceMemoryProperties2 -// - vkGetPhysicalDeviceSparseImageFormatProperties2 -// - vkGetPhysicalDeviceExternalBufferProperties -// - vkGetPhysicalDeviceExternalSemaphoreProperties -// - vkGetPhysicalDeviceExternalFenceProperties - VkResult setupLoaderTrampPhysDevGroups(VkInstance instance) { VkResult res = VK_SUCCESS; struct loader_instance *inst; uint32_t total_count = 0; VkPhysicalDeviceGroupPropertiesKHR **new_phys_dev_groups = NULL; VkPhysicalDeviceGroupPropertiesKHR *local_phys_dev_groups = NULL; + PFN_vkEnumeratePhysicalDeviceGroups fpEnumeratePhysicalDeviceGroups = NULL; inst = loader_get_instance(instance); if (NULL == inst) { @@ -2025,6 +2013,13 @@ VkResult setupLoaderTrampPhysDevGroups(VkInstance instance) { goto out; } + // Get the function pointer to use to call into the ICD. This could be the core or KHR version + if (inst->enabled_known_extensions.khr_device_group_creation) { + fpEnumeratePhysicalDeviceGroups = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHR; + } else { + fpEnumeratePhysicalDeviceGroups = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroups; + } + // Setup the trampoline loader physical devices. This will actually // call down and setup the terminator loader physical devices during the // process. @@ -2035,7 +2030,7 @@ VkResult setupLoaderTrampPhysDevGroups(VkInstance instance) { } // Query how many physical device groups there - res = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHR(instance, &total_count, NULL); + res = fpEnumeratePhysicalDeviceGroups(instance, &total_count, NULL); if (res != VK_SUCCESS) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevGroups: Failed during dispatch call of " @@ -2078,7 +2073,7 @@ VkResult setupLoaderTrampPhysDevGroups(VkInstance instance) { } // Call down and get the content - res = inst->disp->layer_inst_disp.EnumeratePhysicalDeviceGroupsKHR(instance, &total_count, local_phys_dev_groups); + fpEnumeratePhysicalDeviceGroups(instance, &total_count, local_phys_dev_groups); if (VK_SUCCESS != res) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "setupLoaderTrampPhysDevGroups: Failed during dispatch call of " @@ -2193,7 +2188,7 @@ out: return res; } -VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups( VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) { VkResult res = VK_SUCCESS; @@ -2249,92 +2244,142 @@ out: return res; } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures) { - const VkLayerInstanceDispatchTable *disp; +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures) { VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFeatures2(unwrapped_phys_dev, pFeatures); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceFeatures2KHR(unwrapped_phys_dev, pFeatures); + } else { + disp->GetPhysicalDeviceFeatures2(unwrapped_phys_dev, pFeatures); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceProperties2(unwrapped_phys_dev, pProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceProperties2KHR(unwrapped_phys_dev, pProperties); + } else { + disp->GetPhysicalDeviceProperties2(unwrapped_phys_dev, pProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 *pFormatProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceFormatProperties2(unwrapped_phys_dev, format, pFormatProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceFormatProperties2KHR(unwrapped_phys_dev, format, pFormatProperties); + } else { + disp->GetPhysicalDeviceFormatProperties2(unwrapped_phys_dev, format, pFormatProperties); + } } -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - return disp->GetPhysicalDeviceImageFormatProperties2(unwrapped_phys_dev, pImageFormatInfo, pImageFormatProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + return disp->GetPhysicalDeviceImageFormatProperties2KHR(unwrapped_phys_dev, pImageFormatInfo, pImageFormatProperties); + } else { + return disp->GetPhysicalDeviceImageFormatProperties2(unwrapped_phys_dev, pImageFormatInfo, pImageFormatProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceQueueFamilyProperties2(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceQueueFamilyProperties2KHR(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); + } else { + disp->GetPhysicalDeviceQueueFamilyProperties2(unwrapped_phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 *pMemoryProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceMemoryProperties2(unwrapped_phys_dev, pMemoryProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceMemoryProperties2KHR(unwrapped_phys_dev, pMemoryProperties); + } else { + disp->GetPhysicalDeviceMemoryProperties2(unwrapped_phys_dev, pMemoryProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo, uint32_t *pPropertyCount, VkSparseImageFormatProperties2 *pProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceSparseImageFormatProperties2(unwrapped_phys_dev, pFormatInfo, pPropertyCount, pProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { + disp->GetPhysicalDeviceSparseImageFormatProperties2KHR(unwrapped_phys_dev, pFormatInfo, pPropertyCount, pProperties); + } else { + disp->GetPhysicalDeviceSparseImageFormatProperties2(unwrapped_phys_dev, pFormatInfo, pPropertyCount, pProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalBufferProperties(unwrapped_phys_dev, pExternalBufferInfo, pExternalBufferProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_external_memory_capabilities){ + disp->GetPhysicalDeviceExternalBufferPropertiesKHR(unwrapped_phys_dev, pExternalBufferInfo, pExternalBufferProperties); + } else { + disp->GetPhysicalDeviceExternalBufferProperties(unwrapped_phys_dev, pExternalBufferInfo, pExternalBufferProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalSemaphoreProperties(unwrapped_phys_dev, pExternalSemaphoreInfo, pExternalSemaphoreProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_external_semaphore_capabilities) { + disp->GetPhysicalDeviceExternalSemaphorePropertiesKHR(unwrapped_phys_dev, pExternalSemaphoreInfo, pExternalSemaphoreProperties); + } else { + disp->GetPhysicalDeviceExternalSemaphoreProperties(unwrapped_phys_dev, pExternalSemaphoreInfo, pExternalSemaphoreProperties); + } } -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) { - const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); - disp = loader_get_instance_layer_dispatch(physicalDevice); - disp->GetPhysicalDeviceExternalFenceProperties(unwrapped_phys_dev, pExternalFenceInfo, pExternalFenceProperties); + const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(physicalDevice); + const struct loader_instance *inst = ((struct loader_physical_device_tramp*) physicalDevice)->this_instance; + + if (inst != NULL && inst->enabled_known_extensions.khr_external_fence_capabilities) { + disp->GetPhysicalDeviceExternalFencePropertiesKHR(unwrapped_phys_dev, pExternalFenceInfo, pExternalFenceProperties); + } else { + disp->GetPhysicalDeviceExternalFenceProperties(unwrapped_phys_dev, pExternalFenceInfo, pExternalFenceProperties); + } } -VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2( VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos) { @@ -2342,7 +2387,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2( return disp->BindBufferMemory2(device, bindInfoCount, pBindInfos); } -VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2( VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos) { @@ -2350,7 +2395,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2( return disp->BindImageMemory2(device, bindInfoCount, pBindInfos); } -VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures( VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, @@ -2360,14 +2405,14 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures( disp->GetDeviceGroupPeerMemoryFeatures(device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures); } -VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask( VkCommandBuffer commandBuffer, uint32_t deviceMask) { const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); disp->CmdSetDeviceMask(commandBuffer, deviceMask); } -VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase( VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, @@ -2379,7 +2424,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase( disp->CmdDispatchBase(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ); } -VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2( VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements) { @@ -2387,7 +2432,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2( disp->GetImageMemoryRequirements2(device, pInfo, pMemoryRequirements); } -VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2( VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements) { @@ -2395,7 +2440,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2( disp->GetBufferMemoryRequirements2(device, pInfo, pMemoryRequirements); } -VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2( VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, @@ -2404,7 +2449,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2( disp->GetImageSparseMemoryRequirements2(device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements); } -VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags) { @@ -2412,13 +2457,13 @@ VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( disp->TrimCommandPool(device, commandPool, flags); } -VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { const VkLayerDispatchTable *disp = loader_get_dispatch(device); disp->GetDeviceQueue2(device, pQueueInfo, pQueue); loader_set_dispatch(*pQueue, disp); } -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion( VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, @@ -2427,7 +2472,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion( return disp->CreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion); } -VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion( VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator) { @@ -2435,7 +2480,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion( disp->DestroySamplerYcbcrConversion(device, ycbcrConversion, pAllocator); } -VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport( +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport( VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport) { diff --git a/loader/vulkan-1.def b/loader/vulkan-1.def index 467dd88c..b578d897 100644 --- a/loader/vulkan-1.def +++ b/loader/vulkan-1.def @@ -181,3 +181,31 @@ EXPORTS vkCreateSharedSwapchainsKHR vkCreateWin32SurfaceKHR vkGetPhysicalDeviceWin32PresentationSupportKHR + + vkEnumerateInstanceVersion + vkEnumeratePhysicalDeviceGroups + vkGetPhysicalDeviceFeatures2 + vkGetPhysicalDeviceProperties2 + vkGetPhysicalDeviceFormatProperties2 + vkGetPhysicalDeviceQueueFamilyProperties2 + vkGetPhysicalDeviceMemoryProperties2 + vkGetPhysicalDeviceSparseImageFormatProperties2 + vkGetPhysicalDeviceExternalBufferProperties + vkGetPhysicalDeviceExternalSemaphoreProperties + vkGetPhysicalDeviceExternalFenceProperties + vkBindBufferMemory2 + vkBindImageMemory2 + vkGetDeviceGroupPeerMemoryFeatures + vkCmdSetDeviceMask + vkCmdDispatchBase + vkGetImageMemoryRequirements2 + vkGetBufferMemoryRequirements2 + vkTrimCommandPool + vkGetDeviceQueue2 + vkCreateSamplerYcbcrConversion + vkDestroySamplerYcbcrConversion + vkGetDescriptorSetLayoutSupport + vkGetDeviceGroupPresentCapabilitiesKHR + vkGetDeviceGroupSurfacePresentModesKHR + vkGetPhysicalDevicePresentRectanglesKHR + vkAcquireNextImage2KHR diff --git a/loader/wsi.c b/loader/wsi.c index 4098b56f..44ddfc24 100644 --- a/loader/wsi.c +++ b/loader/wsi.c @@ -1525,11 +1525,22 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice dev return VK_SUCCESS; } -// TODO: The following functions need to be added tp GPA: -// - vkGetPhysicalDevicePresentRectanglesKHR -// - vkGetPhysicalDeviceSurfaceCapabilities2KHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR( + VkDevice device, + VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + return disp->GetDeviceGroupPresentCapabilitiesKHR(device, pDeviceGroupPresentCapabilities); +} -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR( + VkDevice device, + VkSurfaceKHR surface, + VkDeviceGroupPresentModeFlagsKHR* pModes) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + return disp->GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes); +} + +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, @@ -1559,6 +1570,14 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDevicePresentRectanglesKHR( return icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHR(phys_dev_term->phys_dev, surface, pRectCount, pRects); } +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR( + VkDevice device, + const VkAcquireNextImageInfoKHR* pAcquireInfo, + uint32_t* pImageIndex) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + return disp->AcquireNextImage2KHR(device, pAcquireInfo, pImageIndex); +} + bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { *addr = NULL; @@ -1584,6 +1603,21 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char return true; } + if (!strcmp("vkGetDeviceGroupPresentCapabilitiesKHR", name)) { + *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetDeviceGroupPresentCapabilitiesKHR : NULL; + return true; + } + + if (!strcmp("vkGetDeviceGroupSurfacePresentModesKHR", name)) { + *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetDeviceGroupSurfacePresentModesKHR : NULL; + return true; + } + + if (!strcmp("vkGetPhysicalDevicePresentRectanglesKHR", name)) { + *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDevicePresentRectanglesKHR : NULL; + return true; + } + // Functions for the VK_KHR_swapchain extension: // Note: This is a device extension, and its functions are statically @@ -1610,6 +1644,10 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *addr = (void *)vkQueuePresentKHR; return true; } + if (!strcmp("vkAcquireNextImage2KHR", name)) { + *addr = (void *)vkAcquireNextImage2KHR; + return true; + } #ifdef VK_USE_PLATFORM_WIN32_KHR -- cgit v1.2.3