You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-05 17:15:09 +00:00
Updated thirdparty OpenXR library to 1.0.33
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2020-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2020-2024, The Khronos Group Inc.
|
||||
// Copyright (c) 2020-2021, Collabora, Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Initial Author: Rylie Pavlik <rylie.pavlik@collabora.com>
|
||||
|
||||
#include "android_utilities.h"
|
||||
|
||||
@@ -245,18 +245,38 @@ static int populateFunctions(wrap::android::content::Context const &context, boo
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The current file relies on android-jni-wrappers and jnipp, which may throw on failure.
|
||||
// This is problematic when the loader is compiled with exception handling disabled - the consumers can reasonably
|
||||
// expect that the compilation with -fno-exceptions will succeed, but the compiler will not accept the code that
|
||||
// uses `try` & `catch` keywords. We cannot use the `exception_handling.hpp` here since we're not at an ABI boundary,
|
||||
// so we define helper macros here. This is fine for now since the only occurrence of exception-handling code is in this file.
|
||||
#ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING
|
||||
|
||||
#define ANDROID_UTILITIES_TRY
|
||||
#define ANDROID_UTILITIES_CATCH_FALLBACK(...)
|
||||
|
||||
#else
|
||||
|
||||
#define ANDROID_UTILITIES_TRY try
|
||||
#define ANDROID_UTILITIES_CATCH_FALLBACK(...) \
|
||||
catch (const std::exception &e) { \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
|
||||
#endif // XRLOADER_DISABLE_EXCEPTION_HANDLING
|
||||
|
||||
/// Get cursor for active runtime, parameterized by whether or not we use the system broker
|
||||
static bool getActiveRuntimeCursor(wrap::android::content::Context const &context, jni::Array<std::string> const &projection,
|
||||
bool systemBroker, Cursor &cursor) {
|
||||
auto uri = active_runtime::makeContentUri(systemBroker, XR_VERSION_MAJOR(XR_CURRENT_API_VERSION), ABI);
|
||||
ALOGI("getActiveRuntimeCursor: Querying URI: %s", uri.toString().c_str());
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection);
|
||||
} catch (const std::exception &e) {
|
||||
|
||||
ANDROID_UTILITIES_TRY { cursor = context.getContentResolver().query(uri, projection); }
|
||||
ANDROID_UTILITIES_CATCH_FALLBACK({
|
||||
ALOGW("Exception when querying %s content resolver: %s", getBrokerTypeName(systemBroker), e.what());
|
||||
cursor = {};
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
||||
if (cursor.isNull()) {
|
||||
ALOGW("Null cursor when querying %s content resolver.", getBrokerTypeName(systemBroker));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2020-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2020-2024, The Khronos Group Inc.
|
||||
// Copyright (c) 2020-2021, Collabora, Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Initial Author: Rylie Pavlik <rylie.pavlik@collabora.com>
|
||||
|
||||
#pragma once
|
||||
#ifdef __ANDROID__
|
||||
|
||||
@@ -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,13 +9,14 @@
|
||||
|
||||
#include "api_layer_interface.hpp"
|
||||
|
||||
#include "loader_interfaces.h"
|
||||
#include "loader_init_data.hpp"
|
||||
#include "loader_logger.hpp"
|
||||
#include "loader_platform.hpp"
|
||||
#include "manifest_file.hpp"
|
||||
#include "platform_utils.hpp"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_loader_negotiation.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
@@ -282,6 +283,38 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin
|
||||
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
|
||||
continue;
|
||||
}
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT
|
||||
if (!LoaderInitData::instance().initialized()) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command, "ApiLayerInterface::LoadApiLayers skipping manifest file " +
|
||||
manifest_file->Filename() +
|
||||
" because xrInitializeLoaderKHR was not yet called.");
|
||||
|
||||
LoaderPlatformLibraryClose(layer_library);
|
||||
return XR_ERROR_VALIDATION_FAILURE;
|
||||
}
|
||||
bool forwardedInitLoader = false;
|
||||
{
|
||||
// If we have xrInitializeLoaderKHR exposed as an export, forward call to it.
|
||||
const auto function_name = manifest_file->GetFunctionName("xrInitializeLoaderKHR");
|
||||
auto initLoader =
|
||||
reinterpret_cast<PFN_xrInitializeLoaderKHR>(LoaderPlatformLibraryGetProcAddr(layer_library, function_name));
|
||||
if (initLoader != nullptr) {
|
||||
// we found the entry point one way or another.
|
||||
LoaderLogger::LogInfoMessage(openxr_command,
|
||||
"ApiLayerInterface::LoadApiLayers forwarding xrInitializeLoaderKHR call to API layer "
|
||||
"before calling xrNegotiateLoaderApiLayerInterface.");
|
||||
XrResult res = initLoader(LoaderInitData::instance().getParam());
|
||||
if (!XR_SUCCEEDED(res)) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
openxr_command, "ApiLayerInterface::LoadApiLayers forwarded call to xrInitializeLoaderKHR failed.");
|
||||
|
||||
LoaderPlatformLibraryClose(layer_library);
|
||||
return res;
|
||||
}
|
||||
forwardedInitLoader = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get and settle on an layer interface version (using any provided name if required).
|
||||
std::string function_name = manifest_file->GetFunctionName("xrNegotiateLoaderApiLayerInterface");
|
||||
@@ -324,6 +357,38 @@ XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uin
|
||||
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
|
||||
res = XR_ERROR_FILE_CONTENTS_INVALID;
|
||||
}
|
||||
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT
|
||||
if (XR_SUCCEEDED(res) && !forwardedInitLoader) {
|
||||
// Forward initialize loader call, where possible and if we did not do so before.
|
||||
PFN_xrVoidFunction initializeVoid = nullptr;
|
||||
PFN_xrInitializeLoaderKHR initialize = nullptr;
|
||||
|
||||
// Now we may try asking xrGetInstanceProcAddr on the API layer
|
||||
if (XR_SUCCEEDED(api_layer_info.getInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", &initializeVoid))) {
|
||||
if (initializeVoid == nullptr) {
|
||||
LoaderLogger::LogErrorMessage(openxr_command,
|
||||
"ApiLayerInterface::LoadApiLayers got success from xrGetInstanceProcAddr "
|
||||
"for xrInitializeLoaderKHR, but output a null pointer.");
|
||||
res = XR_ERROR_RUNTIME_FAILURE;
|
||||
} else {
|
||||
initialize = reinterpret_cast<PFN_xrInitializeLoaderKHR>(initializeVoid);
|
||||
}
|
||||
}
|
||||
if (initialize != nullptr) {
|
||||
// we found the entry point one way or another.
|
||||
LoaderLogger::LogInfoMessage(openxr_command,
|
||||
"ApiLayerInterface::LoadApiLayers forwarding xrInitializeLoaderKHR call to API layer "
|
||||
"after calling xrNegotiateLoaderApiLayerInterface.");
|
||||
res = initialize(LoaderInitData::instance().getParam());
|
||||
if (!XR_SUCCEEDED(res)) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
openxr_command, "ApiLayerInterface::LoadApiLayers forwarded call to xrInitializeLoaderKHR failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (XR_FAILED(res)) {
|
||||
if (!any_loaded) {
|
||||
last_error = res;
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
@@ -14,9 +14,9 @@
|
||||
#include <memory>
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_loader_negotiation.h>
|
||||
|
||||
#include "loader_platform.hpp"
|
||||
#include "loader_interfaces.h"
|
||||
|
||||
struct XrGeneratedDispatchTable;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2019-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2019-2024, The Khronos Group Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Initial Author: Rylie Pavlik <rylie.pavlik@collabora.com>
|
||||
//
|
||||
// Provides protection for C ABI functions if standard library functions may throw.
|
||||
|
||||
|
||||
5
thirdparty/openxr/src/loader/loader_core.cpp
vendored
5
thirdparty/openxr/src/loader/loader_core.cpp
vendored
@@ -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.
|
||||
//
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "api_layer_interface.hpp"
|
||||
#include "exception_handling.hpp"
|
||||
#include "hex_and_handles.h"
|
||||
#include "loader_init_data.hpp"
|
||||
#include "loader_instance.hpp"
|
||||
#include "loader_logger_recorders.hpp"
|
||||
#include "loader_logger.hpp"
|
||||
@@ -77,7 +78,7 @@ inline bool IsMissingNullTerminator(const char (&str)[max_length]) {
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT // platforms that support XR_KHR_loader_init.
|
||||
XRAPI_ATTR XrResult XRAPI_CALL LoaderXrInitializeLoaderKHR(const XrLoaderInitInfoBaseHeaderKHR *loaderInitInfo) XRLOADER_ABI_TRY {
|
||||
LoaderLogger::LogVerboseMessage("xrInitializeLoaderKHR", "Entering loader trampoline");
|
||||
return InitializeLoader(loaderInitInfo);
|
||||
return InitializeLoaderInitData(loaderInitInfo);
|
||||
}
|
||||
XRLOADER_ABI_CATCH_FALLBACK
|
||||
#endif
|
||||
|
||||
59
thirdparty/openxr/src/loader/loader_init_data.cpp
vendored
Normal file
59
thirdparty/openxr/src/loader/loader_init_data.cpp
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2017-2024, The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#include "loader_init_data.hpp"
|
||||
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT
|
||||
|
||||
#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
|
||||
|
||||
XrResult InitializeLoaderInitData(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo) {
|
||||
return LoaderInitData::instance().initialize(loaderInitInfo);
|
||||
}
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
std::string GetAndroidNativeLibraryDir() { return LoaderInitData::instance()._native_library_path; }
|
||||
|
||||
void* Android_Get_Asset_Manager() { return LoaderInitData::instance()._android_asset_manager; }
|
||||
#endif // XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#endif // XR_KHR_LOADER_INIT_SUPPORT
|
||||
92
thirdparty/openxr/src/loader/loader_init_data.hpp
vendored
Normal file
92
thirdparty/openxr/src/loader/loader_init_data.hpp
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright (c) 2017-2024, The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2019 Valve Corporation
|
||||
// Copyright (c) 2017-2019 LunarG, Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xr_dependencies.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
#include <json/value.h>
|
||||
#include <android/asset_manager_jni.h>
|
||||
#include "android_utilities.h"
|
||||
#endif // XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT
|
||||
|
||||
/*!
|
||||
* 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;
|
||||
#else
|
||||
#error "Platform specific XR_KHR_loader_init structure is not defined for this platform."
|
||||
#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 InitializeLoaderInitData() 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;
|
||||
};
|
||||
|
||||
//! Initialize loader init data, where required.
|
||||
XrResult InitializeLoaderInitData(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo);
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest);
|
||||
std::string GetAndroidNativeLibraryDir();
|
||||
void* Android_Get_Asset_Manager();
|
||||
#endif // XR_USE_PLATFORM_ANDROID
|
||||
|
||||
#endif // XR_KHR_LOADER_INIT_SUPPORT
|
||||
@@ -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.
|
||||
//
|
||||
@@ -15,13 +15,13 @@
|
||||
|
||||
#include "api_layer_interface.hpp"
|
||||
#include "hex_and_handles.h"
|
||||
#include "loader_interfaces.h"
|
||||
#include "loader_logger.hpp"
|
||||
#include "runtime_interface.hpp"
|
||||
#include "xr_generated_dispatch_table_core.h"
|
||||
#include "xr_generated_loader.hpp"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_loader_negotiation.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
@@ -60,7 +60,7 @@ XrResult Get(LoaderInstance** loader_instance, const char* log_function_name) {
|
||||
|
||||
bool IsAvailable() { return GetSetCurrentLoaderInstance() != nullptr; }
|
||||
|
||||
void Remove() { GetSetCurrentLoaderInstance().release(); }
|
||||
void Remove() { GetSetCurrentLoaderInstance().reset(nullptr); }
|
||||
} // namespace ActiveLoaderInstance
|
||||
|
||||
// Extensions that are supported by the loader, but may not be supported
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
@@ -10,9 +10,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "extra_algorithms.h"
|
||||
#include "loader_interfaces.h"
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_loader_negotiation.h>
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// 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.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
// Initial Author: Rylie Pavlik <rylie.pavlik@collabora.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
@@ -18,6 +18,7 @@
|
||||
#endif // OPENXR_HAVE_COMMON_CONFIG
|
||||
|
||||
#include "filesystem_utils.hpp"
|
||||
#include "loader_init_data.hpp"
|
||||
#include "loader_platform.hpp"
|
||||
#include "platform_utils.hpp"
|
||||
#include "loader_logger.hpp"
|
||||
@@ -666,14 +667,14 @@ XrResult RuntimeManifestFile::FindManifestFiles(std::vector<std::unique_ptr<Runt
|
||||
}
|
||||
#else
|
||||
|
||||
#if defined(XR_KHR_LOADER_INIT_SUPPORT)
|
||||
#if defined(XR_USE_PLATFORM_ANDROID)
|
||||
Json::Value virtualManifest;
|
||||
result = GetPlatformRuntimeVirtualManifest(virtualManifest);
|
||||
if (XR_SUCCESS == result) {
|
||||
RuntimeManifestFile::CreateIfValid(virtualManifest, "", manifest_files);
|
||||
return result;
|
||||
}
|
||||
#endif // defined(XR_KHR_LOADER_INIT_SUPPORT)
|
||||
#endif // defined(XR_USE_PLATFORM_ANDROID)
|
||||
if (!PlatformGetGlobalRuntimeFileName(XR_VERSION_MAJOR(XR_CURRENT_API_VERSION), filename)) {
|
||||
LoaderLogger::LogErrorMessage(
|
||||
"", "RuntimeManifestFile::FindManifestFiles - failed to determine active runtime file path for this environment");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2017-2024, The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
|
||||
117
thirdparty/openxr/src/loader/runtime_interface.cpp
vendored
117
thirdparty/openxr/src/loader/runtime_interface.cpp
vendored
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
//
|
||||
@@ -19,22 +19,10 @@
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ANDROID
|
||||
#define XR_KHR_LOADER_INIT_SUPPORT
|
||||
#endif
|
||||
|
||||
namespace Json {
|
||||
class Value;
|
||||
}
|
||||
|
||||
#ifdef XR_KHR_LOADER_INIT_SUPPORT
|
||||
//! Initialize loader, where required.
|
||||
XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo);
|
||||
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest);
|
||||
std::string GetAndroidNativeLibraryDir();
|
||||
void* Android_Get_Asset_Manager();
|
||||
#endif
|
||||
|
||||
class RuntimeManifestFile;
|
||||
struct XrGeneratedDispatchTable;
|
||||
|
||||
|
||||
@@ -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.
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
@@ -6,7 +6,7 @@
|
||||
// See loader_source_generator.py for modifications
|
||||
// ************************************************************
|
||||
|
||||
// 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.
|
||||
//
|
||||
|
||||
@@ -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.
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
@@ -6,7 +6,7 @@
|
||||
// See loader_source_generator.py for modifications
|
||||
// ************************************************************
|
||||
|
||||
// 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.
|
||||
//
|
||||
@@ -34,10 +34,9 @@
|
||||
|
||||
#include "xr_dependencies.h"
|
||||
#include "openxr/openxr.h"
|
||||
#include "openxr/openxr_loader_negotiation.h"
|
||||
#include "openxr/openxr_platform.h"
|
||||
|
||||
#include "loader_interfaces.h"
|
||||
|
||||
#include "loader_instance.hpp"
|
||||
|
||||
#include "loader_platform.hpp"
|
||||
|
||||
Reference in New Issue
Block a user