summaryrefslogtreecommitdiffstats
path: root/thirdparty/openxr/src/loader/runtime_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/openxr/src/loader/runtime_interface.cpp')
-rw-r--r--thirdparty/openxr/src/loader/runtime_interface.cpp117
1 files changed, 5 insertions, 112 deletions
diff --git a/thirdparty/openxr/src/loader/runtime_interface.cpp b/thirdparty/openxr/src/loader/runtime_interface.cpp
index 8312b15ba4..7812aca987 100644
--- a/thirdparty/openxr/src/loader/runtime_interface.cpp
+++ b/thirdparty/openxr/src/loader/runtime_interface.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2017-2023, The Khronos Group Inc.
+// Copyright (c) 2017-2024, The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
@@ -9,14 +9,15 @@
#include "runtime_interface.hpp"
+#include <openxr/openxr.h>
+#include <openxr/openxr_loader_negotiation.h>
+
#include "manifest_file.hpp"
-#include "loader_interfaces.h"
+#include "loader_init_data.hpp"
#include "loader_logger.hpp"
#include "loader_platform.hpp"
#include "xr_generated_dispatch_table_core.h"
-#include <openxr/openxr.h>
-
#include <cstring>
#include <memory>
#include <mutex>
@@ -26,8 +27,6 @@
#include <vector>
#ifdef XR_USE_PLATFORM_ANDROID
-#include "android_utilities.h"
-#include <android/asset_manager_jni.h>
#include <json/value.h>
// Needed for the loader init struct
@@ -35,112 +34,6 @@
#include <openxr/openxr_platform.h>
#endif // XR_USE_PLATFORM_ANDROID
-#ifdef XR_KHR_LOADER_INIT_SUPPORT
-namespace {
-/*!
- * Stores a copy of the data passed to the xrInitializeLoaderKHR function in a singleton.
- */
-class LoaderInitData {
- public:
- /*!
- * Singleton accessor.
- */
- static LoaderInitData& instance() {
- static LoaderInitData obj;
- return obj;
- }
-
-#ifdef XR_USE_PLATFORM_ANDROID
- /*!
- * Type alias for the platform-specific structure type.
- */
- using StructType = XrLoaderInitInfoAndroidKHR;
- /*!
- * Native library path.
- */
- std::string _native_library_path;
- /*!
- * Android asset manager.
- */
- AAssetManager* _android_asset_manager;
-#endif
-
- /*!
- * Get our copy of the data, casted to pass to the runtime's matching method.
- */
- const XrLoaderInitInfoBaseHeaderKHR* getParam() const { return reinterpret_cast<const XrLoaderInitInfoBaseHeaderKHR*>(&_data); }
-
- /*!
- * Get the data via its real structure type.
- */
- const StructType& getData() const { return _data; }
-
- /*!
- * Has this been correctly initialized?
- */
- bool initialized() const noexcept { return _initialized; }
-
- /*!
- * Initialize loader data - called by InitializeLoader() and thus ultimately by the loader's xrInitializeLoaderKHR
- * implementation. Each platform that needs this extension will provide an implementation of this.
- */
- XrResult initialize(const XrLoaderInitInfoBaseHeaderKHR* info);
-
- private:
- //! Private constructor, forces use of singleton accessor.
- LoaderInitData() = default;
- //! Platform-specific init data
- StructType _data = {};
- //! Flag for indicating whether _data is valid.
- bool _initialized = false;
-};
-
-#ifdef XR_USE_PLATFORM_ANDROID
-// Check and copy the Android-specific init data.
-XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) {
- if (info->type != XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR) {
- return XR_ERROR_VALIDATION_FAILURE;
- }
- auto cast_info = reinterpret_cast<XrLoaderInitInfoAndroidKHR const*>(info);
-
- if (cast_info->applicationVM == nullptr) {
- return XR_ERROR_VALIDATION_FAILURE;
- }
- if (cast_info->applicationContext == nullptr) {
- return XR_ERROR_VALIDATION_FAILURE;
- }
-
- // Copy and store the JVM pointer and Android Context, ensuring the JVM is initialised.
- _data = *cast_info;
- _data.next = nullptr;
- jni::init(static_cast<jni::JavaVM*>(_data.applicationVM));
- const jni::Object context = jni::Object{static_cast<jni::jobject>(_data.applicationContext)};
-
- // Retrieve a reference to the Android AssetManager.
- const auto assetManager = context.call<jni::Object>("getAssets()Landroid/content/res/AssetManager;");
- _android_asset_manager = AAssetManager_fromJava(jni::env(), assetManager.getHandle());
-
- // Retrieve the path to the native libraries.
- const auto applicationContext = context.call<jni::Object>("getApplicationContext()Landroid/content/Context;");
- const auto applicationInfo = context.call<jni::Object>("getApplicationInfo()Landroid/content/pm/ApplicationInfo;");
- _native_library_path = applicationInfo.get<std::string>("nativeLibraryDir");
-
- _initialized = true;
- return XR_SUCCESS;
-}
-#endif // XR_USE_PLATFORM_ANDROID
-} // namespace
-
-XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo) {
- return LoaderInitData::instance().initialize(loaderInitInfo);
-}
-
-std::string GetAndroidNativeLibraryDir() { return LoaderInitData::instance()._native_library_path; }
-
-void* Android_Get_Asset_Manager() { return LoaderInitData::instance()._android_asset_manager; }
-
-#endif // XR_KHR_LOADER_INIT_SUPPORT
-
#ifdef XR_USE_PLATFORM_ANDROID
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest) {
using wrap::android::content::Context;