我一直认为在 android 平台上我们应该使用dlopen()
and加载指向 Vulkan 库的指针dlsym()
(类似这样:
libVulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
vkEnumerateInstanceExtensionProperties = reinterpret_cast<PFN_vkEnumerateInstanceExtensionProperties(dlsym(libVulkan,"vkEnumerateInstanceExtensionProperties"));
(来源:https ://github.com/SaschaWillems/Vulkan/blob/master/base/VulkanAndroid.cpp )
)
或使用“vulkan_wrapper.h”动态加载器(如谷歌的 Vulkan Android 示例https://github.com/googlesamples/android-vulkan-tutorials)
感谢 Gayan Ediriweera 的博客 ( https://gayanediriweera.github.io/code/2021/04/06/how-to-run-helloxr-on- ),我能够在 oculus 任务中构建和运行 hello_xr 示例oculus-quest.html )
但是,当我查看 vulkan 的 hello_xr 示例的代码时,我没有看到对 dlopen() 或 dlsym() 的调用。例如在第 1287 行(https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/tests/hello_xr/graphicsplugin_vulkan.cpp),示例调用vkEnumerateInstanceLayerProperties
,但我没有看到指针在哪里这个基本功能已加载,这让我感到困惑。
这里发生了什么黑魔法?OpenXR 运行时是在后台加载这些还是我在代码中遗漏了什么?
提前感谢您对此的任何帮助