15db71995Sopenharmony_ci/* 25db71995Sopenharmony_ci * 35db71995Sopenharmony_ci * Copyright (c) 2014-2021 The Khronos Group Inc. 45db71995Sopenharmony_ci * Copyright (c) 2014-2021 Valve Corporation 55db71995Sopenharmony_ci * Copyright (c) 2014-2021 LunarG, Inc. 65db71995Sopenharmony_ci * Copyright (C) 2015 Google Inc. 75db71995Sopenharmony_ci * Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 85db71995Sopenharmony_ci * Copyright (c) 2023-2023 RasterGrid Kft. 95db71995Sopenharmony_ci * 105db71995Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 115db71995Sopenharmony_ci * you may not use this file except in compliance with the License. 125db71995Sopenharmony_ci * You may obtain a copy of the License at 135db71995Sopenharmony_ci * 145db71995Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 155db71995Sopenharmony_ci * 165db71995Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 175db71995Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 185db71995Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 195db71995Sopenharmony_ci * See the License for the specific language governing permissions and 205db71995Sopenharmony_ci * limitations under the License. 215db71995Sopenharmony_ci 225db71995Sopenharmony_ci * 235db71995Sopenharmony_ci * Author: Jon Ashburn <jon@lunarg.com> 245db71995Sopenharmony_ci * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> 255db71995Sopenharmony_ci * Author: Mark Young <marky@lunarg.com> 265db71995Sopenharmony_ci * Author: Lenny Komow <lenny@lunarg.com> 275db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com> 285db71995Sopenharmony_ci * 295db71995Sopenharmony_ci */ 305db71995Sopenharmony_ci 315db71995Sopenharmony_ci// Terminators which have simple logic belong here, since they are mostly "pass through" 325db71995Sopenharmony_ci// Function declarations are in vk_loader_extensions.h, thus not needed here 335db71995Sopenharmony_ci 345db71995Sopenharmony_ci#include "allocation.h" 355db71995Sopenharmony_ci#include "loader_common.h" 365db71995Sopenharmony_ci#include "loader.h" 375db71995Sopenharmony_ci#include "log.h" 385db71995Sopenharmony_ci 395db71995Sopenharmony_ci// Terminators for 1.0 functions 405db71995Sopenharmony_ci 415db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, 425db71995Sopenharmony_ci VkPhysicalDeviceProperties *pProperties) { 435db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 445db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 455db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceProperties) { 465db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, pProperties); 475db71995Sopenharmony_ci } 485db71995Sopenharmony_ci} 495db71995Sopenharmony_ci 505db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, 515db71995Sopenharmony_ci uint32_t *pQueueFamilyPropertyCount, 525db71995Sopenharmony_ci VkQueueFamilyProperties *pProperties) { 535db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 545db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 555db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties) { 565db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pProperties); 575db71995Sopenharmony_ci } 585db71995Sopenharmony_ci} 595db71995Sopenharmony_ci 605db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, 615db71995Sopenharmony_ci VkPhysicalDeviceMemoryProperties *pProperties) { 625db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 635db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 645db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceMemoryProperties) { 655db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, pProperties); 665db71995Sopenharmony_ci } 675db71995Sopenharmony_ci} 685db71995Sopenharmony_ci 695db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, 705db71995Sopenharmony_ci VkPhysicalDeviceFeatures *pFeatures) { 715db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 725db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 735db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceFeatures) { 745db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, pFeatures); 755db71995Sopenharmony_ci } 765db71995Sopenharmony_ci} 775db71995Sopenharmony_ci 785db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, 795db71995Sopenharmony_ci VkFormatProperties *pFormatInfo) { 805db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 815db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 825db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceFormatProperties) { 835db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, pFormatInfo); 845db71995Sopenharmony_ci } 855db71995Sopenharmony_ci} 865db71995Sopenharmony_ci 875db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, 885db71995Sopenharmony_ci VkImageType type, VkImageTiling tiling, 895db71995Sopenharmony_ci VkImageUsageFlags usage, VkImageCreateFlags flags, 905db71995Sopenharmony_ci VkImageFormatProperties *pImageFormatProperties) { 915db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 925db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 935db71995Sopenharmony_ci if (NULL == icd_term->dispatch.GetPhysicalDeviceImageFormatProperties) { 945db71995Sopenharmony_ci loader_log( 955db71995Sopenharmony_ci icd_term->this_instance, VULKAN_LOADER_ERROR_BIT, 0, 965db71995Sopenharmony_ci "The icd's vkGetPhysicalDeviceImageFormatProperties was null, returning with VK_ERROR_INITIALIZATION_FAILED instead."); 975db71995Sopenharmony_ci return VK_ERROR_INITIALIZATION_FAILED; 985db71995Sopenharmony_ci } 995db71995Sopenharmony_ci return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties(phys_dev_term->phys_dev, format, type, tiling, usage, flags, 1005db71995Sopenharmony_ci pImageFormatProperties); 1015db71995Sopenharmony_ci} 1025db71995Sopenharmony_ci 1035db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, 1045db71995Sopenharmony_ci VkImageType type, VkSampleCountFlagBits samples, 1055db71995Sopenharmony_ci VkImageUsageFlags usage, VkImageTiling tiling, 1065db71995Sopenharmony_ci uint32_t *pNumProperties, 1075db71995Sopenharmony_ci VkSparseImageFormatProperties *pProperties) { 1085db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 1095db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 1105db71995Sopenharmony_ci if (NULL != icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties) { 1115db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties(phys_dev_term->phys_dev, format, type, samples, usage, 1125db71995Sopenharmony_ci tiling, pNumProperties, pProperties); 1135db71995Sopenharmony_ci } 1145db71995Sopenharmony_ci} 1155db71995Sopenharmony_ci 1165db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, 1175db71995Sopenharmony_ci VkLayerProperties *pProperties) { 1185db71995Sopenharmony_ci (void)pPropertyCount; 1195db71995Sopenharmony_ci (void)pProperties; 1205db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 1215db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 1225db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_ERROR_BIT, 0, 1235db71995Sopenharmony_ci "Encountered the vkEnumerateDeviceLayerProperties terminator. This means a layer improperly continued."); 1245db71995Sopenharmony_ci // Should never get here this call isn't dispatched down the chain 1255db71995Sopenharmony_ci return VK_ERROR_INITIALIZATION_FAILED; 1265db71995Sopenharmony_ci} 1275db71995Sopenharmony_ci 1285db71995Sopenharmony_ci// Terminators for 1.1 functions 1295db71995Sopenharmony_ci 1305db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, 1315db71995Sopenharmony_ci VkPhysicalDeviceFeatures2 *pFeatures) { 1325db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 1335db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 1345db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 1355db71995Sopenharmony_ci 1365db71995Sopenharmony_ci assert(inst != NULL); 1375db71995Sopenharmony_ci 1385db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 1395db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceFeatures2 fpGetPhysicalDeviceFeatures2 = NULL; 1405db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 1415db71995Sopenharmony_ci fpGetPhysicalDeviceFeatures2 = icd_term->dispatch.GetPhysicalDeviceFeatures2; 1425db71995Sopenharmony_ci } 1435db71995Sopenharmony_ci if (fpGetPhysicalDeviceFeatures2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 1445db71995Sopenharmony_ci fpGetPhysicalDeviceFeatures2 = icd_term->dispatch.GetPhysicalDeviceFeatures2KHR; 1455db71995Sopenharmony_ci } 1465db71995Sopenharmony_ci 1475db71995Sopenharmony_ci if (fpGetPhysicalDeviceFeatures2 != NULL) { 1485db71995Sopenharmony_ci // Pass the call to the driver 1495db71995Sopenharmony_ci fpGetPhysicalDeviceFeatures2(phys_dev_term->phys_dev, pFeatures); 1505db71995Sopenharmony_ci } else { 1515db71995Sopenharmony_ci // Emulate the call 1525db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 1535db71995Sopenharmony_ci "vkGetPhysicalDeviceFeatures2: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceFeatures", 1545db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 1555db71995Sopenharmony_ci 1565db71995Sopenharmony_ci // Write to the VkPhysicalDeviceFeatures2 struct 1575db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, &pFeatures->features); 1585db71995Sopenharmony_ci 1595db71995Sopenharmony_ci const VkBaseInStructure *pNext = pFeatures->pNext; 1605db71995Sopenharmony_ci while (pNext != NULL) { 1615db71995Sopenharmony_ci switch (pNext->sType) { 1625db71995Sopenharmony_ci case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES: { 1635db71995Sopenharmony_ci // Skip the check if VK_KHR_multiview is enabled because it's a device extension 1645db71995Sopenharmony_ci // Write to the VkPhysicalDeviceMultiviewFeaturesKHR struct 1655db71995Sopenharmony_ci VkPhysicalDeviceMultiviewFeaturesKHR *multiview_features = (VkPhysicalDeviceMultiviewFeaturesKHR *)pNext; 1665db71995Sopenharmony_ci multiview_features->multiview = VK_FALSE; 1675db71995Sopenharmony_ci multiview_features->multiviewGeometryShader = VK_FALSE; 1685db71995Sopenharmony_ci multiview_features->multiviewTessellationShader = VK_FALSE; 1695db71995Sopenharmony_ci 1705db71995Sopenharmony_ci pNext = multiview_features->pNext; 1715db71995Sopenharmony_ci break; 1725db71995Sopenharmony_ci } 1735db71995Sopenharmony_ci default: { 1745db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 1755db71995Sopenharmony_ci "vkGetPhysicalDeviceFeatures2: Emulation found unrecognized structure type in pFeatures->pNext - " 1765db71995Sopenharmony_ci "this struct will be ignored"); 1775db71995Sopenharmony_ci 1785db71995Sopenharmony_ci pNext = pNext->pNext; 1795db71995Sopenharmony_ci break; 1805db71995Sopenharmony_ci } 1815db71995Sopenharmony_ci } 1825db71995Sopenharmony_ci } 1835db71995Sopenharmony_ci } 1845db71995Sopenharmony_ci} 1855db71995Sopenharmony_ci 1865db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, 1875db71995Sopenharmony_ci VkPhysicalDeviceProperties2 *pProperties) { 1885db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 1895db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 1905db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 1915db71995Sopenharmony_ci 1925db71995Sopenharmony_ci assert(inst != NULL); 1935db71995Sopenharmony_ci 1945db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 1955db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceProperties2 fpGetPhysicalDeviceProperties2 = NULL; 1965db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 1975db71995Sopenharmony_ci fpGetPhysicalDeviceProperties2 = icd_term->dispatch.GetPhysicalDeviceProperties2; 1985db71995Sopenharmony_ci } 1995db71995Sopenharmony_ci if (fpGetPhysicalDeviceProperties2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 2005db71995Sopenharmony_ci fpGetPhysicalDeviceProperties2 = icd_term->dispatch.GetPhysicalDeviceProperties2KHR; 2015db71995Sopenharmony_ci } 2025db71995Sopenharmony_ci 2035db71995Sopenharmony_ci if (fpGetPhysicalDeviceProperties2 != NULL) { 2045db71995Sopenharmony_ci // Pass the call to the driver 2055db71995Sopenharmony_ci fpGetPhysicalDeviceProperties2(phys_dev_term->phys_dev, pProperties); 2065db71995Sopenharmony_ci } else { 2075db71995Sopenharmony_ci // Emulate the call 2085db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 2095db71995Sopenharmony_ci "vkGetPhysicalDeviceProperties2: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceProperties", 2105db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 2115db71995Sopenharmony_ci 2125db71995Sopenharmony_ci // Write to the VkPhysicalDeviceProperties2 struct 2135db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, &pProperties->properties); 2145db71995Sopenharmony_ci 2155db71995Sopenharmony_ci const VkBaseInStructure *pNext = pProperties->pNext; 2165db71995Sopenharmony_ci while (pNext != NULL) { 2175db71995Sopenharmony_ci switch (pNext->sType) { 2185db71995Sopenharmony_ci case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES: { 2195db71995Sopenharmony_ci VkPhysicalDeviceIDPropertiesKHR *id_properties = (VkPhysicalDeviceIDPropertiesKHR *)pNext; 2205db71995Sopenharmony_ci 2215db71995Sopenharmony_ci // Verify that "VK_KHR_external_memory_capabilities" is enabled 2225db71995Sopenharmony_ci if (icd_term->this_instance->enabled_known_extensions.khr_external_memory_capabilities) { 2235db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 2245db71995Sopenharmony_ci "vkGetPhysicalDeviceProperties2: Emulation cannot generate unique IDs for struct " 2255db71995Sopenharmony_ci "VkPhysicalDeviceIDProperties - setting IDs to zero instead"); 2265db71995Sopenharmony_ci 2275db71995Sopenharmony_ci // Write to the VkPhysicalDeviceIDPropertiesKHR struct 2285db71995Sopenharmony_ci memset(id_properties->deviceUUID, 0, VK_UUID_SIZE); 2295db71995Sopenharmony_ci memset(id_properties->driverUUID, 0, VK_UUID_SIZE); 2305db71995Sopenharmony_ci id_properties->deviceLUIDValid = VK_FALSE; 2315db71995Sopenharmony_ci } 2325db71995Sopenharmony_ci 2335db71995Sopenharmony_ci pNext = id_properties->pNext; 2345db71995Sopenharmony_ci break; 2355db71995Sopenharmony_ci } 2365db71995Sopenharmony_ci default: { 2375db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 2385db71995Sopenharmony_ci "vkGetPhysicalDeviceProperties2KHR: Emulation found unrecognized structure type in " 2395db71995Sopenharmony_ci "pProperties->pNext - this struct will be ignored"); 2405db71995Sopenharmony_ci 2415db71995Sopenharmony_ci pNext = pNext->pNext; 2425db71995Sopenharmony_ci break; 2435db71995Sopenharmony_ci } 2445db71995Sopenharmony_ci } 2455db71995Sopenharmony_ci } 2465db71995Sopenharmony_ci } 2475db71995Sopenharmony_ci} 2485db71995Sopenharmony_ci 2495db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, 2505db71995Sopenharmony_ci VkFormatProperties2 *pFormatProperties) { 2515db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 2525db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 2535db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 2545db71995Sopenharmony_ci 2555db71995Sopenharmony_ci assert(inst != NULL); 2565db71995Sopenharmony_ci 2575db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 2585db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceFormatProperties2 fpGetPhysicalDeviceFormatProperties2 = NULL; 2595db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 2605db71995Sopenharmony_ci fpGetPhysicalDeviceFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceFormatProperties2; 2615db71995Sopenharmony_ci } 2625db71995Sopenharmony_ci if (fpGetPhysicalDeviceFormatProperties2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 2635db71995Sopenharmony_ci fpGetPhysicalDeviceFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceFormatProperties2KHR; 2645db71995Sopenharmony_ci } 2655db71995Sopenharmony_ci 2665db71995Sopenharmony_ci if (fpGetPhysicalDeviceFormatProperties2 != NULL) { 2675db71995Sopenharmony_ci // Pass the call to the driver 2685db71995Sopenharmony_ci fpGetPhysicalDeviceFormatProperties2(phys_dev_term->phys_dev, format, pFormatProperties); 2695db71995Sopenharmony_ci } else { 2705db71995Sopenharmony_ci // Emulate the call 2715db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 2725db71995Sopenharmony_ci "vkGetPhysicalDeviceFormatProperties2: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceFormatProperties", 2735db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 2745db71995Sopenharmony_ci 2755db71995Sopenharmony_ci // Write to the VkFormatProperties2 struct 2765db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, format, &pFormatProperties->formatProperties); 2775db71995Sopenharmony_ci 2785db71995Sopenharmony_ci if (pFormatProperties->pNext != NULL) { 2795db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 2805db71995Sopenharmony_ci "vkGetPhysicalDeviceFormatProperties2: Emulation found unrecognized structure type in " 2815db71995Sopenharmony_ci "pFormatProperties->pNext - this struct will be ignored"); 2825db71995Sopenharmony_ci } 2835db71995Sopenharmony_ci } 2845db71995Sopenharmony_ci} 2855db71995Sopenharmony_ci 2865db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties2( 2875db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, 2885db71995Sopenharmony_ci VkImageFormatProperties2 *pImageFormatProperties) { 2895db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 2905db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 2915db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 2925db71995Sopenharmony_ci 2935db71995Sopenharmony_ci assert(inst != NULL); 2945db71995Sopenharmony_ci 2955db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 2965db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceImageFormatProperties2 fpGetPhysicalDeviceImageFormatProperties2 = NULL; 2975db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 2985db71995Sopenharmony_ci fpGetPhysicalDeviceImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2; 2995db71995Sopenharmony_ci } 3005db71995Sopenharmony_ci if (fpGetPhysicalDeviceImageFormatProperties2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 3015db71995Sopenharmony_ci fpGetPhysicalDeviceImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceImageFormatProperties2KHR; 3025db71995Sopenharmony_ci } 3035db71995Sopenharmony_ci 3045db71995Sopenharmony_ci if (fpGetPhysicalDeviceImageFormatProperties2 != NULL) { 3055db71995Sopenharmony_ci // Pass the call to the driver 3065db71995Sopenharmony_ci return fpGetPhysicalDeviceImageFormatProperties2(phys_dev_term->phys_dev, pImageFormatInfo, pImageFormatProperties); 3075db71995Sopenharmony_ci } else { 3085db71995Sopenharmony_ci // Emulate the call 3095db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 3105db71995Sopenharmony_ci "vkGetPhysicalDeviceImageFormatProperties2: Emulating call in ICD \"%s\" using " 3115db71995Sopenharmony_ci "vkGetPhysicalDeviceImageFormatProperties", 3125db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 3135db71995Sopenharmony_ci 3145db71995Sopenharmony_ci // If there is more info in either pNext, then this is unsupported 3155db71995Sopenharmony_ci if (pImageFormatInfo->pNext != NULL || pImageFormatProperties->pNext != NULL) { 3165db71995Sopenharmony_ci return VK_ERROR_FORMAT_NOT_SUPPORTED; 3175db71995Sopenharmony_ci } 3185db71995Sopenharmony_ci 3195db71995Sopenharmony_ci // Write to the VkImageFormatProperties2KHR struct 3205db71995Sopenharmony_ci return icd_term->dispatch.GetPhysicalDeviceImageFormatProperties( 3215db71995Sopenharmony_ci phys_dev_term->phys_dev, pImageFormatInfo->format, pImageFormatInfo->type, pImageFormatInfo->tiling, 3225db71995Sopenharmony_ci pImageFormatInfo->usage, pImageFormatInfo->flags, &pImageFormatProperties->imageFormatProperties); 3235db71995Sopenharmony_ci } 3245db71995Sopenharmony_ci} 3255db71995Sopenharmony_ci 3265db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, 3275db71995Sopenharmony_ci uint32_t *pQueueFamilyPropertyCount, 3285db71995Sopenharmony_ci VkQueueFamilyProperties2 *pQueueFamilyProperties) { 3295db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 3305db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 3315db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 3325db71995Sopenharmony_ci 3335db71995Sopenharmony_ci assert(inst != NULL); 3345db71995Sopenharmony_ci 3355db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 3365db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceQueueFamilyProperties2 fpGetPhysicalDeviceQueueFamilyProperties2 = NULL; 3375db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 3385db71995Sopenharmony_ci fpGetPhysicalDeviceQueueFamilyProperties2 = icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2; 3395db71995Sopenharmony_ci } 3405db71995Sopenharmony_ci if (fpGetPhysicalDeviceQueueFamilyProperties2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 3415db71995Sopenharmony_ci fpGetPhysicalDeviceQueueFamilyProperties2 = icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties2KHR; 3425db71995Sopenharmony_ci } 3435db71995Sopenharmony_ci 3445db71995Sopenharmony_ci if (fpGetPhysicalDeviceQueueFamilyProperties2 != NULL) { 3455db71995Sopenharmony_ci // Pass the call to the driver 3465db71995Sopenharmony_ci fpGetPhysicalDeviceQueueFamilyProperties2(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pQueueFamilyProperties); 3475db71995Sopenharmony_ci } else { 3485db71995Sopenharmony_ci // Emulate the call 3495db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 3505db71995Sopenharmony_ci "vkGetPhysicalDeviceQueueFamilyProperties2: Emulating call in ICD \"%s\" using " 3515db71995Sopenharmony_ci "vkGetPhysicalDeviceQueueFamilyProperties", 3525db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 3535db71995Sopenharmony_ci 3545db71995Sopenharmony_ci if (pQueueFamilyProperties == NULL || *pQueueFamilyPropertyCount == 0) { 3555db71995Sopenharmony_ci // Write to pQueueFamilyPropertyCount 3565db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, NULL); 3575db71995Sopenharmony_ci } else { 3585db71995Sopenharmony_ci // Allocate a temporary array for the output of the old function 3595db71995Sopenharmony_ci VkQueueFamilyProperties *properties = loader_stack_alloc(*pQueueFamilyPropertyCount * sizeof(VkQueueFamilyProperties)); 3605db71995Sopenharmony_ci if (properties == NULL) { 3615db71995Sopenharmony_ci *pQueueFamilyPropertyCount = 0; 3625db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_ERROR_BIT, 0, 3635db71995Sopenharmony_ci "vkGetPhysicalDeviceQueueFamilyProperties2: Out of memory - Failed to allocate array for loader " 3645db71995Sopenharmony_ci "emulation."); 3655db71995Sopenharmony_ci return; 3665db71995Sopenharmony_ci } 3675db71995Sopenharmony_ci 3685db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceQueueFamilyProperties(phys_dev_term->phys_dev, pQueueFamilyPropertyCount, 3695db71995Sopenharmony_ci properties); 3705db71995Sopenharmony_ci for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; ++i) { 3715db71995Sopenharmony_ci // Write to the VkQueueFamilyProperties2KHR struct 3725db71995Sopenharmony_ci memcpy(&pQueueFamilyProperties[i].queueFamilyProperties, &properties[i], sizeof(VkQueueFamilyProperties)); 3735db71995Sopenharmony_ci 3745db71995Sopenharmony_ci if (pQueueFamilyProperties[i].pNext != NULL) { 3755db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 3765db71995Sopenharmony_ci "vkGetPhysicalDeviceQueueFamilyProperties2: Emulation found unrecognized structure type in " 3775db71995Sopenharmony_ci "pQueueFamilyProperties[%d].pNext - this struct will be ignored", 3785db71995Sopenharmony_ci i); 3795db71995Sopenharmony_ci } 3805db71995Sopenharmony_ci } 3815db71995Sopenharmony_ci } 3825db71995Sopenharmony_ci } 3835db71995Sopenharmony_ci} 3845db71995Sopenharmony_ci 3855db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, 3865db71995Sopenharmony_ci VkPhysicalDeviceMemoryProperties2 *pMemoryProperties) { 3875db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 3885db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 3895db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 3905db71995Sopenharmony_ci 3915db71995Sopenharmony_ci assert(inst != NULL); 3925db71995Sopenharmony_ci 3935db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 3945db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceMemoryProperties2 fpGetPhysicalDeviceMemoryProperties2 = NULL; 3955db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 3965db71995Sopenharmony_ci fpGetPhysicalDeviceMemoryProperties2 = icd_term->dispatch.GetPhysicalDeviceMemoryProperties2; 3975db71995Sopenharmony_ci } 3985db71995Sopenharmony_ci if (fpGetPhysicalDeviceMemoryProperties2 == NULL && inst->enabled_known_extensions.khr_get_physical_device_properties2) { 3995db71995Sopenharmony_ci fpGetPhysicalDeviceMemoryProperties2 = icd_term->dispatch.GetPhysicalDeviceMemoryProperties2KHR; 4005db71995Sopenharmony_ci } 4015db71995Sopenharmony_ci 4025db71995Sopenharmony_ci if (fpGetPhysicalDeviceMemoryProperties2 != NULL) { 4035db71995Sopenharmony_ci // Pass the call to the driver 4045db71995Sopenharmony_ci fpGetPhysicalDeviceMemoryProperties2(phys_dev_term->phys_dev, pMemoryProperties); 4055db71995Sopenharmony_ci } else { 4065db71995Sopenharmony_ci // Emulate the call 4075db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 4085db71995Sopenharmony_ci "vkGetPhysicalDeviceMemoryProperties2: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceMemoryProperties", 4095db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 4105db71995Sopenharmony_ci 4115db71995Sopenharmony_ci // Write to the VkPhysicalDeviceMemoryProperties2 struct 4125db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, &pMemoryProperties->memoryProperties); 4135db71995Sopenharmony_ci 4145db71995Sopenharmony_ci if (pMemoryProperties->pNext != NULL) { 4155db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 4165db71995Sopenharmony_ci "vkGetPhysicalDeviceMemoryProperties2: Emulation found unrecognized structure type in " 4175db71995Sopenharmony_ci "pMemoryProperties->pNext - this struct will be ignored"); 4185db71995Sopenharmony_ci } 4195db71995Sopenharmony_ci } 4205db71995Sopenharmony_ci} 4215db71995Sopenharmony_ci 4225db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties2( 4235db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, 4245db71995Sopenharmony_ci VkSparseImageFormatProperties2KHR *pProperties) { 4255db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 4265db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 4275db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 4285db71995Sopenharmony_ci 4295db71995Sopenharmony_ci assert(inst != NULL); 4305db71995Sopenharmony_ci 4315db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 4325db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 fpGetPhysicalDeviceSparseImageFormatProperties2 = NULL; 4335db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 4345db71995Sopenharmony_ci fpGetPhysicalDeviceSparseImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2; 4355db71995Sopenharmony_ci } 4365db71995Sopenharmony_ci if (fpGetPhysicalDeviceSparseImageFormatProperties2 == NULL && 4375db71995Sopenharmony_ci inst->enabled_known_extensions.khr_get_physical_device_properties2) { 4385db71995Sopenharmony_ci fpGetPhysicalDeviceSparseImageFormatProperties2 = icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties2KHR; 4395db71995Sopenharmony_ci } 4405db71995Sopenharmony_ci 4415db71995Sopenharmony_ci if (fpGetPhysicalDeviceSparseImageFormatProperties2 != NULL) { 4425db71995Sopenharmony_ci // Pass the call to the driver 4435db71995Sopenharmony_ci fpGetPhysicalDeviceSparseImageFormatProperties2(phys_dev_term->phys_dev, pFormatInfo, pPropertyCount, pProperties); 4445db71995Sopenharmony_ci } else { 4455db71995Sopenharmony_ci // Emulate the call 4465db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 4475db71995Sopenharmony_ci "vkGetPhysicalDeviceSparseImageFormatProperties2: Emulating call in ICD \"%s\" using " 4485db71995Sopenharmony_ci "vkGetPhysicalDeviceSparseImageFormatProperties", 4495db71995Sopenharmony_ci icd_term->scanned_icd->lib_name); 4505db71995Sopenharmony_ci 4515db71995Sopenharmony_ci if (pFormatInfo->pNext != NULL) { 4525db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 4535db71995Sopenharmony_ci "vkGetPhysicalDeviceSparseImageFormatProperties2: Emulation found unrecognized structure type in " 4545db71995Sopenharmony_ci "pFormatInfo->pNext - this struct will be ignored"); 4555db71995Sopenharmony_ci } 4565db71995Sopenharmony_ci 4575db71995Sopenharmony_ci if (pProperties == NULL || *pPropertyCount == 0) { 4585db71995Sopenharmony_ci // Write to pPropertyCount 4595db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties( 4605db71995Sopenharmony_ci phys_dev_term->phys_dev, pFormatInfo->format, pFormatInfo->type, pFormatInfo->samples, pFormatInfo->usage, 4615db71995Sopenharmony_ci pFormatInfo->tiling, pPropertyCount, NULL); 4625db71995Sopenharmony_ci } else { 4635db71995Sopenharmony_ci // Allocate a temporary array for the output of the old function 4645db71995Sopenharmony_ci VkSparseImageFormatProperties *properties = 4655db71995Sopenharmony_ci loader_stack_alloc(*pPropertyCount * sizeof(VkSparseImageMemoryRequirements)); 4665db71995Sopenharmony_ci if (properties == NULL) { 4675db71995Sopenharmony_ci *pPropertyCount = 0; 4685db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_ERROR_BIT, 0, 4695db71995Sopenharmony_ci "vkGetPhysicalDeviceSparseImageFormatProperties2: Out of memory - Failed to allocate array for " 4705db71995Sopenharmony_ci "loader emulation."); 4715db71995Sopenharmony_ci return; 4725db71995Sopenharmony_ci } 4735db71995Sopenharmony_ci 4745db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceSparseImageFormatProperties( 4755db71995Sopenharmony_ci phys_dev_term->phys_dev, pFormatInfo->format, pFormatInfo->type, pFormatInfo->samples, pFormatInfo->usage, 4765db71995Sopenharmony_ci pFormatInfo->tiling, pPropertyCount, properties); 4775db71995Sopenharmony_ci for (uint32_t i = 0; i < *pPropertyCount; ++i) { 4785db71995Sopenharmony_ci // Write to the VkSparseImageFormatProperties2KHR struct 4795db71995Sopenharmony_ci memcpy(&pProperties[i].properties, &properties[i], sizeof(VkSparseImageFormatProperties)); 4805db71995Sopenharmony_ci 4815db71995Sopenharmony_ci if (pProperties[i].pNext != NULL) { 4825db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 4835db71995Sopenharmony_ci "vkGetPhysicalDeviceSparseImageFormatProperties2: Emulation found unrecognized structure type in " 4845db71995Sopenharmony_ci "pProperties[%d].pNext - this struct will be ignored", 4855db71995Sopenharmony_ci i); 4865db71995Sopenharmony_ci } 4875db71995Sopenharmony_ci } 4885db71995Sopenharmony_ci } 4895db71995Sopenharmony_ci } 4905db71995Sopenharmony_ci} 4915db71995Sopenharmony_ci 4925db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalBufferProperties( 4935db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, 4945db71995Sopenharmony_ci VkExternalBufferProperties *pExternalBufferProperties) { 4955db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 4965db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 4975db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 4985db71995Sopenharmony_ci 4995db71995Sopenharmony_ci assert(inst != NULL); 5005db71995Sopenharmony_ci 5015db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 5025db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceExternalBufferProperties fpGetPhysicalDeviceExternalBufferProperties = NULL; 5035db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 5045db71995Sopenharmony_ci fpGetPhysicalDeviceExternalBufferProperties = icd_term->dispatch.GetPhysicalDeviceExternalBufferProperties; 5055db71995Sopenharmony_ci } 5065db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalBufferProperties == NULL && inst->enabled_known_extensions.khr_external_memory_capabilities) { 5075db71995Sopenharmony_ci fpGetPhysicalDeviceExternalBufferProperties = icd_term->dispatch.GetPhysicalDeviceExternalBufferPropertiesKHR; 5085db71995Sopenharmony_ci } 5095db71995Sopenharmony_ci 5105db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalBufferProperties != NULL) { 5115db71995Sopenharmony_ci // Pass the call to the driver 5125db71995Sopenharmony_ci fpGetPhysicalDeviceExternalBufferProperties(phys_dev_term->phys_dev, pExternalBufferInfo, pExternalBufferProperties); 5135db71995Sopenharmony_ci } else { 5145db71995Sopenharmony_ci // Emulate the call 5155db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 5165db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalBufferProperties: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); 5175db71995Sopenharmony_ci 5185db71995Sopenharmony_ci if (pExternalBufferInfo->pNext != NULL) { 5195db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 5205db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalBufferProperties: Emulation found unrecognized structure type in " 5215db71995Sopenharmony_ci "pExternalBufferInfo->pNext - this struct will be ignored"); 5225db71995Sopenharmony_ci } 5235db71995Sopenharmony_ci 5245db71995Sopenharmony_ci // Fill in everything being unsupported 5255db71995Sopenharmony_ci memset(&pExternalBufferProperties->externalMemoryProperties, 0, sizeof(VkExternalMemoryPropertiesKHR)); 5265db71995Sopenharmony_ci 5275db71995Sopenharmony_ci if (pExternalBufferProperties->pNext != NULL) { 5285db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 5295db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalBufferProperties: Emulation found unrecognized structure type in " 5305db71995Sopenharmony_ci "pExternalBufferProperties->pNext - this struct will be ignored"); 5315db71995Sopenharmony_ci } 5325db71995Sopenharmony_ci } 5335db71995Sopenharmony_ci} 5345db71995Sopenharmony_ci 5355db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalSemaphoreProperties( 5365db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, 5375db71995Sopenharmony_ci VkExternalSemaphoreProperties *pExternalSemaphoreProperties) { 5385db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 5395db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 5405db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 5415db71995Sopenharmony_ci 5425db71995Sopenharmony_ci assert(inst != NULL); 5435db71995Sopenharmony_ci 5445db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 5455db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceExternalSemaphoreProperties fpGetPhysicalDeviceExternalSemaphoreProperties = NULL; 5465db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 5475db71995Sopenharmony_ci fpGetPhysicalDeviceExternalSemaphoreProperties = icd_term->dispatch.GetPhysicalDeviceExternalSemaphoreProperties; 5485db71995Sopenharmony_ci } 5495db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalSemaphoreProperties == NULL && 5505db71995Sopenharmony_ci inst->enabled_known_extensions.khr_external_semaphore_capabilities) { 5515db71995Sopenharmony_ci fpGetPhysicalDeviceExternalSemaphoreProperties = icd_term->dispatch.GetPhysicalDeviceExternalSemaphorePropertiesKHR; 5525db71995Sopenharmony_ci } 5535db71995Sopenharmony_ci 5545db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalSemaphoreProperties != NULL) { 5555db71995Sopenharmony_ci // Pass the call to the driver 5565db71995Sopenharmony_ci fpGetPhysicalDeviceExternalSemaphoreProperties(phys_dev_term->phys_dev, pExternalSemaphoreInfo, 5575db71995Sopenharmony_ci pExternalSemaphoreProperties); 5585db71995Sopenharmony_ci } else { 5595db71995Sopenharmony_ci // Emulate the call 5605db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 5615db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalSemaphoreProperties: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); 5625db71995Sopenharmony_ci 5635db71995Sopenharmony_ci if (pExternalSemaphoreInfo->pNext != NULL) { 5645db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 5655db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalSemaphoreProperties: Emulation found unrecognized structure type in " 5665db71995Sopenharmony_ci "pExternalSemaphoreInfo->pNext - this struct will be ignored"); 5675db71995Sopenharmony_ci } 5685db71995Sopenharmony_ci 5695db71995Sopenharmony_ci // Fill in everything being unsupported 5705db71995Sopenharmony_ci pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0; 5715db71995Sopenharmony_ci pExternalSemaphoreProperties->compatibleHandleTypes = 0; 5725db71995Sopenharmony_ci pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; 5735db71995Sopenharmony_ci 5745db71995Sopenharmony_ci if (pExternalSemaphoreProperties->pNext != NULL) { 5755db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 5765db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalSemaphoreProperties: Emulation found unrecognized structure type in " 5775db71995Sopenharmony_ci "pExternalSemaphoreProperties->pNext - this struct will be ignored"); 5785db71995Sopenharmony_ci } 5795db71995Sopenharmony_ci } 5805db71995Sopenharmony_ci} 5815db71995Sopenharmony_ci 5825db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceExternalFenceProperties( 5835db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, 5845db71995Sopenharmony_ci VkExternalFenceProperties *pExternalFenceProperties) { 5855db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 5865db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 5875db71995Sopenharmony_ci const struct loader_instance *inst = icd_term->this_instance; 5885db71995Sopenharmony_ci 5895db71995Sopenharmony_ci assert(inst != NULL); 5905db71995Sopenharmony_ci 5915db71995Sopenharmony_ci // Get the function pointer to use to call into the ICD. This could be the core or KHR version 5925db71995Sopenharmony_ci PFN_vkGetPhysicalDeviceExternalFenceProperties fpGetPhysicalDeviceExternalFenceProperties = NULL; 5935db71995Sopenharmony_ci if (loader_check_version_meets_required(LOADER_VERSION_1_1_0, inst->app_api_version)) { 5945db71995Sopenharmony_ci fpGetPhysicalDeviceExternalFenceProperties = icd_term->dispatch.GetPhysicalDeviceExternalFenceProperties; 5955db71995Sopenharmony_ci } 5965db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalFenceProperties == NULL && inst->enabled_known_extensions.khr_external_fence_capabilities) { 5975db71995Sopenharmony_ci fpGetPhysicalDeviceExternalFenceProperties = icd_term->dispatch.GetPhysicalDeviceExternalFencePropertiesKHR; 5985db71995Sopenharmony_ci } 5995db71995Sopenharmony_ci 6005db71995Sopenharmony_ci if (fpGetPhysicalDeviceExternalFenceProperties != NULL) { 6015db71995Sopenharmony_ci // Pass the call to the driver 6025db71995Sopenharmony_ci fpGetPhysicalDeviceExternalFenceProperties(phys_dev_term->phys_dev, pExternalFenceInfo, pExternalFenceProperties); 6035db71995Sopenharmony_ci } else { 6045db71995Sopenharmony_ci // Emulate the call 6055db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_INFO_BIT, 0, 6065db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalFenceProperties: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); 6075db71995Sopenharmony_ci 6085db71995Sopenharmony_ci if (pExternalFenceInfo->pNext != NULL) { 6095db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 6105db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalFenceProperties: Emulation found unrecognized structure type in " 6115db71995Sopenharmony_ci "pExternalFenceInfo->pNext - this struct will be ignored"); 6125db71995Sopenharmony_ci } 6135db71995Sopenharmony_ci 6145db71995Sopenharmony_ci // Fill in everything being unsupported 6155db71995Sopenharmony_ci pExternalFenceProperties->exportFromImportedHandleTypes = 0; 6165db71995Sopenharmony_ci pExternalFenceProperties->compatibleHandleTypes = 0; 6175db71995Sopenharmony_ci pExternalFenceProperties->externalFenceFeatures = 0; 6185db71995Sopenharmony_ci 6195db71995Sopenharmony_ci if (pExternalFenceProperties->pNext != NULL) { 6205db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0, 6215db71995Sopenharmony_ci "vkGetPhysicalDeviceExternalFenceProperties: Emulation found unrecognized structure type in " 6225db71995Sopenharmony_ci "pExternalFenceProperties->pNext - this struct will be ignored"); 6235db71995Sopenharmony_ci } 6245db71995Sopenharmony_ci } 6255db71995Sopenharmony_ci} 6265db71995Sopenharmony_ci 6275db71995Sopenharmony_ci// 1.3 Core terminators 6285db71995Sopenharmony_ci 6295db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t *pToolCount, 6305db71995Sopenharmony_ci VkPhysicalDeviceToolProperties *pToolProperties) { 6315db71995Sopenharmony_ci struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; 6325db71995Sopenharmony_ci struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; 6335db71995Sopenharmony_ci 6345db71995Sopenharmony_ci if (NULL == icd_term->dispatch.GetPhysicalDeviceToolProperties) { 6355db71995Sopenharmony_ci loader_log(icd_term->this_instance, VULKAN_LOADER_ERROR_BIT, 0, 6365db71995Sopenharmony_ci "terminator_GetPhysicalDeviceToolProperties: The ICD's vkGetPhysicalDeviceToolProperties was NULL yet " 6375db71995Sopenharmony_ci "the physical device supports Vulkan API Version 1.3."); 6385db71995Sopenharmony_ci } else { 6395db71995Sopenharmony_ci VkPhysicalDeviceProperties properties; 6405db71995Sopenharmony_ci if (icd_term->dispatch.GetPhysicalDeviceProperties) { 6415db71995Sopenharmony_ci icd_term->dispatch.GetPhysicalDeviceProperties(phys_dev_term->phys_dev, &properties); 6425db71995Sopenharmony_ci 6435db71995Sopenharmony_ci if (VK_API_VERSION_MINOR(properties.apiVersion) >= 3) { 6445db71995Sopenharmony_ci return icd_term->dispatch.GetPhysicalDeviceToolProperties(phys_dev_term->phys_dev, pToolCount, pToolProperties); 6455db71995Sopenharmony_ci } 6465db71995Sopenharmony_ci } 6475db71995Sopenharmony_ci } 6485db71995Sopenharmony_ci 6495db71995Sopenharmony_ci // In the case the driver didn't support 1.3, make sure that the first layer doesn't find the count uninitialized 6505db71995Sopenharmony_ci *pToolCount = 0; 6515db71995Sopenharmony_ci return VK_SUCCESS; 6525db71995Sopenharmony_ci} 653