15db71995Sopenharmony_ci/* 25db71995Sopenharmony_ci * Copyright (c) 2021-2023 The Khronos Group Inc. 35db71995Sopenharmony_ci * Copyright (c) 2021-2023 Valve Corporation 45db71995Sopenharmony_ci * Copyright (c) 2021-2023 LunarG, Inc. 55db71995Sopenharmony_ci * Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 65db71995Sopenharmony_ci * Copyright (c) 2023-2023 RasterGrid Kft. 75db71995Sopenharmony_ci * 85db71995Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 95db71995Sopenharmony_ci * of this software and/or associated documentation files (the "Materials"), to 105db71995Sopenharmony_ci * deal in the Materials without restriction, including without limitation the 115db71995Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 125db71995Sopenharmony_ci * sell copies of the Materials, and to permit persons to whom the Materials are 135db71995Sopenharmony_ci * furnished to do so, subject to the following conditions: 145db71995Sopenharmony_ci * 155db71995Sopenharmony_ci * The above copyright notice(s) and this permission notice shall be included in 165db71995Sopenharmony_ci * all copies or substantial portions of the Materials. 175db71995Sopenharmony_ci * 185db71995Sopenharmony_ci * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 195db71995Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 205db71995Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 215db71995Sopenharmony_ci * 225db71995Sopenharmony_ci * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 235db71995Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 245db71995Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE 255db71995Sopenharmony_ci * USE OR OTHER DEALINGS IN THE MATERIALS. 265db71995Sopenharmony_ci * 275db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com> 285db71995Sopenharmony_ci */ 295db71995Sopenharmony_ci 305db71995Sopenharmony_ci#include "test_icd.h" 315db71995Sopenharmony_ci 325db71995Sopenharmony_ci// export vk_icdGetInstanceProcAddr 335db71995Sopenharmony_ci#if !defined(TEST_ICD_EXPORT_ICD_GIPA) 345db71995Sopenharmony_ci#define TEST_ICD_EXPORT_ICD_GIPA 0 355db71995Sopenharmony_ci#endif 365db71995Sopenharmony_ci 375db71995Sopenharmony_ci// export vk_icdNegotiateLoaderICDInterfaceVersion 385db71995Sopenharmony_ci#if !defined(TEST_ICD_EXPORT_NEGOTIATE_INTERFACE_VERSION) 395db71995Sopenharmony_ci#define TEST_ICD_EXPORT_NEGOTIATE_INTERFACE_VERSION 0 405db71995Sopenharmony_ci#endif 415db71995Sopenharmony_ci 425db71995Sopenharmony_ci// export vk_icdGetPhysicalDeviceProcAddr 435db71995Sopenharmony_ci#if !defined(TEST_ICD_EXPORT_ICD_GPDPA) 445db71995Sopenharmony_ci#define TEST_ICD_EXPORT_ICD_GPDPA 0 455db71995Sopenharmony_ci#endif 465db71995Sopenharmony_ci 475db71995Sopenharmony_ci// export vk_icdEnumerateAdapterPhysicalDevices 485db71995Sopenharmony_ci#if !defined(TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES) 495db71995Sopenharmony_ci#define TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES 0 505db71995Sopenharmony_ci#endif 515db71995Sopenharmony_ci 525db71995Sopenharmony_ci// expose vk_icdNegotiateLoaderICDInterfaceVersion, vk_icdEnumerateAdapterPhysicalDevices, and vk_icdGetPhysicalDeviceProcAddr 535db71995Sopenharmony_ci// through vk_icdGetInstanceProcAddr or vkGetInstanceProcAddr 545db71995Sopenharmony_ci#if !defined(TEST_ICD_EXPOSE_VERSION_7) 555db71995Sopenharmony_ci#define TEST_ICD_EXPOSE_VERSION_7 0 565db71995Sopenharmony_ci#endif 575db71995Sopenharmony_ci 585db71995Sopenharmony_ciTestICD icd; 595db71995Sopenharmony_ciextern "C" { 605db71995Sopenharmony_ciFRAMEWORK_EXPORT TestICD* get_test_icd_func() { return &icd; } 615db71995Sopenharmony_ciFRAMEWORK_EXPORT TestICD* reset_icd_func() { 625db71995Sopenharmony_ci icd.~TestICD(); 635db71995Sopenharmony_ci return new (&icd) TestICD(); 645db71995Sopenharmony_ci} 655db71995Sopenharmony_ci} 665db71995Sopenharmony_ci 675db71995Sopenharmony_ciLayerDefinition& FindLayer(std::vector<LayerDefinition>& layers, std::string layerName) { 685db71995Sopenharmony_ci for (auto& layer : layers) { 695db71995Sopenharmony_ci if (layer.layerName == layerName) return layer; 705db71995Sopenharmony_ci } 715db71995Sopenharmony_ci assert(false && "Layer name not found!"); 725db71995Sopenharmony_ci return layers[0]; 735db71995Sopenharmony_ci} 745db71995Sopenharmony_cibool CheckLayer(std::vector<LayerDefinition>& layers, std::string layerName) { 755db71995Sopenharmony_ci for (auto& layer : layers) { 765db71995Sopenharmony_ci if (layer.layerName == layerName) return true; 775db71995Sopenharmony_ci } 785db71995Sopenharmony_ci return false; 795db71995Sopenharmony_ci} 805db71995Sopenharmony_ci 815db71995Sopenharmony_cibool IsInstanceExtensionSupported(const char* extension_name) { 825db71995Sopenharmony_ci return icd.instance_extensions.end() != 835db71995Sopenharmony_ci std::find_if(icd.instance_extensions.begin(), icd.instance_extensions.end(), 845db71995Sopenharmony_ci [extension_name](Extension const& ext) { return string_eq(&ext.extensionName[0], extension_name); }); 855db71995Sopenharmony_ci} 865db71995Sopenharmony_ci 875db71995Sopenharmony_cibool IsInstanceExtensionEnabled(const char* extension_name) { 885db71995Sopenharmony_ci return icd.enabled_instance_extensions.end() != 895db71995Sopenharmony_ci std::find_if(icd.enabled_instance_extensions.begin(), icd.enabled_instance_extensions.end(), 905db71995Sopenharmony_ci [extension_name](Extension const& ext) { return string_eq(&ext.extensionName[0], extension_name); }); 915db71995Sopenharmony_ci} 925db71995Sopenharmony_ci 935db71995Sopenharmony_cibool IsPhysicalDeviceExtensionAvailable(const char* extension_name) { 945db71995Sopenharmony_ci for (auto& phys_dev : icd.physical_devices) { 955db71995Sopenharmony_ci if (phys_dev.extensions.end() != 965db71995Sopenharmony_ci std::find_if(phys_dev.extensions.begin(), phys_dev.extensions.end(), 975db71995Sopenharmony_ci [extension_name](Extension const& ext) { return ext.extensionName == extension_name; })) { 985db71995Sopenharmony_ci return true; 995db71995Sopenharmony_ci } 1005db71995Sopenharmony_ci } 1015db71995Sopenharmony_ci return false; 1025db71995Sopenharmony_ci} 1035db71995Sopenharmony_ci 1045db71995Sopenharmony_ci// typename T must have '.get()' function that returns a type U 1055db71995Sopenharmony_citemplate <typename T, typename U> 1065db71995Sopenharmony_ciVkResult FillCountPtr(std::vector<T> const& data_vec, uint32_t* pCount, U* pData) { 1075db71995Sopenharmony_ci if (pCount == nullptr) { 1085db71995Sopenharmony_ci return VK_ERROR_OUT_OF_HOST_MEMORY; 1095db71995Sopenharmony_ci } 1105db71995Sopenharmony_ci if (pData == nullptr) { 1115db71995Sopenharmony_ci *pCount = static_cast<uint32_t>(data_vec.size()); 1125db71995Sopenharmony_ci return VK_SUCCESS; 1135db71995Sopenharmony_ci } 1145db71995Sopenharmony_ci uint32_t amount_written = 0; 1155db71995Sopenharmony_ci uint32_t amount_to_write = static_cast<uint32_t>(data_vec.size()); 1165db71995Sopenharmony_ci if (*pCount < data_vec.size()) { 1175db71995Sopenharmony_ci amount_to_write = *pCount; 1185db71995Sopenharmony_ci } 1195db71995Sopenharmony_ci for (size_t i = 0; i < amount_to_write; i++) { 1205db71995Sopenharmony_ci pData[i] = data_vec[i].get(); 1215db71995Sopenharmony_ci amount_written++; 1225db71995Sopenharmony_ci } 1235db71995Sopenharmony_ci if (*pCount < data_vec.size()) { 1245db71995Sopenharmony_ci *pCount = amount_written; 1255db71995Sopenharmony_ci return VK_INCOMPLETE; 1265db71995Sopenharmony_ci } 1275db71995Sopenharmony_ci *pCount = amount_written; 1285db71995Sopenharmony_ci return VK_SUCCESS; 1295db71995Sopenharmony_ci} 1305db71995Sopenharmony_ci 1315db71995Sopenharmony_citemplate <typename T> 1325db71995Sopenharmony_ciVkResult FillCountPtr(std::vector<T> const& data_vec, uint32_t* pCount, T* pData) { 1335db71995Sopenharmony_ci if (pCount == nullptr) { 1345db71995Sopenharmony_ci return VK_ERROR_OUT_OF_HOST_MEMORY; 1355db71995Sopenharmony_ci } 1365db71995Sopenharmony_ci if (pData == nullptr) { 1375db71995Sopenharmony_ci *pCount = static_cast<uint32_t>(data_vec.size()); 1385db71995Sopenharmony_ci return VK_SUCCESS; 1395db71995Sopenharmony_ci } 1405db71995Sopenharmony_ci uint32_t amount_written = 0; 1415db71995Sopenharmony_ci uint32_t amount_to_write = static_cast<uint32_t>(data_vec.size()); 1425db71995Sopenharmony_ci if (*pCount < data_vec.size()) { 1435db71995Sopenharmony_ci amount_to_write = *pCount; 1445db71995Sopenharmony_ci } 1455db71995Sopenharmony_ci for (size_t i = 0; i < amount_to_write; i++) { 1465db71995Sopenharmony_ci pData[i] = data_vec[i]; 1475db71995Sopenharmony_ci amount_written++; 1485db71995Sopenharmony_ci } 1495db71995Sopenharmony_ci if (*pCount < data_vec.size()) { 1505db71995Sopenharmony_ci *pCount = amount_written; 1515db71995Sopenharmony_ci return VK_INCOMPLETE; 1525db71995Sopenharmony_ci } 1535db71995Sopenharmony_ci *pCount = amount_written; 1545db71995Sopenharmony_ci return VK_SUCCESS; 1555db71995Sopenharmony_ci} 1565db71995Sopenharmony_ci 1575db71995Sopenharmony_ci//// Instance Functions //// 1585db71995Sopenharmony_ci 1595db71995Sopenharmony_ci// VK_SUCCESS,VK_INCOMPLETE 1605db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, 1615db71995Sopenharmony_ci VkExtensionProperties* pProperties) { 1625db71995Sopenharmony_ci if (pLayerName != nullptr) { 1635db71995Sopenharmony_ci auto& layer = FindLayer(icd.instance_layers, std::string(pLayerName)); 1645db71995Sopenharmony_ci return FillCountPtr(layer.extensions, pPropertyCount, pProperties); 1655db71995Sopenharmony_ci } else { // instance extensions 1665db71995Sopenharmony_ci FillCountPtr(icd.instance_extensions, pPropertyCount, pProperties); 1675db71995Sopenharmony_ci } 1685db71995Sopenharmony_ci 1695db71995Sopenharmony_ci return VK_SUCCESS; 1705db71995Sopenharmony_ci} 1715db71995Sopenharmony_ci 1725db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties) { 1735db71995Sopenharmony_ci return FillCountPtr(icd.instance_layers, pPropertyCount, pProperties); 1745db71995Sopenharmony_ci} 1755db71995Sopenharmony_ci 1765db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateInstanceVersion(uint32_t* pApiVersion) { 1775db71995Sopenharmony_ci if (pApiVersion != nullptr) { 1785db71995Sopenharmony_ci *pApiVersion = icd.icd_api_version; 1795db71995Sopenharmony_ci } 1805db71995Sopenharmony_ci return VK_SUCCESS; 1815db71995Sopenharmony_ci} 1825db71995Sopenharmony_ci 1835db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, 1845db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 1855db71995Sopenharmony_ci VkInstance* pInstance) { 1865db71995Sopenharmony_ci if (pCreateInfo == nullptr || pCreateInfo->pApplicationInfo == nullptr) { 1875db71995Sopenharmony_ci return VK_ERROR_OUT_OF_HOST_MEMORY; 1885db71995Sopenharmony_ci } 1895db71995Sopenharmony_ci 1905db71995Sopenharmony_ci if (icd.icd_api_version < VK_API_VERSION_1_1) { 1915db71995Sopenharmony_ci if (pCreateInfo->pApplicationInfo->apiVersion > VK_API_VERSION_1_0) { 1925db71995Sopenharmony_ci return VK_ERROR_INCOMPATIBLE_DRIVER; 1935db71995Sopenharmony_ci } 1945db71995Sopenharmony_ci } 1955db71995Sopenharmony_ci 1965db71995Sopenharmony_ci // Add to the list of enabled extensions only those that the ICD actively supports 1975db71995Sopenharmony_ci for (uint32_t iii = 0; iii < pCreateInfo->enabledExtensionCount; ++iii) { 1985db71995Sopenharmony_ci if (IsInstanceExtensionSupported(pCreateInfo->ppEnabledExtensionNames[iii])) { 1995db71995Sopenharmony_ci icd.add_enabled_instance_extension({pCreateInfo->ppEnabledExtensionNames[iii]}); 2005db71995Sopenharmony_ci } 2015db71995Sopenharmony_ci } 2025db71995Sopenharmony_ci 2035db71995Sopenharmony_ci // VK_SUCCESS 2045db71995Sopenharmony_ci *pInstance = icd.instance_handle.handle; 2055db71995Sopenharmony_ci 2065db71995Sopenharmony_ci icd.passed_in_instance_create_flags = pCreateInfo->flags; 2075db71995Sopenharmony_ci 2085db71995Sopenharmony_ci return VK_SUCCESS; 2095db71995Sopenharmony_ci} 2105db71995Sopenharmony_ci 2115db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroyInstance([[maybe_unused]] VkInstance instance, 2125db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator) {} 2135db71995Sopenharmony_ci 2145db71995Sopenharmony_ci// VK_SUCCESS,VK_INCOMPLETE 2155db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumeratePhysicalDevices([[maybe_unused]] VkInstance instance, uint32_t* pPhysicalDeviceCount, 2165db71995Sopenharmony_ci VkPhysicalDevice* pPhysicalDevices) { 2175db71995Sopenharmony_ci if (pPhysicalDevices == nullptr) { 2185db71995Sopenharmony_ci *pPhysicalDeviceCount = static_cast<uint32_t>(icd.physical_devices.size()); 2195db71995Sopenharmony_ci } else { 2205db71995Sopenharmony_ci uint32_t handles_written = 0; 2215db71995Sopenharmony_ci for (size_t i = 0; i < icd.physical_devices.size(); i++) { 2225db71995Sopenharmony_ci if (i < *pPhysicalDeviceCount) { 2235db71995Sopenharmony_ci handles_written++; 2245db71995Sopenharmony_ci pPhysicalDevices[i] = icd.physical_devices[i].vk_physical_device.handle; 2255db71995Sopenharmony_ci } else { 2265db71995Sopenharmony_ci *pPhysicalDeviceCount = handles_written; 2275db71995Sopenharmony_ci return VK_INCOMPLETE; 2285db71995Sopenharmony_ci } 2295db71995Sopenharmony_ci } 2305db71995Sopenharmony_ci *pPhysicalDeviceCount = handles_written; 2315db71995Sopenharmony_ci } 2325db71995Sopenharmony_ci return VK_SUCCESS; 2335db71995Sopenharmony_ci} 2345db71995Sopenharmony_ci 2355db71995Sopenharmony_ci// VK_SUCCESS,VK_INCOMPLETE, VK_ERROR_INITIALIZATION_FAILED 2365db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL 2375db71995Sopenharmony_citest_vkEnumeratePhysicalDeviceGroups([[maybe_unused]] VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, 2385db71995Sopenharmony_ci VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties) { 2395db71995Sopenharmony_ci VkResult result = VK_SUCCESS; 2405db71995Sopenharmony_ci 2415db71995Sopenharmony_ci if (pPhysicalDeviceGroupProperties == nullptr) { 2425db71995Sopenharmony_ci if (0 == icd.physical_device_groups.size()) { 2435db71995Sopenharmony_ci *pPhysicalDeviceGroupCount = static_cast<uint32_t>(icd.physical_devices.size()); 2445db71995Sopenharmony_ci } else { 2455db71995Sopenharmony_ci *pPhysicalDeviceGroupCount = static_cast<uint32_t>(icd.physical_device_groups.size()); 2465db71995Sopenharmony_ci } 2475db71995Sopenharmony_ci } else { 2485db71995Sopenharmony_ci // NOTE: This is a fake struct to make sure the pNext chain is properly passed down to the ICD 2495db71995Sopenharmony_ci // vkEnumeratePhysicalDeviceGroups. 2505db71995Sopenharmony_ci // The two versions must match: 2515db71995Sopenharmony_ci // "FakePNext" test in loader_regresion_tests.cpp 2525db71995Sopenharmony_ci // "test_vkEnumeratePhysicalDeviceGroups" in test_icd.cpp 2535db71995Sopenharmony_ci struct FakePnextSharedWithICD { 2545db71995Sopenharmony_ci VkStructureType sType; 2555db71995Sopenharmony_ci void* pNext; 2565db71995Sopenharmony_ci uint32_t value; 2575db71995Sopenharmony_ci }; 2585db71995Sopenharmony_ci 2595db71995Sopenharmony_ci uint32_t group_count = 0; 2605db71995Sopenharmony_ci if (0 == icd.physical_device_groups.size()) { 2615db71995Sopenharmony_ci group_count = static_cast<uint32_t>(icd.physical_devices.size()); 2625db71995Sopenharmony_ci for (size_t device_group = 0; device_group < icd.physical_devices.size(); device_group++) { 2635db71995Sopenharmony_ci if (device_group >= *pPhysicalDeviceGroupCount) { 2645db71995Sopenharmony_ci group_count = *pPhysicalDeviceGroupCount; 2655db71995Sopenharmony_ci result = VK_INCOMPLETE; 2665db71995Sopenharmony_ci break; 2675db71995Sopenharmony_ci } 2685db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].subsetAllocation = false; 2695db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDeviceCount = 1; 2705db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDevices[0] = 2715db71995Sopenharmony_ci icd.physical_devices[device_group].vk_physical_device.handle; 2725db71995Sopenharmony_ci for (size_t i = 1; i < VK_MAX_DEVICE_GROUP_SIZE; i++) { 2735db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] = {}; 2745db71995Sopenharmony_ci } 2755db71995Sopenharmony_ci } 2765db71995Sopenharmony_ci } else { 2775db71995Sopenharmony_ci group_count = static_cast<uint32_t>(icd.physical_device_groups.size()); 2785db71995Sopenharmony_ci for (size_t device_group = 0; device_group < icd.physical_device_groups.size(); device_group++) { 2795db71995Sopenharmony_ci if (device_group >= *pPhysicalDeviceGroupCount) { 2805db71995Sopenharmony_ci group_count = *pPhysicalDeviceGroupCount; 2815db71995Sopenharmony_ci result = VK_INCOMPLETE; 2825db71995Sopenharmony_ci break; 2835db71995Sopenharmony_ci } 2845db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].subsetAllocation = 2855db71995Sopenharmony_ci icd.physical_device_groups[device_group].subset_allocation; 2865db71995Sopenharmony_ci uint32_t handles_written = 0; 2875db71995Sopenharmony_ci for (size_t i = 0; i < icd.physical_device_groups[device_group].physical_device_handles.size(); i++) { 2885db71995Sopenharmony_ci handles_written++; 2895db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] = 2905db71995Sopenharmony_ci icd.physical_device_groups[device_group].physical_device_handles[i]->vk_physical_device.handle; 2915db71995Sopenharmony_ci } 2925db71995Sopenharmony_ci for (size_t i = handles_written; i < VK_MAX_DEVICE_GROUP_SIZE; i++) { 2935db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDevices[i] = {}; 2945db71995Sopenharmony_ci } 2955db71995Sopenharmony_ci pPhysicalDeviceGroupProperties[device_group].physicalDeviceCount = handles_written; 2965db71995Sopenharmony_ci } 2975db71995Sopenharmony_ci } 2985db71995Sopenharmony_ci // NOTE: The following code is purely to test pNext passing in vkEnumeratePhysicalDevice groups 2995db71995Sopenharmony_ci // and includes normally invalid information. 3005db71995Sopenharmony_ci for (size_t device_group = 0; device_group < group_count; device_group++) { 3015db71995Sopenharmony_ci if (nullptr != pPhysicalDeviceGroupProperties[device_group].pNext) { 3025db71995Sopenharmony_ci VkBaseInStructure* base = reinterpret_cast<VkBaseInStructure*>(pPhysicalDeviceGroupProperties[device_group].pNext); 3035db71995Sopenharmony_ci if (base->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT) { 3045db71995Sopenharmony_ci FakePnextSharedWithICD* fake = reinterpret_cast<FakePnextSharedWithICD*>(base); 3055db71995Sopenharmony_ci fake->value = 0xDECAFBAD; 3065db71995Sopenharmony_ci } 3075db71995Sopenharmony_ci } 3085db71995Sopenharmony_ci } 3095db71995Sopenharmony_ci *pPhysicalDeviceGroupCount = static_cast<uint32_t>(group_count); 3105db71995Sopenharmony_ci } 3115db71995Sopenharmony_ci return result; 3125db71995Sopenharmony_ci} 3135db71995Sopenharmony_ci 3145db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDebugUtilsMessengerEXT( 3155db71995Sopenharmony_ci [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, 3165db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { 3175db71995Sopenharmony_ci if (nullptr != pMessenger) { 3185db71995Sopenharmony_ci uint64_t fake_msgr_handle = reinterpret_cast<uint64_t>(new uint8_t); 3195db71995Sopenharmony_ci icd.messenger_handles.push_back(fake_msgr_handle); 3205db71995Sopenharmony_ci#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ 3215db71995Sopenharmony_ci defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) 3225db71995Sopenharmony_ci *pMessenger = reinterpret_cast<VkDebugUtilsMessengerEXT>(fake_msgr_handle); 3235db71995Sopenharmony_ci#else 3245db71995Sopenharmony_ci *pMessenger = fake_msgr_handle; 3255db71995Sopenharmony_ci#endif 3265db71995Sopenharmony_ci } 3275db71995Sopenharmony_ci return VK_SUCCESS; 3285db71995Sopenharmony_ci} 3295db71995Sopenharmony_ci 3305db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroyDebugUtilsMessengerEXT([[maybe_unused]] VkInstance instance, 3315db71995Sopenharmony_ci VkDebugUtilsMessengerEXT messenger, 3325db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator) { 3335db71995Sopenharmony_ci if (messenger != VK_NULL_HANDLE) { 3345db71995Sopenharmony_ci uint64_t fake_msgr_handle = (uint64_t)(messenger); 3355db71995Sopenharmony_ci auto found_iter = std::find(icd.messenger_handles.begin(), icd.messenger_handles.end(), fake_msgr_handle); 3365db71995Sopenharmony_ci if (found_iter != icd.messenger_handles.end()) { 3375db71995Sopenharmony_ci // Remove it from the list 3385db71995Sopenharmony_ci icd.messenger_handles.erase(found_iter); 3395db71995Sopenharmony_ci // Delete the handle 3405db71995Sopenharmony_ci delete (uint8_t*)fake_msgr_handle; 3415db71995Sopenharmony_ci } else { 3425db71995Sopenharmony_ci assert(false && "Messenger not found during destroy!"); 3435db71995Sopenharmony_ci } 3445db71995Sopenharmony_ci } 3455db71995Sopenharmony_ci} 3465db71995Sopenharmony_ci 3475db71995Sopenharmony_ci// Debug utils & debug marker ext stubs 3485db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkDebugMarkerSetObjectTagEXT(VkDevice dev, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { 3495db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { 3505db71995Sopenharmony_ci VkPhysicalDevice pd = (VkPhysicalDevice)(uintptr_t)(pTagInfo->object); 3515db71995Sopenharmony_ci if (pd != icd.physical_devices.at(icd.lookup_device(dev).phys_dev_index).vk_physical_device.handle) 3525db71995Sopenharmony_ci return VK_ERROR_DEVICE_LOST; 3535db71995Sopenharmony_ci } 3545db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { 3555db71995Sopenharmony_ci if (pTagInfo->object != icd.surface_handles.at(0)) return VK_ERROR_DEVICE_LOST; 3565db71995Sopenharmony_ci } 3575db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT) { 3585db71995Sopenharmony_ci if (pTagInfo->object != (uint64_t)(uintptr_t)icd.instance_handle.handle) return VK_ERROR_DEVICE_LOST; 3595db71995Sopenharmony_ci } 3605db71995Sopenharmony_ci return VK_SUCCESS; 3615db71995Sopenharmony_ci} 3625db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkDebugMarkerSetObjectNameEXT(VkDevice dev, const VkDebugMarkerObjectNameInfoEXT* pNameInfo) { 3635db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { 3645db71995Sopenharmony_ci VkPhysicalDevice pd = (VkPhysicalDevice)(uintptr_t)(pNameInfo->object); 3655db71995Sopenharmony_ci if (pd != icd.physical_devices.at(icd.lookup_device(dev).phys_dev_index).vk_physical_device.handle) 3665db71995Sopenharmony_ci return VK_ERROR_DEVICE_LOST; 3675db71995Sopenharmony_ci } 3685db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { 3695db71995Sopenharmony_ci if (pNameInfo->object != icd.surface_handles.at(0)) return VK_ERROR_DEVICE_LOST; 3705db71995Sopenharmony_ci } 3715db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT) { 3725db71995Sopenharmony_ci if (pNameInfo->object != (uint64_t)(uintptr_t)icd.instance_handle.handle) return VK_ERROR_DEVICE_LOST; 3735db71995Sopenharmony_ci } 3745db71995Sopenharmony_ci return VK_SUCCESS; 3755db71995Sopenharmony_ci} 3765db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdDebugMarkerBeginEXT(VkCommandBuffer, const VkDebugMarkerMarkerInfoEXT*) {} 3775db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdDebugMarkerEndEXT(VkCommandBuffer) {} 3785db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdDebugMarkerInsertEXT(VkCommandBuffer, const VkDebugMarkerMarkerInfoEXT*) {} 3795db71995Sopenharmony_ci 3805db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkSetDebugUtilsObjectNameEXT(VkDevice dev, const VkDebugUtilsObjectNameInfoEXT* pNameInfo) { 3815db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_OBJECT_TYPE_PHYSICAL_DEVICE) { 3825db71995Sopenharmony_ci VkPhysicalDevice pd = (VkPhysicalDevice)(uintptr_t)(pNameInfo->objectHandle); 3835db71995Sopenharmony_ci if (pd != icd.physical_devices.at(icd.lookup_device(dev).phys_dev_index).vk_physical_device.handle) 3845db71995Sopenharmony_ci return VK_ERROR_DEVICE_LOST; 3855db71995Sopenharmony_ci } 3865db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) { 3875db71995Sopenharmony_ci if (pNameInfo->objectHandle != icd.surface_handles.at(0)) return VK_ERROR_DEVICE_LOST; 3885db71995Sopenharmony_ci } 3895db71995Sopenharmony_ci if (pNameInfo && pNameInfo->objectType == VK_OBJECT_TYPE_INSTANCE) { 3905db71995Sopenharmony_ci if (pNameInfo->objectHandle != (uint64_t)(uintptr_t)icd.instance_handle.handle) return VK_ERROR_DEVICE_LOST; 3915db71995Sopenharmony_ci } 3925db71995Sopenharmony_ci return VK_SUCCESS; 3935db71995Sopenharmony_ci} 3945db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkSetDebugUtilsObjectTagEXT(VkDevice dev, const VkDebugUtilsObjectTagInfoEXT* pTagInfo) { 3955db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_OBJECT_TYPE_PHYSICAL_DEVICE) { 3965db71995Sopenharmony_ci VkPhysicalDevice pd = (VkPhysicalDevice)(uintptr_t)(pTagInfo->objectHandle); 3975db71995Sopenharmony_ci if (pd != icd.physical_devices.at(icd.lookup_device(dev).phys_dev_index).vk_physical_device.handle) 3985db71995Sopenharmony_ci return VK_ERROR_DEVICE_LOST; 3995db71995Sopenharmony_ci } 4005db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_OBJECT_TYPE_SURFACE_KHR) { 4015db71995Sopenharmony_ci if (pTagInfo->objectHandle != icd.surface_handles.at(0)) return VK_ERROR_DEVICE_LOST; 4025db71995Sopenharmony_ci } 4035db71995Sopenharmony_ci if (pTagInfo && pTagInfo->objectType == VK_OBJECT_TYPE_INSTANCE) { 4045db71995Sopenharmony_ci if (pTagInfo->objectHandle != (uint64_t)(uintptr_t)icd.instance_handle.handle) return VK_ERROR_DEVICE_LOST; 4055db71995Sopenharmony_ci } 4065db71995Sopenharmony_ci return VK_SUCCESS; 4075db71995Sopenharmony_ci} 4085db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkQueueBeginDebugUtilsLabelEXT(VkQueue, const VkDebugUtilsLabelEXT*) {} 4095db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkQueueEndDebugUtilsLabelEXT(VkQueue) {} 4105db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkQueueInsertDebugUtilsLabelEXT(VkQueue, const VkDebugUtilsLabelEXT*) {} 4115db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdBeginDebugUtilsLabelEXT(VkCommandBuffer, const VkDebugUtilsLabelEXT*) {} 4125db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer) {} 4135db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdInsertDebugUtilsLabelEXT(VkCommandBuffer, const VkDebugUtilsLabelEXT*) {} 4145db71995Sopenharmony_ci 4155db71995Sopenharmony_ci//// Physical Device functions //// 4165db71995Sopenharmony_ci 4175db71995Sopenharmony_ci// VK_SUCCESS,VK_INCOMPLETE 4185db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateDeviceLayerProperties(VkPhysicalDevice, uint32_t*, VkLayerProperties*) { 4195db71995Sopenharmony_ci assert(false && "ICD's don't contain layers???"); 4205db71995Sopenharmony_ci return VK_SUCCESS; 4215db71995Sopenharmony_ci} 4225db71995Sopenharmony_ci 4235db71995Sopenharmony_ci// VK_SUCCESS, VK_INCOMPLETE, VK_ERROR_LAYER_NOT_PRESENT 4245db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, 4255db71995Sopenharmony_ci uint32_t* pPropertyCount, 4265db71995Sopenharmony_ci VkExtensionProperties* pProperties) { 4275db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 4285db71995Sopenharmony_ci if (pLayerName != nullptr) { 4295db71995Sopenharmony_ci assert(false && "Drivers don't contain layers???"); 4305db71995Sopenharmony_ci return VK_SUCCESS; 4315db71995Sopenharmony_ci } else { // instance extensions 4325db71995Sopenharmony_ci return FillCountPtr(phys_dev.extensions, pPropertyCount, pProperties); 4335db71995Sopenharmony_ci } 4345db71995Sopenharmony_ci} 4355db71995Sopenharmony_ci 4365db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, 4375db71995Sopenharmony_ci uint32_t* pQueueFamilyPropertyCount, 4385db71995Sopenharmony_ci VkQueueFamilyProperties* pQueueFamilyProperties) { 4395db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 4405db71995Sopenharmony_ci FillCountPtr(phys_dev.queue_family_properties, pQueueFamilyPropertyCount, pQueueFamilyProperties); 4415db71995Sopenharmony_ci} 4425db71995Sopenharmony_ci 4435db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, 4445db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkDevice* pDevice) { 4455db71995Sopenharmony_ci // VK_SUCCESS 4465db71995Sopenharmony_ci auto found = std::find_if(icd.physical_devices.begin(), icd.physical_devices.end(), [physicalDevice](PhysicalDevice& phys_dev) { 4475db71995Sopenharmony_ci return phys_dev.vk_physical_device.handle == physicalDevice; 4485db71995Sopenharmony_ci }); 4495db71995Sopenharmony_ci if (found == icd.physical_devices.end()) return VK_ERROR_INITIALIZATION_FAILED; 4505db71995Sopenharmony_ci auto device_handle = DispatchableHandle<VkDevice>(); 4515db71995Sopenharmony_ci *pDevice = device_handle.handle; 4525db71995Sopenharmony_ci found->device_handles.push_back(device_handle.handle); 4535db71995Sopenharmony_ci found->device_create_infos.push_back(DeviceCreateInfo{pCreateInfo}); 4545db71995Sopenharmony_ci for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) { 4555db71995Sopenharmony_ci found->queue_handles.emplace_back(); 4565db71995Sopenharmony_ci } 4575db71995Sopenharmony_ci icd.device_handles.emplace_back(std::move(device_handle)); 4585db71995Sopenharmony_ci 4595db71995Sopenharmony_ci return VK_SUCCESS; 4605db71995Sopenharmony_ci} 4615db71995Sopenharmony_ci 4625db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroyDevice(VkDevice device, [[maybe_unused]] const VkAllocationCallbacks* pAllocator) { 4635db71995Sopenharmony_ci auto found = std::find(icd.device_handles.begin(), icd.device_handles.end(), device); 4645db71995Sopenharmony_ci if (found != icd.device_handles.end()) icd.device_handles.erase(found); 4655db71995Sopenharmony_ci auto fd = icd.lookup_device(device); 4665db71995Sopenharmony_ci if (!fd.found) return; 4675db71995Sopenharmony_ci auto& phys_dev = icd.physical_devices.at(fd.phys_dev_index); 4685db71995Sopenharmony_ci phys_dev.device_handles.erase(phys_dev.device_handles.begin() + fd.dev_index); 4695db71995Sopenharmony_ci phys_dev.device_create_infos.erase(phys_dev.device_create_infos.begin() + fd.dev_index); 4705db71995Sopenharmony_ci} 4715db71995Sopenharmony_ci 4725db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL generic_tool_props_function([[maybe_unused]] VkPhysicalDevice physicalDevice, uint32_t* pToolCount, 4735db71995Sopenharmony_ci VkPhysicalDeviceToolPropertiesEXT* pToolProperties) { 4745db71995Sopenharmony_ci if (icd.tooling_properties.size() == 0) { 4755db71995Sopenharmony_ci return VK_SUCCESS; 4765db71995Sopenharmony_ci } 4775db71995Sopenharmony_ci if (pToolProperties == nullptr && pToolCount != nullptr) { 4785db71995Sopenharmony_ci *pToolCount = static_cast<uint32_t>(icd.tooling_properties.size()); 4795db71995Sopenharmony_ci } else if (pToolCount != nullptr) { 4805db71995Sopenharmony_ci for (size_t i = 0; i < *pToolCount; i++) { 4815db71995Sopenharmony_ci if (i >= icd.tooling_properties.size()) { 4825db71995Sopenharmony_ci return VK_INCOMPLETE; 4835db71995Sopenharmony_ci } 4845db71995Sopenharmony_ci pToolProperties[i] = icd.tooling_properties[i]; 4855db71995Sopenharmony_ci } 4865db71995Sopenharmony_ci } 4875db71995Sopenharmony_ci return VK_SUCCESS; 4885db71995Sopenharmony_ci} 4895db71995Sopenharmony_ci 4905db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceToolPropertiesEXT(VkPhysicalDevice physicalDevice, uint32_t* pToolCount, 4915db71995Sopenharmony_ci VkPhysicalDeviceToolPropertiesEXT* pToolProperties) { 4925db71995Sopenharmony_ci return generic_tool_props_function(physicalDevice, pToolCount, pToolProperties); 4935db71995Sopenharmony_ci} 4945db71995Sopenharmony_ci 4955db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t* pToolCount, 4965db71995Sopenharmony_ci VkPhysicalDeviceToolPropertiesEXT* pToolProperties) { 4975db71995Sopenharmony_ci return generic_tool_props_function(physicalDevice, pToolCount, pToolProperties); 4985db71995Sopenharmony_ci} 4995db71995Sopenharmony_ci 5005db71995Sopenharmony_citemplate <typename T> 5015db71995Sopenharmony_ciT to_nondispatch_handle(uint64_t handle) { 5025db71995Sopenharmony_ci#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ 5035db71995Sopenharmony_ci defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) 5045db71995Sopenharmony_ci return reinterpret_cast<T>(handle); 5055db71995Sopenharmony_ci#else 5065db71995Sopenharmony_ci return handle; 5075db71995Sopenharmony_ci#endif 5085db71995Sopenharmony_ci} 5095db71995Sopenharmony_ci 5105db71995Sopenharmony_citemplate <typename T> 5115db71995Sopenharmony_ciuint64_t from_nondispatch_handle(T handle) { 5125db71995Sopenharmony_ci#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ 5135db71995Sopenharmony_ci defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) 5145db71995Sopenharmony_ci return reinterpret_cast<uint64_t>(handle); 5155db71995Sopenharmony_ci#else 5165db71995Sopenharmony_ci return handle; 5175db71995Sopenharmony_ci#endif 5185db71995Sopenharmony_ci} 5195db71995Sopenharmony_ci 5205db71995Sopenharmony_ci//// WSI //// 5215db71995Sopenharmony_citemplate <typename HandleType> 5225db71995Sopenharmony_civoid common_nondispatch_handle_creation(std::vector<uint64_t>& handles, HandleType* pHandle) { 5235db71995Sopenharmony_ci if (nullptr != pHandle) { 5245db71995Sopenharmony_ci if (handles.size() == 0) 5255db71995Sopenharmony_ci handles.push_back(800851234); 5265db71995Sopenharmony_ci else 5275db71995Sopenharmony_ci handles.push_back(handles.back() + 102030); 5285db71995Sopenharmony_ci *pHandle = to_nondispatch_handle<HandleType>(handles.back()); 5295db71995Sopenharmony_ci } 5305db71995Sopenharmony_ci} 5315db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_ANDROID_KHR) 5325db71995Sopenharmony_ci 5335db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, 5345db71995Sopenharmony_ci const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) { 5355db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 5365db71995Sopenharmony_ci return VK_SUCCESS; 5375db71995Sopenharmony_ci} 5385db71995Sopenharmony_ci#endif 5395db71995Sopenharmony_ci 5405db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_WIN32_KHR) 5415db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateWin32SurfaceKHR([[maybe_unused]] VkInstance instance, 5425db71995Sopenharmony_ci [[maybe_unused]] const VkWin32SurfaceCreateInfoKHR* pCreateInfo, 5435db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 5445db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 5455db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 5465db71995Sopenharmony_ci return VK_SUCCESS; 5475db71995Sopenharmony_ci} 5485db71995Sopenharmony_ci 5495db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice, uint32_t) { return VK_TRUE; } 5505db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_WIN32_KHR 5515db71995Sopenharmony_ci 5525db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_WAYLAND_KHR) 5535db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateWaylandSurfaceKHR([[maybe_unused]] VkInstance instance, 5545db71995Sopenharmony_ci [[maybe_unused]] const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, 5555db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 5565db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 5575db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 5585db71995Sopenharmony_ci return VK_SUCCESS; 5595db71995Sopenharmony_ci} 5605db71995Sopenharmony_ci 5615db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice, uint32_t, 5625db71995Sopenharmony_ci struct wl_display*) { 5635db71995Sopenharmony_ci return VK_TRUE; 5645db71995Sopenharmony_ci} 5655db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_WAYLAND_KHR 5665db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_XCB_KHR) 5675db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateXcbSurfaceKHR([[maybe_unused]] VkInstance instance, 5685db71995Sopenharmony_ci [[maybe_unused]] const VkXcbSurfaceCreateInfoKHR* pCreateInfo, 5695db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 5705db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 5715db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 5725db71995Sopenharmony_ci return VK_SUCCESS; 5735db71995Sopenharmony_ci} 5745db71995Sopenharmony_ci 5755db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice, uint32_t, xcb_connection_t*, 5765db71995Sopenharmony_ci xcb_visualid_t) { 5775db71995Sopenharmony_ci return VK_TRUE; 5785db71995Sopenharmony_ci} 5795db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_XCB_KHR 5805db71995Sopenharmony_ci 5815db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_XLIB_KHR) 5825db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateXlibSurfaceKHR([[maybe_unused]] VkInstance instance, 5835db71995Sopenharmony_ci [[maybe_unused]] const VkXlibSurfaceCreateInfoKHR* pCreateInfo, 5845db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 5855db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 5865db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 5875db71995Sopenharmony_ci return VK_SUCCESS; 5885db71995Sopenharmony_ci} 5895db71995Sopenharmony_ci 5905db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice, uint32_t, Display*, VisualID) { 5915db71995Sopenharmony_ci return VK_TRUE; 5925db71995Sopenharmony_ci} 5935db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_XLIB_KHR 5945db71995Sopenharmony_ci 5955db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_DIRECTFB_EXT) 5965db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDirectFBSurfaceEXT(VkInstance instance, 5975db71995Sopenharmony_ci const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, 5985db71995Sopenharmony_ci const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) { 5995db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6005db71995Sopenharmony_ci return VK_SUCCESS; 6015db71995Sopenharmony_ci} 6025db71995Sopenharmony_ci 6035db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceDirectFBPresentationSupportEXT(VkPhysicalDevice physicalDevice, 6045db71995Sopenharmony_ci uint32_t queueFamilyIndex, IDirectFB* dfb) { 6055db71995Sopenharmony_ci return VK_TRUE; 6065db71995Sopenharmony_ci} 6075db71995Sopenharmony_ci 6085db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_DIRECTFB_EXT 6095db71995Sopenharmony_ci 6105db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_MACOS_MVK) 6115db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMacOSSurfaceMVK([[maybe_unused]] VkInstance instance, 6125db71995Sopenharmony_ci [[maybe_unused]] const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, 6135db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 6145db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 6155db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6165db71995Sopenharmony_ci return VK_SUCCESS; 6175db71995Sopenharmony_ci} 6185db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_MACOS_MVK 6195db71995Sopenharmony_ci 6205db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_IOS_MVK) 6215db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateIOSSurfaceMVK([[maybe_unused]] VkInstance instance, 6225db71995Sopenharmony_ci [[maybe_unused]] const VkIOSSurfaceCreateInfoMVK* pCreateInfo, 6235db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 6245db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 6255db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6265db71995Sopenharmony_ci return VK_SUCCESS; 6275db71995Sopenharmony_ci} 6285db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_IOS_MVK 6295db71995Sopenharmony_ci 6305db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_GGP) 6315db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateStreamDescriptorSurfaceGGP(VkInstance instance, 6325db71995Sopenharmony_ci const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, 6335db71995Sopenharmony_ci const VkAllocationCallbacks* pAllocator, 6345db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 6355db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6365db71995Sopenharmony_ci return VK_SUCCESS; 6375db71995Sopenharmony_ci} 6385db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_GGP 6395db71995Sopenharmony_ci 6405db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_METAL_EXT) 6415db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateMetalSurfaceEXT([[maybe_unused]] VkInstance instance, 6425db71995Sopenharmony_ci [[maybe_unused]] const VkMetalSurfaceCreateInfoEXT* pCreateInfo, 6435db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 6445db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 6455db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6465db71995Sopenharmony_ci return VK_SUCCESS; 6475db71995Sopenharmony_ci} 6485db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_METAL_EXT 6495db71995Sopenharmony_ci 6505db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_SCREEN_QNX) 6515db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateScreenSurfaceQNX(VkInstance instance, const VkScreenSurfaceCreateInfoQNX* pCreateInfo, 6525db71995Sopenharmony_ci const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) { 6535db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6545db71995Sopenharmony_ci return VK_SUCCESS; 6555db71995Sopenharmony_ci} 6565db71995Sopenharmony_ci 6575db71995Sopenharmony_ciVKAPI_ATTR VkBool32 VKAPI_CALL test_vkGetPhysicalDeviceScreenPresentationSupportQNX(VkPhysicalDevice physicalDevice, 6585db71995Sopenharmony_ci uint32_t queueFamilyIndex, 6595db71995Sopenharmony_ci struct _screen_window* window) { 6605db71995Sopenharmony_ci return VK_TRUE; 6615db71995Sopenharmony_ci} 6625db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_SCREEN_QNX 6635db71995Sopenharmony_ci 6645db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateHeadlessSurfaceEXT([[maybe_unused]] VkInstance instance, 6655db71995Sopenharmony_ci [[maybe_unused]] const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo, 6665db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 6675db71995Sopenharmony_ci VkSurfaceKHR* pSurface) { 6685db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 6695db71995Sopenharmony_ci return VK_SUCCESS; 6705db71995Sopenharmony_ci} 6715db71995Sopenharmony_ci 6725db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroySurfaceKHR([[maybe_unused]] VkInstance instance, VkSurfaceKHR surface, 6735db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator) { 6745db71995Sopenharmony_ci if (surface != VK_NULL_HANDLE) { 6755db71995Sopenharmony_ci uint64_t fake_surf_handle = from_nondispatch_handle(surface); 6765db71995Sopenharmony_ci auto found_iter = std::find(icd.surface_handles.begin(), icd.surface_handles.end(), fake_surf_handle); 6775db71995Sopenharmony_ci if (found_iter != icd.surface_handles.end()) { 6785db71995Sopenharmony_ci // Remove it from the list 6795db71995Sopenharmony_ci icd.surface_handles.erase(found_iter); 6805db71995Sopenharmony_ci } else { 6815db71995Sopenharmony_ci assert(false && "Surface not found during destroy!"); 6825db71995Sopenharmony_ci } 6835db71995Sopenharmony_ci } 6845db71995Sopenharmony_ci} 6855db71995Sopenharmony_ci// VK_KHR_swapchain 6865db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateSwapchainKHR([[maybe_unused]] VkDevice device, 6875db71995Sopenharmony_ci [[maybe_unused]] const VkSwapchainCreateInfoKHR* pCreateInfo, 6885db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 6895db71995Sopenharmony_ci VkSwapchainKHR* pSwapchain) { 6905db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.swapchain_handles, pSwapchain); 6915db71995Sopenharmony_ci return VK_SUCCESS; 6925db71995Sopenharmony_ci} 6935db71995Sopenharmony_ci 6945db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetSwapchainImagesKHR([[maybe_unused]] VkDevice device, 6955db71995Sopenharmony_ci [[maybe_unused]] VkSwapchainKHR swapchain, 6965db71995Sopenharmony_ci uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) { 6975db71995Sopenharmony_ci std::vector<uint64_t> handles{123, 234, 345, 345, 456}; 6985db71995Sopenharmony_ci if (pSwapchainImages == nullptr) { 6995db71995Sopenharmony_ci if (pSwapchainImageCount) *pSwapchainImageCount = static_cast<uint32_t>(handles.size()); 7005db71995Sopenharmony_ci } else if (pSwapchainImageCount) { 7015db71995Sopenharmony_ci for (uint32_t i = 0; i < *pSwapchainImageCount && i < handles.size(); i++) { 7025db71995Sopenharmony_ci pSwapchainImages[i] = to_nondispatch_handle<VkImage>(handles.back()); 7035db71995Sopenharmony_ci } 7045db71995Sopenharmony_ci if (*pSwapchainImageCount < handles.size()) return VK_INCOMPLETE; 7055db71995Sopenharmony_ci } 7065db71995Sopenharmony_ci return VK_SUCCESS; 7075db71995Sopenharmony_ci} 7085db71995Sopenharmony_ci 7095db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroySwapchainKHR([[maybe_unused]] VkDevice device, VkSwapchainKHR swapchain, 7105db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator) { 7115db71995Sopenharmony_ci if (swapchain != VK_NULL_HANDLE) { 7125db71995Sopenharmony_ci uint64_t fake_swapchain_handle = from_nondispatch_handle(swapchain); 7135db71995Sopenharmony_ci auto found_iter = icd.swapchain_handles.erase( 7145db71995Sopenharmony_ci std::remove(icd.swapchain_handles.begin(), icd.swapchain_handles.end(), fake_swapchain_handle), 7155db71995Sopenharmony_ci icd.swapchain_handles.end()); 7165db71995Sopenharmony_ci if (!icd.swapchain_handles.empty() && found_iter == icd.swapchain_handles.end()) { 7175db71995Sopenharmony_ci assert(false && "Swapchain not found during destroy!"); 7185db71995Sopenharmony_ci } 7195db71995Sopenharmony_ci } 7205db71995Sopenharmony_ci} 7215db71995Sopenharmony_ci// VK_KHR_swapchain with 1.1 7225db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetDeviceGroupSurfacePresentModesKHR([[maybe_unused]] VkDevice device, 7235db71995Sopenharmony_ci [[maybe_unused]] VkSurfaceKHR surface, 7245db71995Sopenharmony_ci VkDeviceGroupPresentModeFlagsKHR* pModes) { 7255db71995Sopenharmony_ci if (!pModes) return VK_ERROR_INITIALIZATION_FAILED; 7265db71995Sopenharmony_ci *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR; 7275db71995Sopenharmony_ci return VK_SUCCESS; 7285db71995Sopenharmony_ci} 7295db71995Sopenharmony_ci 7305db71995Sopenharmony_ci// VK_KHR_surface 7315db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, 7325db71995Sopenharmony_ci VkSurfaceKHR surface, VkBool32* pSupported) { 7335db71995Sopenharmony_ci if (surface != VK_NULL_HANDLE) { 7345db71995Sopenharmony_ci uint64_t fake_surf_handle = (uint64_t)(surface); 7355db71995Sopenharmony_ci auto found_iter = std::find(icd.surface_handles.begin(), icd.surface_handles.end(), fake_surf_handle); 7365db71995Sopenharmony_ci if (found_iter == icd.surface_handles.end()) { 7375db71995Sopenharmony_ci assert(false && "Surface not found during GetPhysicalDeviceSurfaceSupportKHR query!"); 7385db71995Sopenharmony_ci return VK_ERROR_UNKNOWN; 7395db71995Sopenharmony_ci } 7405db71995Sopenharmony_ci } 7415db71995Sopenharmony_ci if (nullptr != pSupported) { 7425db71995Sopenharmony_ci *pSupported = icd.GetPhysDevice(physicalDevice).queue_family_properties.at(queueFamilyIndex).support_present; 7435db71995Sopenharmony_ci } 7445db71995Sopenharmony_ci return VK_SUCCESS; 7455db71995Sopenharmony_ci} 7465db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, 7475db71995Sopenharmony_ci VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) { 7485db71995Sopenharmony_ci if (surface != VK_NULL_HANDLE) { 7495db71995Sopenharmony_ci uint64_t fake_surf_handle = (uint64_t)(surface); 7505db71995Sopenharmony_ci auto found_iter = std::find(icd.surface_handles.begin(), icd.surface_handles.end(), fake_surf_handle); 7515db71995Sopenharmony_ci if (found_iter == icd.surface_handles.end()) { 7525db71995Sopenharmony_ci assert(false && "Surface not found during GetPhysicalDeviceSurfaceCapabilitiesKHR query!"); 7535db71995Sopenharmony_ci return VK_ERROR_UNKNOWN; 7545db71995Sopenharmony_ci } 7555db71995Sopenharmony_ci } 7565db71995Sopenharmony_ci if (nullptr != pSurfaceCapabilities) { 7575db71995Sopenharmony_ci *pSurfaceCapabilities = icd.GetPhysDevice(physicalDevice).surface_capabilities; 7585db71995Sopenharmony_ci } 7595db71995Sopenharmony_ci return VK_SUCCESS; 7605db71995Sopenharmony_ci} 7615db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, 7625db71995Sopenharmony_ci uint32_t* pSurfaceFormatCount, 7635db71995Sopenharmony_ci VkSurfaceFormatKHR* pSurfaceFormats) { 7645db71995Sopenharmony_ci if (surface != VK_NULL_HANDLE) { 7655db71995Sopenharmony_ci uint64_t fake_surf_handle = (uint64_t)(surface); 7665db71995Sopenharmony_ci auto found_iter = std::find(icd.surface_handles.begin(), icd.surface_handles.end(), fake_surf_handle); 7675db71995Sopenharmony_ci if (found_iter == icd.surface_handles.end()) { 7685db71995Sopenharmony_ci assert(false && "Surface not found during GetPhysicalDeviceSurfaceFormatsKHR query!"); 7695db71995Sopenharmony_ci return VK_ERROR_UNKNOWN; 7705db71995Sopenharmony_ci } 7715db71995Sopenharmony_ci } 7725db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).surface_formats, pSurfaceFormatCount, pSurfaceFormats); 7735db71995Sopenharmony_ci return VK_SUCCESS; 7745db71995Sopenharmony_ci} 7755db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, 7765db71995Sopenharmony_ci uint32_t* pPresentModeCount, 7775db71995Sopenharmony_ci VkPresentModeKHR* pPresentModes) { 7785db71995Sopenharmony_ci if (surface != VK_NULL_HANDLE) { 7795db71995Sopenharmony_ci uint64_t fake_surf_handle = (uint64_t)(surface); 7805db71995Sopenharmony_ci auto found_iter = std::find(icd.surface_handles.begin(), icd.surface_handles.end(), fake_surf_handle); 7815db71995Sopenharmony_ci if (found_iter == icd.surface_handles.end()) { 7825db71995Sopenharmony_ci assert(false && "Surface not found during GetPhysicalDeviceSurfacePresentModesKHR query!"); 7835db71995Sopenharmony_ci return VK_ERROR_UNKNOWN; 7845db71995Sopenharmony_ci } 7855db71995Sopenharmony_ci } 7865db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).surface_present_modes, pPresentModeCount, pPresentModes); 7875db71995Sopenharmony_ci return VK_SUCCESS; 7885db71995Sopenharmony_ci} 7895db71995Sopenharmony_ci 7905db71995Sopenharmony_ci// VK_KHR_display 7915db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, 7925db71995Sopenharmony_ci uint32_t* pPropertyCount, 7935db71995Sopenharmony_ci VkDisplayPropertiesKHR* pProperties) { 7945db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).display_properties, pPropertyCount, pProperties); 7955db71995Sopenharmony_ci return VK_SUCCESS; 7965db71995Sopenharmony_ci} 7975db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, 7985db71995Sopenharmony_ci uint32_t* pPropertyCount, 7995db71995Sopenharmony_ci VkDisplayPlanePropertiesKHR* pProperties) { 8005db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).display_plane_properties, pPropertyCount, pProperties); 8015db71995Sopenharmony_ci return VK_SUCCESS; 8025db71995Sopenharmony_ci} 8035db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, 8045db71995Sopenharmony_ci [[maybe_unused]] uint32_t planeIndex, 8055db71995Sopenharmony_ci uint32_t* pDisplayCount, VkDisplayKHR* pDisplays) { 8065db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).displays, pDisplayCount, pDisplays); 8075db71995Sopenharmony_ci return VK_SUCCESS; 8085db71995Sopenharmony_ci} 8095db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, 8105db71995Sopenharmony_ci [[maybe_unused]] VkDisplayKHR display, uint32_t* pPropertyCount, 8115db71995Sopenharmony_ci VkDisplayModePropertiesKHR* pProperties) { 8125db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).display_mode_properties, pPropertyCount, pProperties); 8135db71995Sopenharmony_ci return VK_SUCCESS; 8145db71995Sopenharmony_ci} 8155db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, [[maybe_unused]] VkDisplayKHR display, 8165db71995Sopenharmony_ci [[maybe_unused]] const VkDisplayModeCreateInfoKHR* pCreateInfo, 8175db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 8185db71995Sopenharmony_ci VkDisplayModeKHR* pMode) { 8195db71995Sopenharmony_ci if (nullptr != pMode) { 8205db71995Sopenharmony_ci *pMode = icd.GetPhysDevice(physicalDevice).display_mode; 8215db71995Sopenharmony_ci } 8225db71995Sopenharmony_ci return VK_SUCCESS; 8235db71995Sopenharmony_ci} 8245db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, 8255db71995Sopenharmony_ci [[maybe_unused]] VkDisplayModeKHR mode, 8265db71995Sopenharmony_ci [[maybe_unused]] uint32_t planeIndex, 8275db71995Sopenharmony_ci VkDisplayPlaneCapabilitiesKHR* pCapabilities) { 8285db71995Sopenharmony_ci if (nullptr != pCapabilities) { 8295db71995Sopenharmony_ci *pCapabilities = icd.GetPhysDevice(physicalDevice).display_plane_capabilities; 8305db71995Sopenharmony_ci } 8315db71995Sopenharmony_ci return VK_SUCCESS; 8325db71995Sopenharmony_ci} 8335db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateDisplayPlaneSurfaceKHR( 8345db71995Sopenharmony_ci [[maybe_unused]] VkInstance instance, [[maybe_unused]] const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, 8355db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) { 8365db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.surface_handles, pSurface); 8375db71995Sopenharmony_ci return VK_SUCCESS; 8385db71995Sopenharmony_ci} 8395db71995Sopenharmony_ci 8405db71995Sopenharmony_ci// VK_KHR_get_surface_capabilities2 8415db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, 8425db71995Sopenharmony_ci const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, 8435db71995Sopenharmony_ci VkSurfaceCapabilities2KHR* pSurfaceCapabilities) { 8445db71995Sopenharmony_ci if (nullptr != pSurfaceInfo && nullptr != pSurfaceCapabilities) { 8455db71995Sopenharmony_ci return test_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, pSurfaceInfo->surface, 8465db71995Sopenharmony_ci &pSurfaceCapabilities->surfaceCapabilities); 8475db71995Sopenharmony_ci } 8485db71995Sopenharmony_ci return VK_SUCCESS; 8495db71995Sopenharmony_ci} 8505db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, 8515db71995Sopenharmony_ci const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, 8525db71995Sopenharmony_ci uint32_t* pSurfaceFormatCount, 8535db71995Sopenharmony_ci VkSurfaceFormat2KHR* pSurfaceFormats) { 8545db71995Sopenharmony_ci if (nullptr != pSurfaceFormatCount) { 8555db71995Sopenharmony_ci test_vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, nullptr); 8565db71995Sopenharmony_ci if (nullptr != pSurfaceFormats) { 8575db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 8585db71995Sopenharmony_ci // Since the structures are different, we have to copy each item over seperately. Since we have multiple, we 8595db71995Sopenharmony_ci // have to manually copy the data here instead of calling the next function 8605db71995Sopenharmony_ci for (uint32_t cnt = 0; cnt < *pSurfaceFormatCount; ++cnt) { 8615db71995Sopenharmony_ci memcpy(&pSurfaceFormats[cnt].surfaceFormat, &phys_dev.surface_formats[cnt], sizeof(VkSurfaceFormatKHR)); 8625db71995Sopenharmony_ci } 8635db71995Sopenharmony_ci } 8645db71995Sopenharmony_ci } 8655db71995Sopenharmony_ci return VK_SUCCESS; 8665db71995Sopenharmony_ci} 8675db71995Sopenharmony_ci// VK_KHR_display_swapchain 8685db71995Sopenharmony_ciVkResult test_vkCreateSharedSwapchainsKHR([[maybe_unused]] VkDevice device, uint32_t swapchainCount, 8695db71995Sopenharmony_ci [[maybe_unused]] const VkSwapchainCreateInfoKHR* pCreateInfos, 8705db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains) { 8715db71995Sopenharmony_ci for (uint32_t i = 0; i < swapchainCount; i++) { 8725db71995Sopenharmony_ci common_nondispatch_handle_creation(icd.swapchain_handles, &pSwapchains[i]); 8735db71995Sopenharmony_ci } 8745db71995Sopenharmony_ci return VK_SUCCESS; 8755db71995Sopenharmony_ci} 8765db71995Sopenharmony_ci 8775db71995Sopenharmony_ci//// misc 8785db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkCreateCommandPool([[maybe_unused]] VkDevice device, 8795db71995Sopenharmony_ci [[maybe_unused]] const VkCommandPoolCreateInfo* pCreateInfo, 8805db71995Sopenharmony_ci [[maybe_unused]] const VkAllocationCallbacks* pAllocator, 8815db71995Sopenharmony_ci VkCommandPool* pCommandPool) { 8825db71995Sopenharmony_ci if (pCommandPool != nullptr) { 8835db71995Sopenharmony_ci pCommandPool = reinterpret_cast<VkCommandPool*>(0xdeadbeefdeadbeef); 8845db71995Sopenharmony_ci } 8855db71995Sopenharmony_ci return VK_SUCCESS; 8865db71995Sopenharmony_ci} 8875db71995Sopenharmony_ci 8885db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkDestroyCommandPool(VkDevice, VkCommandPool, const VkAllocationCallbacks*) { 8895db71995Sopenharmony_ci // do nothing, leak memory for now 8905db71995Sopenharmony_ci} 8915db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkAllocateCommandBuffers([[maybe_unused]] VkDevice device, 8925db71995Sopenharmony_ci const VkCommandBufferAllocateInfo* pAllocateInfo, 8935db71995Sopenharmony_ci VkCommandBuffer* pCommandBuffers) { 8945db71995Sopenharmony_ci if (pAllocateInfo != nullptr && pCommandBuffers != nullptr) { 8955db71995Sopenharmony_ci for (size_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { 8965db71995Sopenharmony_ci icd.allocated_command_buffers.push_back({}); 8975db71995Sopenharmony_ci pCommandBuffers[i] = icd.allocated_command_buffers.back().handle; 8985db71995Sopenharmony_ci } 8995db71995Sopenharmony_ci } 9005db71995Sopenharmony_ci return VK_SUCCESS; 9015db71995Sopenharmony_ci} 9025db71995Sopenharmony_ci 9035db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetDeviceQueue([[maybe_unused]] VkDevice device, [[maybe_unused]] uint32_t queueFamilyIndex, 9045db71995Sopenharmony_ci uint32_t queueIndex, VkQueue* pQueue) { 9055db71995Sopenharmony_ci auto fd = icd.lookup_device(device); 9065db71995Sopenharmony_ci if (fd.found) { 9075db71995Sopenharmony_ci *pQueue = icd.physical_devices.at(fd.phys_dev_index).queue_handles[queueIndex].handle; 9085db71995Sopenharmony_ci } 9095db71995Sopenharmony_ci} 9105db71995Sopenharmony_ci 9115db71995Sopenharmony_ci// VK_EXT_acquire_drm_display 9125db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkAcquireDrmDisplayEXT(VkPhysicalDevice, int32_t, VkDisplayKHR) { return VK_SUCCESS; } 9135db71995Sopenharmony_ci 9145db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetDrmDisplayEXT(VkPhysicalDevice physicalDevice, [[maybe_unused]] int32_t drmFd, 9155db71995Sopenharmony_ci [[maybe_unused]] uint32_t connectorId, VkDisplayKHR* display) { 9165db71995Sopenharmony_ci if (nullptr != display && icd.GetPhysDevice(physicalDevice).displays.size() > 0) { 9175db71995Sopenharmony_ci *display = icd.GetPhysDevice(physicalDevice).displays[0]; 9185db71995Sopenharmony_ci } 9195db71995Sopenharmony_ci return VK_SUCCESS; 9205db71995Sopenharmony_ci} 9215db71995Sopenharmony_ci 9225db71995Sopenharmony_ci//// stubs 9235db71995Sopenharmony_ci// 1.0 9245db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) { 9255db71995Sopenharmony_ci if (nullptr != pFeatures) { 9265db71995Sopenharmony_ci memcpy(pFeatures, &icd.GetPhysDevice(physicalDevice).features, sizeof(VkPhysicalDeviceFeatures)); 9275db71995Sopenharmony_ci } 9285db71995Sopenharmony_ci} 9295db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, 9305db71995Sopenharmony_ci VkPhysicalDeviceProperties* pProperties) { 9315db71995Sopenharmony_ci if (nullptr != pProperties) { 9325db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 9335db71995Sopenharmony_ci memcpy(pProperties, &phys_dev.properties, sizeof(VkPhysicalDeviceProperties)); 9345db71995Sopenharmony_ci size_t max_len = (phys_dev.deviceName.length() > VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) ? VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 9355db71995Sopenharmony_ci : phys_dev.deviceName.length(); 9365db71995Sopenharmony_ci std::copy(phys_dev.deviceName.c_str(), phys_dev.deviceName.c_str() + max_len, pProperties->deviceName); 9375db71995Sopenharmony_ci pProperties->deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1] = '\0'; 9385db71995Sopenharmony_ci } 9395db71995Sopenharmony_ci} 9405db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, 9415db71995Sopenharmony_ci VkPhysicalDeviceMemoryProperties* pMemoryProperties) { 9425db71995Sopenharmony_ci if (nullptr != pMemoryProperties) { 9435db71995Sopenharmony_ci memcpy(pMemoryProperties, &icd.GetPhysDevice(physicalDevice).memory_properties, sizeof(VkPhysicalDeviceMemoryProperties)); 9445db71995Sopenharmony_ci } 9455db71995Sopenharmony_ci} 9465db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceSparseImageFormatProperties( 9475db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, [[maybe_unused]] VkFormat format, [[maybe_unused]] VkImageType type, 9485db71995Sopenharmony_ci [[maybe_unused]] VkSampleCountFlagBits samples, [[maybe_unused]] VkImageUsageFlags usage, [[maybe_unused]] VkImageTiling tiling, 9495db71995Sopenharmony_ci uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties) { 9505db71995Sopenharmony_ci FillCountPtr(icd.GetPhysDevice(physicalDevice).sparse_image_format_properties, pPropertyCount, pProperties); 9515db71995Sopenharmony_ci} 9525db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, 9535db71995Sopenharmony_ci VkFormatProperties* pFormatProperties) { 9545db71995Sopenharmony_ci if (nullptr != pFormatProperties) { 9555db71995Sopenharmony_ci memcpy(pFormatProperties, &icd.GetPhysDevice(physicalDevice).format_properties[static_cast<uint32_t>(format)], 9565db71995Sopenharmony_ci sizeof(VkFormatProperties)); 9575db71995Sopenharmony_ci } 9585db71995Sopenharmony_ci} 9595db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceImageFormatProperties( 9605db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, [[maybe_unused]] VkFormat format, [[maybe_unused]] VkImageType type, 9615db71995Sopenharmony_ci [[maybe_unused]] VkImageTiling tiling, [[maybe_unused]] VkImageUsageFlags usage, [[maybe_unused]] VkImageCreateFlags flags, 9625db71995Sopenharmony_ci VkImageFormatProperties* pImageFormatProperties) { 9635db71995Sopenharmony_ci if (nullptr != pImageFormatProperties) { 9645db71995Sopenharmony_ci memcpy(pImageFormatProperties, &icd.GetPhysDevice(physicalDevice).image_format_properties, sizeof(VkImageFormatProperties)); 9655db71995Sopenharmony_ci } 9665db71995Sopenharmony_ci return VK_SUCCESS; 9675db71995Sopenharmony_ci} 9685db71995Sopenharmony_ci 9695db71995Sopenharmony_ci// 1.1 9705db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, 9715db71995Sopenharmony_ci VkPhysicalDeviceFeatures2* pFeatures) { 9725db71995Sopenharmony_ci if (nullptr != pFeatures) { 9735db71995Sopenharmony_ci test_vkGetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features); 9745db71995Sopenharmony_ci } 9755db71995Sopenharmony_ci} 9765db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, 9775db71995Sopenharmony_ci VkPhysicalDeviceProperties2* pProperties) { 9785db71995Sopenharmony_ci if (nullptr != pProperties) { 9795db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 9805db71995Sopenharmony_ci test_vkGetPhysicalDeviceProperties(physicalDevice, &pProperties->properties); 9815db71995Sopenharmony_ci VkBaseInStructure* pNext = reinterpret_cast<VkBaseInStructure*>(pProperties->pNext); 9825db71995Sopenharmony_ci while (pNext) { 9835db71995Sopenharmony_ci if (pNext->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT) { 9845db71995Sopenharmony_ci auto* bus_info = reinterpret_cast<VkPhysicalDevicePCIBusInfoPropertiesEXT*>(pNext); 9855db71995Sopenharmony_ci bus_info->pciBus = phys_dev.pci_bus; 9865db71995Sopenharmony_ci } 9875db71995Sopenharmony_ci if (pNext->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_DRIVER_PROPERTIES_MSFT) { 9885db71995Sopenharmony_ci auto* layered_driver_props = reinterpret_cast<VkPhysicalDeviceLayeredDriverPropertiesMSFT*>(pNext); 9895db71995Sopenharmony_ci layered_driver_props->underlyingAPI = phys_dev.layered_driver_underlying_api; 9905db71995Sopenharmony_ci } 9915db71995Sopenharmony_ci pNext = reinterpret_cast<VkBaseInStructure*>(const_cast<VkBaseInStructure*>(pNext->pNext)); 9925db71995Sopenharmony_ci } 9935db71995Sopenharmony_ci } 9945db71995Sopenharmony_ci} 9955db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, 9965db71995Sopenharmony_ci VkPhysicalDeviceMemoryProperties2* pMemoryProperties) { 9975db71995Sopenharmony_ci if (nullptr != pMemoryProperties) { 9985db71995Sopenharmony_ci test_vkGetPhysicalDeviceMemoryProperties(physicalDevice, &pMemoryProperties->memoryProperties); 9995db71995Sopenharmony_ci } 10005db71995Sopenharmony_ci} 10015db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, 10025db71995Sopenharmony_ci uint32_t* pQueueFamilyPropertyCount, 10035db71995Sopenharmony_ci VkQueueFamilyProperties2* pQueueFamilyProperties) { 10045db71995Sopenharmony_ci if (nullptr != pQueueFamilyPropertyCount) { 10055db71995Sopenharmony_ci test_vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, nullptr); 10065db71995Sopenharmony_ci if (nullptr != pQueueFamilyProperties) { 10075db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 10085db71995Sopenharmony_ci // Since the structures are different, we have to copy each item over seperately. Since we have multiple, we 10095db71995Sopenharmony_ci // have to manually copy the data here instead of calling the next function 10105db71995Sopenharmony_ci for (uint32_t queue = 0; queue < *pQueueFamilyPropertyCount; ++queue) { 10115db71995Sopenharmony_ci memcpy(&pQueueFamilyProperties[queue].queueFamilyProperties, &phys_dev.queue_family_properties[queue].properties, 10125db71995Sopenharmony_ci sizeof(VkQueueFamilyProperties)); 10135db71995Sopenharmony_ci } 10145db71995Sopenharmony_ci } 10155db71995Sopenharmony_ci } 10165db71995Sopenharmony_ci} 10175db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceSparseImageFormatProperties2( 10185db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, 10195db71995Sopenharmony_ci VkSparseImageFormatProperties2* pProperties) { 10205db71995Sopenharmony_ci if (nullptr != pPropertyCount) { 10215db71995Sopenharmony_ci test_vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, pFormatInfo->format, pFormatInfo->type, 10225db71995Sopenharmony_ci pFormatInfo->samples, pFormatInfo->usage, pFormatInfo->tiling, 10235db71995Sopenharmony_ci pPropertyCount, nullptr); 10245db71995Sopenharmony_ci if (nullptr != pProperties) { 10255db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 10265db71995Sopenharmony_ci // Since the structures are different, we have to copy each item over seperately. Since we have multiple, we 10275db71995Sopenharmony_ci // have to manually copy the data here instead of calling the next function 10285db71995Sopenharmony_ci for (uint32_t cnt = 0; cnt < *pPropertyCount; ++cnt) { 10295db71995Sopenharmony_ci memcpy(&pProperties[cnt].properties, &phys_dev.sparse_image_format_properties[cnt], 10305db71995Sopenharmony_ci sizeof(VkSparseImageFormatProperties)); 10315db71995Sopenharmony_ci } 10325db71995Sopenharmony_ci } 10335db71995Sopenharmony_ci } 10345db71995Sopenharmony_ci} 10355db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, 10365db71995Sopenharmony_ci VkFormatProperties2* pFormatProperties) { 10375db71995Sopenharmony_ci if (nullptr != pFormatProperties) { 10385db71995Sopenharmony_ci test_vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &pFormatProperties->formatProperties); 10395db71995Sopenharmony_ci } 10405db71995Sopenharmony_ci} 10415db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceImageFormatProperties2( 10425db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, 10435db71995Sopenharmony_ci VkImageFormatProperties2* pImageFormatProperties) { 10445db71995Sopenharmony_ci if (nullptr != pImageFormatInfo) { 10455db71995Sopenharmony_ci VkImageFormatProperties* ptr = nullptr; 10465db71995Sopenharmony_ci if (pImageFormatProperties) { 10475db71995Sopenharmony_ci ptr = &pImageFormatProperties->imageFormatProperties; 10485db71995Sopenharmony_ci } 10495db71995Sopenharmony_ci test_vkGetPhysicalDeviceImageFormatProperties(physicalDevice, pImageFormatInfo->format, pImageFormatInfo->type, 10505db71995Sopenharmony_ci pImageFormatInfo->tiling, pImageFormatInfo->usage, pImageFormatInfo->flags, 10515db71995Sopenharmony_ci ptr); 10525db71995Sopenharmony_ci } 10535db71995Sopenharmony_ci return VK_SUCCESS; 10545db71995Sopenharmony_ci} 10555db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceExternalBufferProperties( 10565db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, [[maybe_unused]] const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, 10575db71995Sopenharmony_ci VkExternalBufferProperties* pExternalBufferProperties) { 10585db71995Sopenharmony_ci if (nullptr != pExternalBufferProperties) { 10595db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 10605db71995Sopenharmony_ci memcpy(&pExternalBufferProperties->externalMemoryProperties, &phys_dev.external_memory_properties, 10615db71995Sopenharmony_ci sizeof(VkExternalMemoryProperties)); 10625db71995Sopenharmony_ci } 10635db71995Sopenharmony_ci} 10645db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceExternalSemaphoreProperties( 10655db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, [[maybe_unused]] const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, 10665db71995Sopenharmony_ci VkExternalSemaphoreProperties* pExternalSemaphoreProperties) { 10675db71995Sopenharmony_ci if (nullptr != pExternalSemaphoreProperties) { 10685db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 10695db71995Sopenharmony_ci memcpy(pExternalSemaphoreProperties, &phys_dev.external_semaphore_properties, sizeof(VkExternalSemaphoreProperties)); 10705db71995Sopenharmony_ci } 10715db71995Sopenharmony_ci} 10725db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceExternalFenceProperties( 10735db71995Sopenharmony_ci VkPhysicalDevice physicalDevice, [[maybe_unused]] const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, 10745db71995Sopenharmony_ci VkExternalFenceProperties* pExternalFenceProperties) { 10755db71995Sopenharmony_ci if (nullptr != pExternalFenceProperties) { 10765db71995Sopenharmony_ci auto& phys_dev = icd.GetPhysDevice(physicalDevice); 10775db71995Sopenharmony_ci memcpy(pExternalFenceProperties, &phys_dev.external_fence_properties, sizeof(VkExternalFenceProperties)); 10785db71995Sopenharmony_ci } 10795db71995Sopenharmony_ci} 10805db71995Sopenharmony_ci// Entry-points associated with the VK_KHR_performance_query extension 10815db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( 10825db71995Sopenharmony_ci VkPhysicalDevice, uint32_t, uint32_t*, VkPerformanceCounterKHR*, VkPerformanceCounterDescriptionKHR*) { 10835db71995Sopenharmony_ci return VK_SUCCESS; 10845db71995Sopenharmony_ci} 10855db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR(VkPhysicalDevice, 10865db71995Sopenharmony_ci const VkQueryPoolPerformanceCreateInfoKHR*, 10875db71995Sopenharmony_ci uint32_t*) {} 10885db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkAcquireProfilingLockKHR(VkDevice, const VkAcquireProfilingLockInfoKHR*) { return VK_SUCCESS; } 10895db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkReleaseProfilingLockKHR(VkDevice) {} 10905db71995Sopenharmony_ci// Entry-points associated with the VK_EXT_sample_locations extension 10915db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkCmdSetSampleLocationsEXT(VkCommandBuffer, const VkSampleLocationsInfoEXT*) {} 10925db71995Sopenharmony_ciVKAPI_ATTR void VKAPI_CALL test_vkGetPhysicalDeviceMultisamplePropertiesEXT(VkPhysicalDevice, VkSampleCountFlagBits, 10935db71995Sopenharmony_ci VkMultisamplePropertiesEXT*) {} 10945db71995Sopenharmony_ci// Entry-points associated with the VK_EXT_calibrated_timestamps extension 10955db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDevice, uint32_t*, VkTimeDomainEXT*) { 10965db71995Sopenharmony_ci return VK_SUCCESS; 10975db71995Sopenharmony_ci} 10985db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vkGetCalibratedTimestampsEXT(VkDevice, uint32_t, const VkCalibratedTimestampInfoEXT*, uint64_t*, 10995db71995Sopenharmony_ci uint64_t*) { 11005db71995Sopenharmony_ci return VK_SUCCESS; 11015db71995Sopenharmony_ci} 11025db71995Sopenharmony_ci 11035db71995Sopenharmony_ci#if defined(WIN32) 11045db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL test_vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, 11055db71995Sopenharmony_ci uint32_t* pPhysicalDeviceCount, 11065db71995Sopenharmony_ci VkPhysicalDevice* pPhysicalDevices) { 11075db71995Sopenharmony_ci if (adapterLUID.LowPart != icd.adapterLUID.LowPart || adapterLUID.HighPart != icd.adapterLUID.HighPart) { 11085db71995Sopenharmony_ci *pPhysicalDeviceCount = 0; 11095db71995Sopenharmony_ci return VK_ERROR_INCOMPATIBLE_DRIVER; 11105db71995Sopenharmony_ci } 11115db71995Sopenharmony_ci icd.called_enumerate_adapter_physical_devices = true; 11125db71995Sopenharmony_ci VkResult res = test_vkEnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); 11135db71995Sopenharmony_ci // For this testing, flip order intentionally 11145db71995Sopenharmony_ci if (nullptr != pPhysicalDevices) { 11155db71995Sopenharmony_ci std::reverse(pPhysicalDevices, pPhysicalDevices + *pPhysicalDeviceCount); 11165db71995Sopenharmony_ci } 11175db71995Sopenharmony_ci return res; 11185db71995Sopenharmony_ci} 11195db71995Sopenharmony_ci#endif // defined(WIN32) 11205db71995Sopenharmony_ci 11215db71995Sopenharmony_ciVkResult test_vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion) { 11225db71995Sopenharmony_ci if (icd.called_vk_icd_gipa == CalledICDGIPA::not_called && 11235db71995Sopenharmony_ci icd.called_negotiate_interface == CalledNegotiateInterface::not_called) 11245db71995Sopenharmony_ci icd.called_negotiate_interface = CalledNegotiateInterface::vk_icd_negotiate; 11255db71995Sopenharmony_ci else if (icd.called_vk_icd_gipa != CalledICDGIPA::not_called) 11265db71995Sopenharmony_ci icd.called_negotiate_interface = CalledNegotiateInterface::vk_icd_gipa_first; 11275db71995Sopenharmony_ci 11285db71995Sopenharmony_ci // loader puts the minimum it supports in pSupportedVersion, if that is lower than our minimum 11295db71995Sopenharmony_ci // If the ICD doesn't supports the interface version provided by the loader, report VK_ERROR_INCOMPATIBLE_DRIVER 11305db71995Sopenharmony_ci if (icd.min_icd_interface_version > *pSupportedVersion) { 11315db71995Sopenharmony_ci icd.interface_version_check = InterfaceVersionCheck::loader_version_too_old; 11325db71995Sopenharmony_ci *pSupportedVersion = icd.min_icd_interface_version; 11335db71995Sopenharmony_ci return VK_ERROR_INCOMPATIBLE_DRIVER; 11345db71995Sopenharmony_ci } 11355db71995Sopenharmony_ci 11365db71995Sopenharmony_ci // the loader-provided interface version is newer than that supported by the ICD 11375db71995Sopenharmony_ci if (icd.max_icd_interface_version < *pSupportedVersion) { 11385db71995Sopenharmony_ci icd.interface_version_check = InterfaceVersionCheck::loader_version_too_new; 11395db71995Sopenharmony_ci *pSupportedVersion = icd.max_icd_interface_version; 11405db71995Sopenharmony_ci } 11415db71995Sopenharmony_ci // ICD interface version is greater than the loader's, return the loader's version 11425db71995Sopenharmony_ci else if (icd.max_icd_interface_version > *pSupportedVersion) { 11435db71995Sopenharmony_ci icd.interface_version_check = InterfaceVersionCheck::icd_version_too_new; 11445db71995Sopenharmony_ci // don't change *pSupportedVersion 11455db71995Sopenharmony_ci } else { 11465db71995Sopenharmony_ci icd.interface_version_check = InterfaceVersionCheck::version_is_supported; 11475db71995Sopenharmony_ci *pSupportedVersion = icd.max_icd_interface_version; 11485db71995Sopenharmony_ci } 11495db71995Sopenharmony_ci 11505db71995Sopenharmony_ci return VK_SUCCESS; 11515db71995Sopenharmony_ci} 11525db71995Sopenharmony_ci 11535db71995Sopenharmony_ci// Forward declarations for trampolines 11545db71995Sopenharmony_ciextern "C" { 11555db71995Sopenharmony_ci#if TEST_ICD_EXPOSE_VERSION_7 11565db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion); 11575db71995Sopenharmony_ci#if TEST_ICD_EXPORT_ICD_GPDPA 11585db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName); 11595db71995Sopenharmony_ci#endif 11605db71995Sopenharmony_ci#if defined(WIN32) && TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES 11615db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, 11625db71995Sopenharmony_ci uint32_t* pPhysicalDeviceCount, 11635db71995Sopenharmony_ci VkPhysicalDevice* pPhysicalDevices); 11645db71995Sopenharmony_ci#endif 11655db71995Sopenharmony_ci#endif 11665db71995Sopenharmony_ci} 11675db71995Sopenharmony_ci 11685db71995Sopenharmony_ci//// trampolines 11695db71995Sopenharmony_ci 11705db71995Sopenharmony_ciPFN_vkVoidFunction get_instance_func_ver_1_1([[maybe_unused]] VkInstance instance, const char* pName) { 11715db71995Sopenharmony_ci if (icd.icd_api_version >= VK_API_VERSION_1_1) { 11725db71995Sopenharmony_ci if (string_eq(pName, "test_vkEnumerateInstanceVersion")) { 11735db71995Sopenharmony_ci return icd.can_query_vkEnumerateInstanceVersion ? to_vkVoidFunction(test_vkEnumerateInstanceVersion) : nullptr; 11745db71995Sopenharmony_ci } 11755db71995Sopenharmony_ci if (string_eq(pName, "vkEnumeratePhysicalDeviceGroups")) { 11765db71995Sopenharmony_ci return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceGroups); 11775db71995Sopenharmony_ci } 11785db71995Sopenharmony_ci } 11795db71995Sopenharmony_ci return nullptr; 11805db71995Sopenharmony_ci} 11815db71995Sopenharmony_ci 11825db71995Sopenharmony_ciPFN_vkVoidFunction get_physical_device_func_wsi([[maybe_unused]] VkInstance instance, const char* pName) { 11835db71995Sopenharmony_ci if (IsInstanceExtensionEnabled("VK_KHR_surface")) { 11845db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfaceSupportKHR")) 11855db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceSupportKHR); 11865db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR")) 11875db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceCapabilitiesKHR); 11885db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfaceFormatsKHR")) 11895db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceFormatsKHR); 11905db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfacePresentModesKHR")) 11915db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfacePresentModesKHR); 11925db71995Sopenharmony_ci } 11935db71995Sopenharmony_ci if (IsInstanceExtensionEnabled("VK_KHR_get_surface_capabilities2")) { 11945db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfaceCapabilities2KHR")) 11955db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceCapabilities2KHR); 11965db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSurfaceFormats2KHR")) 11975db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSurfaceFormats2KHR); 11985db71995Sopenharmony_ci } 11995db71995Sopenharmony_ci if (IsInstanceExtensionEnabled("VK_KHR_display")) { 12005db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceDisplayPropertiesKHR")) 12015db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceDisplayPropertiesKHR); 12025db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR")) 12035db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceDisplayPlanePropertiesKHR); 12045db71995Sopenharmony_ci if (string_eq(pName, "vkGetDisplayPlaneSupportedDisplaysKHR")) 12055db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetDisplayPlaneSupportedDisplaysKHR); 12065db71995Sopenharmony_ci if (string_eq(pName, "vkGetDisplayModePropertiesKHR")) return to_vkVoidFunction(test_vkGetDisplayModePropertiesKHR); 12075db71995Sopenharmony_ci if (string_eq(pName, "vkCreateDisplayModeKHR")) return to_vkVoidFunction(test_vkCreateDisplayModeKHR); 12085db71995Sopenharmony_ci if (string_eq(pName, "vkGetDisplayPlaneCapabilitiesKHR")) return to_vkVoidFunction(test_vkGetDisplayPlaneCapabilitiesKHR); 12095db71995Sopenharmony_ci if (string_eq(pName, "vkCreateDisplayPlaneSurfaceKHR")) return to_vkVoidFunction(test_vkCreateDisplayPlaneSurfaceKHR); 12105db71995Sopenharmony_ci } 12115db71995Sopenharmony_ci if (IsInstanceExtensionEnabled("VK_EXT_acquire_drm_display")) { 12125db71995Sopenharmony_ci if (string_eq(pName, "vkAcquireDrmDisplayEXT")) return to_vkVoidFunction(test_vkAcquireDrmDisplayEXT); 12135db71995Sopenharmony_ci if (string_eq(pName, "vkGetDrmDisplayEXT")) return to_vkVoidFunction(test_vkGetDrmDisplayEXT); 12145db71995Sopenharmony_ci } 12155db71995Sopenharmony_ci return nullptr; 12165db71995Sopenharmony_ci} 12175db71995Sopenharmony_ci 12185db71995Sopenharmony_ciPFN_vkVoidFunction get_instance_func_wsi(VkInstance instance, const char* pName) { 12195db71995Sopenharmony_ci if (icd.min_icd_interface_version >= 3 && icd.enable_icd_wsi == true) { 12205db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_ANDROID_KHR) 12215db71995Sopenharmony_ci if (string_eq(pName, "vkCreateAndroidSurfaceKHR")) { 12225db71995Sopenharmony_ci icd.is_using_icd_wsi = true; 12235db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateAndroidSurfaceKHR); 12245db71995Sopenharmony_ci } 12255db71995Sopenharmony_ci#endif 12265db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_METAL_EXT) 12275db71995Sopenharmony_ci if (string_eq(pName, "vkCreateMetalSurfaceEXT")) { 12285db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateMetalSurfaceEXT); 12295db71995Sopenharmony_ci } 12305db71995Sopenharmony_ci#endif 12315db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_WAYLAND_KHR) 12325db71995Sopenharmony_ci if (string_eq(pName, "vkCreateWaylandSurfaceKHR")) { 12335db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateWaylandSurfaceKHR); 12345db71995Sopenharmony_ci } 12355db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceWaylandPresentationSupportKHR")) { 12365db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceWaylandPresentationSupportKHR); 12375db71995Sopenharmony_ci } 12385db71995Sopenharmony_ci#endif 12395db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_XCB_KHR) 12405db71995Sopenharmony_ci if (string_eq(pName, "vkCreateXcbSurfaceKHR")) { 12415db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateXcbSurfaceKHR); 12425db71995Sopenharmony_ci } 12435db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceXcbPresentationSupportKHR")) { 12445db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceXcbPresentationSupportKHR); 12455db71995Sopenharmony_ci } 12465db71995Sopenharmony_ci#endif 12475db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_XLIB_KHR) 12485db71995Sopenharmony_ci if (string_eq(pName, "vkCreateXlibSurfaceKHR")) { 12495db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateXlibSurfaceKHR); 12505db71995Sopenharmony_ci } 12515db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceXlibPresentationSupportKHR")) { 12525db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceXlibPresentationSupportKHR); 12535db71995Sopenharmony_ci } 12545db71995Sopenharmony_ci#endif 12555db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_WIN32_KHR) 12565db71995Sopenharmony_ci if (string_eq(pName, "vkCreateWin32SurfaceKHR")) { 12575db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateWin32SurfaceKHR); 12585db71995Sopenharmony_ci } 12595db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceWin32PresentationSupportKHR")) { 12605db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceWin32PresentationSupportKHR); 12615db71995Sopenharmony_ci } 12625db71995Sopenharmony_ci#endif 12635db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_DIRECTFB_EXT) 12645db71995Sopenharmony_ci if (string_eq(pName, "vkCreateDirectFBSurfaceEXT")) { 12655db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateDirectFBSurfaceEXT); 12665db71995Sopenharmony_ci } 12675db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceDirectFBPresentationSupportEXT")) { 12685db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceDirectFBPresentationSupportEXT); 12695db71995Sopenharmony_ci } 12705db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_DIRECTFB_EXT 12715db71995Sopenharmony_ci 12725db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_MACOS_MVK) 12735db71995Sopenharmony_ci if (string_eq(pName, "vkCreateMacOSSurfaceMVK")) { 12745db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateMacOSSurfaceMVK); 12755db71995Sopenharmony_ci } 12765db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_MACOS_MVK 12775db71995Sopenharmony_ci 12785db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_IOS_MVK) 12795db71995Sopenharmony_ci if (string_eq(pName, "vkCreateIOSSurfaceMVK")) { 12805db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateIOSSurfaceMVK); 12815db71995Sopenharmony_ci } 12825db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_IOS_MVK 12835db71995Sopenharmony_ci 12845db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_GGP) 12855db71995Sopenharmony_ci if (string_eq(pName, "vkCreateStreamDescriptorSurfaceGGP")) { 12865db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateStreamDescriptorSurfaceGGP); 12875db71995Sopenharmony_ci } 12885db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_GGP 12895db71995Sopenharmony_ci 12905db71995Sopenharmony_ci#if defined(VK_USE_PLATFORM_SCREEN_QNX) 12915db71995Sopenharmony_ci if (string_eq(pName, "vkCreateScreenSurfaceQNX")) { 12925db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateScreenSurfaceQNX); 12935db71995Sopenharmony_ci } 12945db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceScreenPresentationSupportQNX")) { 12955db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceScreenPresentationSupportQNX); 12965db71995Sopenharmony_ci } 12975db71995Sopenharmony_ci#endif // VK_USE_PLATFORM_SCREEN_QNX 12985db71995Sopenharmony_ci 12995db71995Sopenharmony_ci if (string_eq(pName, "vkCreateHeadlessSurfaceEXT")) { 13005db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateHeadlessSurfaceEXT); 13015db71995Sopenharmony_ci } 13025db71995Sopenharmony_ci 13035db71995Sopenharmony_ci if (string_eq(pName, "vkDestroySurfaceKHR")) { 13045db71995Sopenharmony_ci icd.is_using_icd_wsi = true; 13055db71995Sopenharmony_ci return to_vkVoidFunction(test_vkDestroySurfaceKHR); 13065db71995Sopenharmony_ci } 13075db71995Sopenharmony_ci } 13085db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) { 13095db71995Sopenharmony_ci if (string_eq(pName, "vkCreateDebugUtilsMessengerEXT")) { 13105db71995Sopenharmony_ci return to_vkVoidFunction(test_vkCreateDebugUtilsMessengerEXT); 13115db71995Sopenharmony_ci } 13125db71995Sopenharmony_ci if (string_eq(pName, "vkDestroyDebugUtilsMessengerEXT")) { 13135db71995Sopenharmony_ci return to_vkVoidFunction(test_vkDestroyDebugUtilsMessengerEXT); 13145db71995Sopenharmony_ci } 13155db71995Sopenharmony_ci } 13165db71995Sopenharmony_ci 13175db71995Sopenharmony_ci PFN_vkVoidFunction ret_phys_dev_wsi = get_physical_device_func_wsi(instance, pName); 13185db71995Sopenharmony_ci if (ret_phys_dev_wsi != nullptr) return ret_phys_dev_wsi; 13195db71995Sopenharmony_ci return nullptr; 13205db71995Sopenharmony_ci} 13215db71995Sopenharmony_ciPFN_vkVoidFunction get_physical_device_func([[maybe_unused]] VkInstance instance, const char* pName) { 13225db71995Sopenharmony_ci if (string_eq(pName, "vkEnumerateDeviceLayerProperties")) return to_vkVoidFunction(test_vkEnumerateDeviceLayerProperties); 13235db71995Sopenharmony_ci if (string_eq(pName, "vkEnumerateDeviceExtensionProperties")) 13245db71995Sopenharmony_ci return to_vkVoidFunction(test_vkEnumerateDeviceExtensionProperties); 13255db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties")) 13265db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties); 13275db71995Sopenharmony_ci if (string_eq(pName, "vkCreateDevice")) return to_vkVoidFunction(test_vkCreateDevice); 13285db71995Sopenharmony_ci 13295db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFeatures")) 13305db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures) : nullptr; 13315db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceProperties")) 13325db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceProperties) : nullptr; 13335db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties")) 13345db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties) : nullptr; 13355db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties")) 13365db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties) 13375db71995Sopenharmony_ci : nullptr; 13385db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties")) 13395db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties) : nullptr; 13405db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties")) 13415db71995Sopenharmony_ci return icd.can_query_GetPhysicalDeviceFuncs ? to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties) : nullptr; 13425db71995Sopenharmony_ci 13435db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { 13445db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFeatures2KHR")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures2); 13455db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceProperties2KHR")) return to_vkVoidFunction(test_vkGetPhysicalDeviceProperties2); 13465db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties2KHR")) 13475db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties2); 13485db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties2KHR")) 13495db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties2); 13505db71995Sopenharmony_ci 13515db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties2KHR")) 13525db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties2); 13535db71995Sopenharmony_ci 13545db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR")) 13555db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties2); 13565db71995Sopenharmony_ci 13575db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties2KHR")) { 13585db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties2); 13595db71995Sopenharmony_ci } 13605db71995Sopenharmony_ci } 13615db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME)) { 13625db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalBufferPropertiesKHR")) 13635db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalBufferProperties); 13645db71995Sopenharmony_ci } 13655db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME)) { 13665db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR")) 13675db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalSemaphoreProperties); 13685db71995Sopenharmony_ci } 13695db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME)) { 13705db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalFencePropertiesKHR")) 13715db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalFenceProperties); 13725db71995Sopenharmony_ci } 13735db71995Sopenharmony_ci 13745db71995Sopenharmony_ci // The following physical device extensions only need 1 device to support them for the ICD to export 13755db71995Sopenharmony_ci // them 13765db71995Sopenharmony_ci if (IsPhysicalDeviceExtensionAvailable(VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME)) { 13775db71995Sopenharmony_ci if (string_eq(pName, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR")) 13785db71995Sopenharmony_ci return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR); 13795db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR")) 13805db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR); 13815db71995Sopenharmony_ci if (string_eq(pName, "vkAcquireProfilingLockKHR")) return to_vkVoidFunction(test_vkAcquireProfilingLockKHR); 13825db71995Sopenharmony_ci if (string_eq(pName, "vkReleaseProfilingLockKHR")) return to_vkVoidFunction(test_vkReleaseProfilingLockKHR); 13835db71995Sopenharmony_ci } 13845db71995Sopenharmony_ci if (IsPhysicalDeviceExtensionAvailable(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME)) { 13855db71995Sopenharmony_ci if (string_eq(pName, "vkCmdSetSampleLocationsEXT")) return to_vkVoidFunction(test_vkCmdSetSampleLocationsEXT); 13865db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceMultisamplePropertiesEXT")) 13875db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceMultisamplePropertiesEXT); 13885db71995Sopenharmony_ci } 13895db71995Sopenharmony_ci if (IsPhysicalDeviceExtensionAvailable(VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME)) { 13905db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT")) 13915db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT); 13925db71995Sopenharmony_ci if (string_eq(pName, "vkGetCalibratedTimestampsEXT")) return to_vkVoidFunction(test_vkGetCalibratedTimestampsEXT); 13935db71995Sopenharmony_ci } 13945db71995Sopenharmony_ci 13955db71995Sopenharmony_ci if (icd.icd_api_version >= VK_MAKE_API_VERSION(0, 1, 1, 0)) { 13965db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFeatures2")) return to_vkVoidFunction(test_vkGetPhysicalDeviceFeatures2); 13975db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceProperties2")) return to_vkVoidFunction(test_vkGetPhysicalDeviceProperties2); 13985db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceFormatProperties2")) 13995db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceFormatProperties2); 14005db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceMemoryProperties2")) 14015db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceMemoryProperties2); 14025db71995Sopenharmony_ci 14035db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceQueueFamilyProperties2")) 14045db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceQueueFamilyProperties2); 14055db71995Sopenharmony_ci 14065db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceSparseImageFormatProperties2")) 14075db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceSparseImageFormatProperties2); 14085db71995Sopenharmony_ci 14095db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceImageFormatProperties2")) { 14105db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceImageFormatProperties2); 14115db71995Sopenharmony_ci } 14125db71995Sopenharmony_ci 14135db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalBufferProperties")) 14145db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalBufferProperties); 14155db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalSemaphoreProperties")) 14165db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalSemaphoreProperties); 14175db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceExternalFenceProperties")) 14185db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceExternalFenceProperties); 14195db71995Sopenharmony_ci } 14205db71995Sopenharmony_ci 14215db71995Sopenharmony_ci if (icd.supports_tooling_info_core) { 14225db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceToolProperties")) return to_vkVoidFunction(test_vkGetPhysicalDeviceToolProperties); 14235db71995Sopenharmony_ci } 14245db71995Sopenharmony_ci if (icd.supports_tooling_info_ext) { 14255db71995Sopenharmony_ci if (string_eq(pName, "vkGetPhysicalDeviceToolPropertiesEXT")) 14265db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetPhysicalDeviceToolPropertiesEXT); 14275db71995Sopenharmony_ci } 14285db71995Sopenharmony_ci 14295db71995Sopenharmony_ci for (auto& phys_dev : icd.physical_devices) { 14305db71995Sopenharmony_ci for (auto& func : phys_dev.custom_physical_device_functions) { 14315db71995Sopenharmony_ci if (func.name == pName) { 14325db71995Sopenharmony_ci return to_vkVoidFunction(func.function); 14335db71995Sopenharmony_ci } 14345db71995Sopenharmony_ci } 14355db71995Sopenharmony_ci } 14365db71995Sopenharmony_ci return nullptr; 14375db71995Sopenharmony_ci} 14385db71995Sopenharmony_ci 14395db71995Sopenharmony_ciPFN_vkVoidFunction get_instance_func(VkInstance instance, const char* pName) { 14405db71995Sopenharmony_ci if (string_eq(pName, "vkDestroyInstance")) return to_vkVoidFunction(test_vkDestroyInstance); 14415db71995Sopenharmony_ci if (string_eq(pName, "vkEnumeratePhysicalDevices")) return to_vkVoidFunction(test_vkEnumeratePhysicalDevices); 14425db71995Sopenharmony_ci 14435db71995Sopenharmony_ci if (IsInstanceExtensionEnabled(VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME)) { 14445db71995Sopenharmony_ci if (string_eq(pName, "vkEnumeratePhysicalDeviceGroupsKHR")) return to_vkVoidFunction(test_vkEnumeratePhysicalDeviceGroups); 14455db71995Sopenharmony_ci } 14465db71995Sopenharmony_ci 14475db71995Sopenharmony_ci PFN_vkVoidFunction ret_phys_dev = get_physical_device_func(instance, pName); 14485db71995Sopenharmony_ci if (ret_phys_dev != nullptr) return ret_phys_dev; 14495db71995Sopenharmony_ci 14505db71995Sopenharmony_ci PFN_vkVoidFunction ret_1_1 = get_instance_func_ver_1_1(instance, pName); 14515db71995Sopenharmony_ci if (ret_1_1 != nullptr) return ret_1_1; 14525db71995Sopenharmony_ci 14535db71995Sopenharmony_ci PFN_vkVoidFunction ret_wsi = get_instance_func_wsi(instance, pName); 14545db71995Sopenharmony_ci if (ret_wsi != nullptr) return ret_wsi; 14555db71995Sopenharmony_ci 14565db71995Sopenharmony_ci for (auto& func : icd.custom_instance_functions) { 14575db71995Sopenharmony_ci if (func.name == pName) { 14585db71995Sopenharmony_ci return to_vkVoidFunction(func.function); 14595db71995Sopenharmony_ci } 14605db71995Sopenharmony_ci } 14615db71995Sopenharmony_ci 14625db71995Sopenharmony_ci return nullptr; 14635db71995Sopenharmony_ci} 14645db71995Sopenharmony_ci 14655db71995Sopenharmony_cibool should_check(std::vector<const char*> const& exts, VkDevice device, const char* ext_name) { 14665db71995Sopenharmony_ci if (device == NULL) return true; // always look if device is NULL 14675db71995Sopenharmony_ci for (auto const& ext : exts) { 14685db71995Sopenharmony_ci if (string_eq(ext, ext_name)) { 14695db71995Sopenharmony_ci return true; 14705db71995Sopenharmony_ci } 14715db71995Sopenharmony_ci } 14725db71995Sopenharmony_ci return false; 14735db71995Sopenharmony_ci} 14745db71995Sopenharmony_ci 14755db71995Sopenharmony_ciPFN_vkVoidFunction get_device_func(VkDevice device, const char* pName) { 14765db71995Sopenharmony_ci TestICD::FindDevice fd{}; 14775db71995Sopenharmony_ci DeviceCreateInfo create_info{}; 14785db71995Sopenharmony_ci if (device != nullptr) { 14795db71995Sopenharmony_ci fd = icd.lookup_device(device); 14805db71995Sopenharmony_ci if (!fd.found) return NULL; 14815db71995Sopenharmony_ci create_info = icd.physical_devices.at(fd.phys_dev_index).device_create_infos.at(fd.dev_index); 14825db71995Sopenharmony_ci } 14835db71995Sopenharmony_ci if (string_eq(pName, "vkCreateCommandPool")) return to_vkVoidFunction(test_vkCreateCommandPool); 14845db71995Sopenharmony_ci if (string_eq(pName, "vkAllocateCommandBuffers")) return to_vkVoidFunction(test_vkAllocateCommandBuffers); 14855db71995Sopenharmony_ci if (string_eq(pName, "vkDestroyCommandPool")) return to_vkVoidFunction(test_vkDestroyCommandPool); 14865db71995Sopenharmony_ci if (string_eq(pName, "vkGetDeviceQueue")) return to_vkVoidFunction(test_vkGetDeviceQueue); 14875db71995Sopenharmony_ci if (string_eq(pName, "vkDestroyDevice")) return to_vkVoidFunction(test_vkDestroyDevice); 14885db71995Sopenharmony_ci if (should_check(create_info.enabled_extensions, device, "VK_KHR_swapchain")) { 14895db71995Sopenharmony_ci if (string_eq(pName, "vkCreateSwapchainKHR")) return to_vkVoidFunction(test_vkCreateSwapchainKHR); 14905db71995Sopenharmony_ci if (string_eq(pName, "vkGetSwapchainImagesKHR")) return to_vkVoidFunction(test_vkGetSwapchainImagesKHR); 14915db71995Sopenharmony_ci if (string_eq(pName, "vkDestroySwapchainKHR")) return to_vkVoidFunction(test_vkDestroySwapchainKHR); 14925db71995Sopenharmony_ci 14935db71995Sopenharmony_ci if (icd.icd_api_version >= VK_API_VERSION_1_1 && string_eq(pName, "vkGetDeviceGroupSurfacePresentModesKHR")) 14945db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetDeviceGroupSurfacePresentModesKHR); 14955db71995Sopenharmony_ci } 14965db71995Sopenharmony_ci if (should_check(create_info.enabled_extensions, device, "VK_KHR_display_swapchain")) { 14975db71995Sopenharmony_ci if (string_eq(pName, "vkCreateSharedSwapchainsKHR")) return to_vkVoidFunction(test_vkCreateSharedSwapchainsKHR); 14985db71995Sopenharmony_ci } 14995db71995Sopenharmony_ci if (should_check(create_info.enabled_extensions, device, "VK_KHR_device_group")) { 15005db71995Sopenharmony_ci if (string_eq(pName, "vkGetDeviceGroupSurfacePresentModesKHR")) 15015db71995Sopenharmony_ci return to_vkVoidFunction(test_vkGetDeviceGroupSurfacePresentModesKHR); 15025db71995Sopenharmony_ci } 15035db71995Sopenharmony_ci if (should_check(create_info.enabled_extensions, device, "VK_EXT_debug_marker")) { 15045db71995Sopenharmony_ci if (string_eq(pName, "vkDebugMarkerSetObjectTagEXT")) return to_vkVoidFunction(test_vkDebugMarkerSetObjectTagEXT); 15055db71995Sopenharmony_ci if (string_eq(pName, "vkDebugMarkerSetObjectNameEXT")) return to_vkVoidFunction(test_vkDebugMarkerSetObjectNameEXT); 15065db71995Sopenharmony_ci if (string_eq(pName, "vkCmdDebugMarkerBeginEXT")) return to_vkVoidFunction(test_vkCmdDebugMarkerBeginEXT); 15075db71995Sopenharmony_ci if (string_eq(pName, "vkCmdDebugMarkerEndEXT")) return to_vkVoidFunction(test_vkCmdDebugMarkerEndEXT); 15085db71995Sopenharmony_ci if (string_eq(pName, "vkCmdDebugMarkerInsertEXT")) return to_vkVoidFunction(test_vkCmdDebugMarkerInsertEXT); 15095db71995Sopenharmony_ci } 15105db71995Sopenharmony_ci if (IsInstanceExtensionEnabled("VK_EXT_debug_utils")) { 15115db71995Sopenharmony_ci if (string_eq(pName, "vkSetDebugUtilsObjectNameEXT")) return to_vkVoidFunction(test_vkSetDebugUtilsObjectNameEXT); 15125db71995Sopenharmony_ci if (string_eq(pName, "vkSetDebugUtilsObjectTagEXT")) return to_vkVoidFunction(test_vkSetDebugUtilsObjectTagEXT); 15135db71995Sopenharmony_ci if (string_eq(pName, "vkQueueBeginDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkQueueBeginDebugUtilsLabelEXT); 15145db71995Sopenharmony_ci if (string_eq(pName, "vkQueueEndDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkQueueEndDebugUtilsLabelEXT); 15155db71995Sopenharmony_ci if (string_eq(pName, "vkQueueInsertDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkQueueInsertDebugUtilsLabelEXT); 15165db71995Sopenharmony_ci if (string_eq(pName, "vkCmdBeginDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkCmdBeginDebugUtilsLabelEXT); 15175db71995Sopenharmony_ci if (string_eq(pName, "vkCmdEndDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkCmdEndDebugUtilsLabelEXT); 15185db71995Sopenharmony_ci if (string_eq(pName, "vkCmdInsertDebugUtilsLabelEXT")) return to_vkVoidFunction(test_vkCmdInsertDebugUtilsLabelEXT); 15195db71995Sopenharmony_ci } 15205db71995Sopenharmony_ci // look for device functions setup from a test 15215db71995Sopenharmony_ci for (const auto& phys_dev : icd.physical_devices) { 15225db71995Sopenharmony_ci for (const auto& function : phys_dev.known_device_functions) { 15235db71995Sopenharmony_ci if (function.name == pName) { 15245db71995Sopenharmony_ci return to_vkVoidFunction(function.function); 15255db71995Sopenharmony_ci } 15265db71995Sopenharmony_ci } 15275db71995Sopenharmony_ci } 15285db71995Sopenharmony_ci return nullptr; 15295db71995Sopenharmony_ci} 15305db71995Sopenharmony_ci 15315db71995Sopenharmony_ciVKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL test_vkGetInstanceProcAddr(VkInstance instance, const char* pName) { 15325db71995Sopenharmony_ci return get_instance_func(instance, pName); 15335db71995Sopenharmony_ci} 15345db71995Sopenharmony_ci 15355db71995Sopenharmony_ciVKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL test_vkGetDeviceProcAddr(VkDevice device, const char* pName) { 15365db71995Sopenharmony_ci return get_device_func(device, pName); 15375db71995Sopenharmony_ci} 15385db71995Sopenharmony_ci 15395db71995Sopenharmony_ciPFN_vkVoidFunction base_get_instance_proc_addr(VkInstance instance, const char* pName) { 15405db71995Sopenharmony_ci if (pName == nullptr) return nullptr; 15415db71995Sopenharmony_ci if (instance == NULL) { 15425db71995Sopenharmony_ci#if TEST_ICD_EXPOSE_VERSION_7 15435db71995Sopenharmony_ci if (string_eq(pName, "vk_icdNegotiateLoaderICDInterfaceVersion")) 15445db71995Sopenharmony_ci return icd.exposes_vk_icdNegotiateLoaderICDInterfaceVersion 15455db71995Sopenharmony_ci ? to_vkVoidFunction(vk_icdNegotiateLoaderICDInterfaceVersion) 15465db71995Sopenharmony_ci : NULL; 15475db71995Sopenharmony_ci#if TEST_ICD_EXPORT_ICD_GPDPA 15485db71995Sopenharmony_ci if (string_eq(pName, "vk_icdGetPhysicalDeviceProcAddr")) 15495db71995Sopenharmony_ci return icd.exposes_vk_icdGetPhysicalDeviceProcAddr ? to_vkVoidFunction(vk_icdGetPhysicalDeviceProcAddr) : NULL; 15505db71995Sopenharmony_ci#endif 15515db71995Sopenharmony_ci#if defined(WIN32) && TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES 15525db71995Sopenharmony_ci if (string_eq(pName, "vk_icdEnumerateAdapterPhysicalDevices")) 15535db71995Sopenharmony_ci return icd.exposes_vk_icdEnumerateAdapterPhysicalDevices ? to_vkVoidFunction(vk_icdEnumerateAdapterPhysicalDevices) 15545db71995Sopenharmony_ci : NULL; 15555db71995Sopenharmony_ci#endif // defined(WIN32) 15565db71995Sopenharmony_ci#endif // TEST_ICD_EXPOSE_VERSION_7 15575db71995Sopenharmony_ci 15585db71995Sopenharmony_ci if (string_eq(pName, "vkGetInstanceProcAddr")) return to_vkVoidFunction(test_vkGetInstanceProcAddr); 15595db71995Sopenharmony_ci if (string_eq(pName, "vkEnumerateInstanceExtensionProperties")) 15605db71995Sopenharmony_ci return icd.exposes_vkEnumerateInstanceExtensionProperties 15615db71995Sopenharmony_ci ? to_vkVoidFunction(test_vkEnumerateInstanceExtensionProperties) 15625db71995Sopenharmony_ci : NULL; 15635db71995Sopenharmony_ci if (string_eq(pName, "vkEnumerateInstanceLayerProperties")) 15645db71995Sopenharmony_ci return to_vkVoidFunction(test_vkEnumerateInstanceLayerProperties); 15655db71995Sopenharmony_ci if (string_eq(pName, "vkEnumerateInstanceVersion")) 15665db71995Sopenharmony_ci return icd.can_query_vkEnumerateInstanceVersion ? to_vkVoidFunction(test_vkEnumerateInstanceVersion) : nullptr; 15675db71995Sopenharmony_ci if (string_eq(pName, "vkCreateInstance")) return to_vkVoidFunction(test_vkCreateInstance); 15685db71995Sopenharmony_ci } 15695db71995Sopenharmony_ci if (string_eq(pName, "vkGetDeviceProcAddr")) return to_vkVoidFunction(test_vkGetDeviceProcAddr); 15705db71995Sopenharmony_ci 15715db71995Sopenharmony_ci auto instance_func_return = get_instance_func(instance, pName); 15725db71995Sopenharmony_ci if (instance_func_return != nullptr) return instance_func_return; 15735db71995Sopenharmony_ci 15745db71995Sopenharmony_ci // Need to return function pointers for device extensions 15755db71995Sopenharmony_ci auto device_func_return = get_device_func(nullptr, pName); 15765db71995Sopenharmony_ci if (device_func_return != nullptr) return device_func_return; 15775db71995Sopenharmony_ci return nullptr; 15785db71995Sopenharmony_ci} 15795db71995Sopenharmony_ci 15805db71995Sopenharmony_ci// Exported functions 15815db71995Sopenharmony_ciextern "C" { 15825db71995Sopenharmony_ci#if TEST_ICD_EXPORT_NEGOTIATE_INTERFACE_VERSION 15835db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion) { 15845db71995Sopenharmony_ci return test_vk_icdNegotiateLoaderICDInterfaceVersion(pSupportedVersion); 15855db71995Sopenharmony_ci} 15865db71995Sopenharmony_ci#endif // TEST_ICD_EXPORT_NEGOTIATE_INTERFACE_VERSION 15875db71995Sopenharmony_ci 15885db71995Sopenharmony_ci#if TEST_ICD_EXPORT_ICD_GPDPA 15895db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName) { 15905db71995Sopenharmony_ci return get_physical_device_func(instance, pName); 15915db71995Sopenharmony_ci} 15925db71995Sopenharmony_ci#endif // TEST_ICD_EXPORT_ICD_GPDPA 15935db71995Sopenharmony_ci 15945db71995Sopenharmony_ci#if TEST_ICD_EXPORT_ICD_GIPA 15955db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName) { 15965db71995Sopenharmony_ci if (icd.called_vk_icd_gipa == CalledICDGIPA::not_called) icd.called_vk_icd_gipa = CalledICDGIPA::vk_icd_gipa; 15975db71995Sopenharmony_ci return base_get_instance_proc_addr(instance, pName); 15985db71995Sopenharmony_ci} 15995db71995Sopenharmony_ci#else // !TEST_ICD_EXPORT_ICD_GIPA 16005db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName) { 16015db71995Sopenharmony_ci if (icd.called_vk_icd_gipa == CalledICDGIPA::not_called) icd.called_vk_icd_gipa = CalledICDGIPA::vk_gipa; 16025db71995Sopenharmony_ci return base_get_instance_proc_addr(instance, pName); 16035db71995Sopenharmony_ci} 16045db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, 16055db71995Sopenharmony_ci const VkAllocationCallbacks* pAllocator, VkInstance* pInstance) { 16065db71995Sopenharmony_ci return test_vkCreateInstance(pCreateInfo, pAllocator, pInstance); 16075db71995Sopenharmony_ci} 16085db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char* pLayerName, 16095db71995Sopenharmony_ci uint32_t* pPropertyCount, 16105db71995Sopenharmony_ci VkExtensionProperties* pProperties) { 16115db71995Sopenharmony_ci return test_vkEnumerateInstanceExtensionProperties(pLayerName, pPropertyCount, pProperties); 16125db71995Sopenharmony_ci} 16135db71995Sopenharmony_ci#endif // TEST_ICD_EXPORT_ICD_GIPA 16145db71995Sopenharmony_ci 16155db71995Sopenharmony_ci#if TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES 16165db71995Sopenharmony_ci#if defined(WIN32) 16175db71995Sopenharmony_ciFRAMEWORK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, 16185db71995Sopenharmony_ci uint32_t* pPhysicalDeviceCount, 16195db71995Sopenharmony_ci VkPhysicalDevice* pPhysicalDevices) { 16205db71995Sopenharmony_ci return test_vk_icdEnumerateAdapterPhysicalDevices(instance, adapterLUID, pPhysicalDeviceCount, pPhysicalDevices); 16215db71995Sopenharmony_ci} 16225db71995Sopenharmony_ci#endif // defined(WIN32) 16235db71995Sopenharmony_ci#endif // TEST_ICD_EXPORT_ICD_ENUMERATE_ADAPTER_PHYSICAL_DEVICES 16245db71995Sopenharmony_ci 16255db71995Sopenharmony_ci} // extern "C" 1626