| 190 | } |
| 191 | |
| 192 | VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, |
| 193 | VkInstance* pInstance) { |
| 194 | atexit(ApplicationAtExit); |
| 195 | |
| 196 | VVL_ZoneScoped; |
| 197 | VkLayerInstanceCreateInfo* chain_info = GetChainInfo(pCreateInfo, VK_LAYER_LINK_INFO); |
| 198 | |
| 199 | assert(chain_info->u.pLayerInfo); |
| 200 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 201 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(nullptr, "vkCreateInstance"); |
| 202 | if (fpCreateInstance == nullptr) return VK_ERROR_INITIALIZATION_FAILED; |
| 203 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 204 | |
| 205 | auto instance_dispatch = std::make_unique<vvl::DispatchInstance>(pCreateInfo); |
| 206 | |
| 207 | // Init dispatch array and call registration functions |
| 208 | bool skip = false; |
| 209 | ErrorObject error_obj(vvl::Func::vkCreateInstance, VulkanTypedHandle()); |
| 210 | for (const auto& vo : instance_dispatch->object_dispatch) { |
| 211 | if (!vo) { |
| 212 | continue; |
| 213 | } |
| 214 | skip |= vo->PreCallValidateCreateInstance(pCreateInfo, pAllocator, pInstance, error_obj); |
| 215 | if (skip) { |
| 216 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | RecordObject record_obj(vvl::Func::vkCreateInstance); |
| 221 | for (auto& vo : instance_dispatch->object_dispatch) { |
| 222 | if (!vo) { |
| 223 | continue; |
| 224 | } |
| 225 | vo->PreCallRecordCreateInstance(pCreateInfo, pAllocator, pInstance, record_obj); |
| 226 | } |
| 227 | |
| 228 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 229 | if (result != VK_SUCCESS) { |
| 230 | return result; |
| 231 | } |
| 232 | record_obj.result = result; |
| 233 | instance_dispatch->instance = *pInstance; |
| 234 | for (auto& vo : instance_dispatch->object_dispatch) { |
| 235 | if (!vo) { |
| 236 | continue; |
| 237 | } |
| 238 | vo->CopyDispatchState(); |
| 239 | } |
| 240 | |
| 241 | layer_init_instance_dispatch_table(*pInstance, &instance_dispatch->instance_dispatch_table, fpGetInstanceProcAddr); |
| 242 | |
| 243 | OutputLayerStatusInfo(instance_dispatch.get()); |
| 244 | InstanceExtensionWhitelist(instance_dispatch.get(), pCreateInfo, *pInstance); |
| 245 | instance_dispatch->FindSupportedExtensions(); |
| 246 | |
| 247 | // save a raw pointer since the unique_ptr will be invalidate by the move() below |
| 248 | auto* id = instance_dispatch.get(); |
| 249 | vvl::SetDispatchInstance(*pInstance, std::move(instance_dispatch)); |
nothing calls this directly
no test coverage detected