forked from sascha/godot
Updated thirdparty OpenXR library to 1.0.33
parent
84e205b5a1
commit
3747cf2ffa
@ -0,0 +1,140 @@
|
||||
#ifndef OPENXR_LOADER_NEGOTIATION_H_
|
||||
#define OPENXR_LOADER_NEGOTIATION_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2017-2024, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos OpenXR XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
#include "openxr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define XR_LOADER_VERSION_1_0 1
|
||||
|
||||
#define XR_CURRENT_LOADER_API_LAYER_VERSION 1
|
||||
|
||||
|
||||
#define XR_CURRENT_LOADER_RUNTIME_VERSION 1
|
||||
|
||||
|
||||
#define XR_LOADER_INFO_STRUCT_VERSION 1
|
||||
|
||||
|
||||
#define XR_API_LAYER_INFO_STRUCT_VERSION 1
|
||||
|
||||
|
||||
#define XR_RUNTIME_INFO_STRUCT_VERSION 1
|
||||
|
||||
|
||||
#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1
|
||||
|
||||
|
||||
#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1
|
||||
|
||||
|
||||
#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512
|
||||
|
||||
|
||||
typedef enum XrLoaderInterfaceStructs {
|
||||
XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0,
|
||||
XR_LOADER_INTERFACE_STRUCT_LOADER_INFO = 1,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST = 2,
|
||||
XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST = 3,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO = 4,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO = 5,
|
||||
XR_LOADER_INTERFACE_STRUCTS_MAX_ENUM = 0x7FFFFFFF
|
||||
} XrLoaderInterfaceStructs;
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetInstanceProcAddr)(XrInstance instance, const char* name, PFN_xrVoidFunction* function);
|
||||
|
||||
typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo;
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateApiLayerInstance)(
|
||||
const XrInstanceCreateInfo* info,
|
||||
const XrApiLayerCreateInfo* apiLayerInfo,
|
||||
XrInstance* instance);
|
||||
|
||||
typedef struct XrApiLayerNextInfo {
|
||||
XrLoaderInterfaceStructs structType;
|
||||
uint32_t structVersion;
|
||||
size_t structSize;
|
||||
char layerName[XR_MAX_API_LAYER_NAME_SIZE];
|
||||
PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr;
|
||||
PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance;
|
||||
struct XrApiLayerNextInfo* next;
|
||||
} XrApiLayerNextInfo;
|
||||
|
||||
typedef struct XrApiLayerCreateInfo {
|
||||
XrLoaderInterfaceStructs structType;
|
||||
uint32_t structVersion;
|
||||
size_t structSize;
|
||||
void* XR_MAY_ALIAS loaderInstance;
|
||||
char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE];
|
||||
XrApiLayerNextInfo* nextInfo;
|
||||
} XrApiLayerCreateInfo;
|
||||
|
||||
typedef struct XrNegotiateLoaderInfo {
|
||||
XrLoaderInterfaceStructs structType;
|
||||
uint32_t structVersion;
|
||||
size_t structSize;
|
||||
uint32_t minInterfaceVersion;
|
||||
uint32_t maxInterfaceVersion;
|
||||
XrVersion minApiVersion;
|
||||
XrVersion maxApiVersion;
|
||||
} XrNegotiateLoaderInfo;
|
||||
|
||||
typedef struct XrNegotiateRuntimeRequest {
|
||||
XrLoaderInterfaceStructs structType;
|
||||
uint32_t structVersion;
|
||||
size_t structSize;
|
||||
uint32_t runtimeInterfaceVersion;
|
||||
XrVersion runtimeApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
} XrNegotiateRuntimeRequest;
|
||||
|
||||
typedef struct XrNegotiateApiLayerRequest {
|
||||
XrLoaderInterfaceStructs structType;
|
||||
uint32_t structVersion;
|
||||
size_t structSize;
|
||||
uint32_t layerInterfaceVersion;
|
||||
XrVersion layerApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
PFN_xrCreateApiLayerInstance createApiLayerInstance;
|
||||
} XrNegotiateApiLayerRequest;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo* info, const XrApiLayerCreateInfo* layerInfo, XrInstance* instance);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo* loaderInfo, XrNegotiateRuntimeRequest* runtimeRequest);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo* loaderInfo, const char* layerName, XrNegotiateApiLayerRequest* apiLayerRequest);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
#ifdef XR_EXTENSION_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrCreateApiLayerInstance(
|
||||
const XrInstanceCreateInfo* info,
|
||||
const XrApiLayerCreateInfo* layerInfo,
|
||||
XrInstance* instance);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrNegotiateLoaderRuntimeInterface(
|
||||
const XrNegotiateLoaderInfo* loaderInfo,
|
||||
XrNegotiateRuntimeRequest* runtimeRequest);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrNegotiateLoaderApiLayerInterface(
|
||||
const XrNegotiateLoaderInfo* loaderInfo,
|
||||
const char* layerName,
|
||||
XrNegotiateApiLayerRequest* apiLayerRequest);
|
||||
#endif /* XR_EXTENSION_PROTOTYPES */
|
||||
#endif /* !XR_NO_PROTOTYPES */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,114 +0,0 @@
|
||||
// Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2017 Valve Corporation
|
||||
// Copyright (c) 2017 LunarG, Inc.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
//
|
||||
// Initial Author: Mark Young <marky@lunarg.com>
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Forward declare.
|
||||
typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo;
|
||||
|
||||
// Function pointer prototype for the xrCreateApiLayerInstance function used in place of xrCreateInstance.
|
||||
// This function allows us to pass special API layer information to each layer during the process of creating an Instance.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo *info,
|
||||
const XrApiLayerCreateInfo *apiLayerInfo, XrInstance *instance);
|
||||
|
||||
// Loader/API Layer Interface versions
|
||||
// 1 - First version, introduces negotiation structure and functions
|
||||
#define XR_CURRENT_LOADER_API_LAYER_VERSION 1
|
||||
|
||||
// Loader/Runtime Interface versions
|
||||
// 1 - First version, introduces negotiation structure and functions
|
||||
#define XR_CURRENT_LOADER_RUNTIME_VERSION 1
|
||||
|
||||
// Version negotiation values
|
||||
typedef enum XrLoaderInterfaceStructs {
|
||||
XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0,
|
||||
XR_LOADER_INTERFACE_STRUCT_LOADER_INFO,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST,
|
||||
XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO,
|
||||
XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO,
|
||||
} XrLoaderInterfaceStructs;
|
||||
|
||||
#define XR_LOADER_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateLoaderInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_LOADER_INFO
|
||||
uint32_t structVersion; // XR_LOADER_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateLoaderInfo)
|
||||
uint32_t minInterfaceVersion;
|
||||
uint32_t maxInterfaceVersion;
|
||||
XrVersion minApiVersion;
|
||||
XrVersion maxApiVersion;
|
||||
} XrNegotiateLoaderInfo;
|
||||
|
||||
#define XR_API_LAYER_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateApiLayerRequest {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST
|
||||
uint32_t structVersion; // XR_API_LAYER_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateApiLayerRequest)
|
||||
uint32_t layerInterfaceVersion; // CURRENT_LOADER_API_LAYER_VERSION
|
||||
XrVersion layerApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
PFN_xrCreateApiLayerInstance createApiLayerInstance;
|
||||
} XrNegotiateApiLayerRequest;
|
||||
|
||||
#define XR_RUNTIME_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrNegotiateRuntimeRequest {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST
|
||||
uint32_t structVersion; // XR_RUNTIME_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrNegotiateRuntimeRequest)
|
||||
uint32_t runtimeInterfaceVersion; // CURRENT_LOADER_RUNTIME_VERSION
|
||||
XrVersion runtimeApiVersion;
|
||||
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
|
||||
} XrNegotiateRuntimeRequest;
|
||||
|
||||
// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
|
||||
// more API layers needs to expose at least this function.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo *loaderInfo,
|
||||
const char *apiLayerName,
|
||||
XrNegotiateApiLayerRequest *apiLayerRequest);
|
||||
|
||||
// Function used to negotiate an interface betewen the loader and a runtime. Each runtime should expose
|
||||
// at least this function.
|
||||
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo *loaderInfo,
|
||||
XrNegotiateRuntimeRequest *runtimeRequest);
|
||||
|
||||
// Forward declare.
|
||||
typedef struct XrApiLayerNextInfo XrApiLayerNextInfo;
|
||||
|
||||
#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1
|
||||
struct XrApiLayerNextInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO
|
||||
uint32_t structVersion; // XR_API_LAYER_NEXT_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrApiLayerNextInfo)
|
||||
char layerName[XR_MAX_API_LAYER_NAME_SIZE]; // Name of API layer which should receive this info
|
||||
PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr; // Pointer to next API layer's xrGetInstanceProcAddr
|
||||
PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance; // Pointer to next API layer's xrCreateApiLayerInstance
|
||||
XrApiLayerNextInfo *next; // Pointer to the next API layer info in the sequence
|
||||
};
|
||||
|
||||
#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512
|
||||
#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1
|
||||
typedef struct XrApiLayerCreateInfo {
|
||||
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO
|
||||
uint32_t structVersion; // XR_API_LAYER_CREATE_INFO_STRUCT_VERSION
|
||||
size_t structSize; // sizeof(XrApiLayerCreateInfo)
|
||||
void *loaderInstance; // Pointer to the LoaderInstance class
|
||||
char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE]; // Location to the found settings file (or empty '\0')
|
||||
XrApiLayerNextInfo *nextInfo; // Pointer to the next API layer's Info
|
||||
} XrApiLayerCreateInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@ -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
|
||||
@ -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
|
||||
Loading…
Reference in New Issue