OpenXR Monado创建instance
@OpenXR-SDK-Source/src/scripts/utility_source_generator.py //编译时生成的源码
UtilitySourceOutputGenerator
void GeneratedXrPopulateDispatchTable(struct XrGeneratedDispatchTable *table,\n'
@OpenXR-SDK-Source/src/tests/hello_xr/main.cpp
android_main
@OpenXR-SDK-Source/src/tests/hello_xr/openxr_program.cpp
program->CreateInstance();
@OpenXR-SDK-Source/src/tests/hello_xr/openxr_program.cpp
CreateInstanceInternal
@OpenXR-SDK-Source/src/loader/loader_core.cpp
CHECK_XRCMD(xrCreateInstance(&createInfo, &m_instance));
return LoaderXrCreateInstance(info, instance);
result = RuntimeInterface::LoadRuntime("xrCreateInstance");
@OpenXR-SDK-Source/src/loader/runtime_interface.cpp
last_error = RuntimeInterface::TryLoadingSingleRuntime(openxr_command, manifest_file);
std::string function_name = manifest_file->GetFunctionName("xrNegotiateLoaderRuntimeInterface");
auto negotiate = reinterpret_cast<PFN_xrNegotiateLoaderRuntimeInterface>(LoaderPlatformLibraryGetProcAddr(runtime_library, function_name));
@monado/src/xrt/state_trackers/oxr/oxr_api_negotiate.c
res = negotiate(&loader_info, &runtime_info); //xrNegotiateLoaderRuntimeInterface
runtimeRequest->getInstanceProcAddr = oxr_xrGetInstanceProcAddr;
GetInstance().reset(new RuntimeInterface(runtime_library, runtime_info.getInstanceProcAddr));
_get_instance_proc_addr(get_instance_proc_addr) //_get_instance_proc_addr=oxr_xrGetInstanceProcAddr
@OpenXR-SDK-Source/src/loader/loader_instance.cpp
result = LoaderInstance::CreateInstance(LoaderXrTermGetInstanceProcAddr, LoaderXrTermCreateInstance, LoaderXrTermCreateApiLayerInstance, std::move(api_layer_interfaces), info, &owned_loader_instance);
@OpenXR-SDK-Source/src/loader/loader_core.cpp
last_error = create_instance_term(modified_create_info, &instance); //LoaderXrTermCreateInstance
@OpenXR-SDK-Source/src/loader/runtime_interface.cpp
result = RuntimeInterface::GetRuntime().CreateInstance(createInfo, instance);
@OpenXR-SDK-Source/src/tests/hello_xr/.cxx/Debug/53674i5p/arm64-v8a/src/xr_generated_dispatch_table.c
GeneratedXrPopulateDispatchTable(dispatch_table.get(), *instance, _get_instance_proc_addr);
(get_inst_proc_addr(instance, "xrLocateSpace", (PFN_xrVoidFunction*)&table->LocateSpace));
(get_inst_proc_addr(instance, "xrCreateSwapchain", (PFN_xrVoidFunction*)&table->CreateSwapchain)); //设置table里面的函数指针CreateSwapchain
handle_non_null(inst, &log, name, function);
ENTRY(xrCreateSwapchain);
*out_function = (PFN_xrVoidFunction)(xr_xrCreateSwapchain);
_dispatch_table_map[*instance] = std::move(dispatch_table);
loader_instance->reset(new LoaderInstance(instance, info, topmost_gipa, std::move(api_layer_interfaces))); //创建LoaderInstance
GeneratedXrPopulateDispatchTable(_dispatch_table.get(), instance, topmost_gipa);
result = ActiveLoaderInstance::Set(std::move(owned_loader_instance), "xrCreateInstance");
GetSetCurrentLoaderInstance() = std::move(loader_instance); //current_loader_instance=loader_instance,即LoaderInstance
static std::unique_ptr<LoaderInstance> current_loader_instance;