Merge pull request #65766 from BastiaanOlij/openxr_1_0_25

Update OpenXR to 1.0.25
This commit is contained in:
Rémi Verschelde 2022-09-14 07:31:54 +02:00 committed by GitHub
commit b1e54ef20b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 389 additions and 28 deletions

View File

@ -535,7 +535,7 @@ Patch files are provided in `oidn/patches/`.
## openxr ## openxr
- Upstream: https://github.com/KhronosGroup/OpenXR-SDK - Upstream: https://github.com/KhronosGroup/OpenXR-SDK
- Version: 1.0.23 (885a90f8934d84121344ba8e4aa5159d5b496e08, 2022) - Version: 1.0.25 (c16a18c99740ea5dd251e3af117e0e5aea4ceaa9, 2022)
- License: Apache 2.0 - License: Apache 2.0
Files extracted from upstream source: Files extracted from upstream source:

View File

@ -2,7 +2,7 @@
#define OPENXR_H_ 1 #define OPENXR_H_ 1
/* /*
** Copyright (c) 2017-2022, The Khronos Group Inc. ** Copyright 2017-2022 The Khronos Group Inc.
** **
** SPDX-License-Identifier: Apache-2.0 OR MIT ** SPDX-License-Identifier: Apache-2.0 OR MIT
*/ */
@ -25,7 +25,7 @@ extern "C" {
((((major) & 0xffffULL) << 48) | (((minor) & 0xffffULL) << 32) | ((patch) & 0xffffffffULL)) ((((major) & 0xffffULL) << 48) | (((minor) & 0xffffULL) << 32) | ((patch) & 0xffffffffULL))
// OpenXR current version number. // OpenXR current version number.
#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 23) #define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 25)
#define XR_VERSION_MAJOR(version) (uint16_t)(((uint64_t)(version) >> 48)& 0xffffULL) #define XR_VERSION_MAJOR(version) (uint16_t)(((uint64_t)(version) >> 48)& 0xffffULL)
#define XR_VERSION_MINOR(version) (uint16_t)(((uint64_t)(version) >> 32) & 0xffffULL) #define XR_VERSION_MINOR(version) (uint16_t)(((uint64_t)(version) >> 32) & 0xffffULL)
@ -401,6 +401,7 @@ typedef enum XrStructureType {
XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB = 1000118003, XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB = 1000118003,
XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB = 1000118004, XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB = 1000118004,
XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB = 1000118005, XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB = 1000118005,
XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB = 1000118006,
XR_TYPE_PASSTHROUGH_STYLE_FB = 1000118020, XR_TYPE_PASSTHROUGH_STYLE_FB = 1000118020,
XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB = 1000118021, XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB = 1000118021,
XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB = 1000118022, XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB = 1000118022,
@ -439,6 +440,9 @@ typedef enum XrStructureType {
XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB = 1000163000, XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB = 1000163000,
XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB = 1000171000, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB = 1000171000,
XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB = 1000171001, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB = 1000171001,
XR_TYPE_SEMANTIC_LABELS_FB = 1000175000,
XR_TYPE_ROOM_LAYOUT_FB = 1000175001,
XR_TYPE_BOUNDARY_2D_FB = 1000175002,
XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE = 1000196000, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE = 1000196000,
XR_TYPE_SPACE_CONTAINER_FB = 1000199000, XR_TYPE_SPACE_CONTAINER_FB = 1000199000,
XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB = 1000203002, XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB = 1000203002,
@ -2603,7 +2607,7 @@ typedef struct XrHandJointsMotionRangeInfoEXT {
XR_DEFINE_HANDLE(XrSceneMSFT) XR_DEFINE_HANDLE(XrSceneMSFT)
#define XR_MSFT_scene_understanding_SPEC_VERSION 1 #define XR_MSFT_scene_understanding_SPEC_VERSION 2
#define XR_MSFT_SCENE_UNDERSTANDING_EXTENSION_NAME "XR_MSFT_scene_understanding" #define XR_MSFT_SCENE_UNDERSTANDING_EXTENSION_NAME "XR_MSFT_scene_understanding"
typedef enum XrSceneComputeFeatureMSFT { typedef enum XrSceneComputeFeatureMSFT {
@ -2925,7 +2929,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetSceneMeshBuffersMSFT(
#define XR_MSFT_scene_understanding_serialization 1 #define XR_MSFT_scene_understanding_serialization 1
#define XR_MSFT_scene_understanding_serialization_SPEC_VERSION 1 #define XR_MSFT_scene_understanding_serialization_SPEC_VERSION 2
#define XR_MSFT_SCENE_UNDERSTANDING_SERIALIZATION_EXTENSION_NAME "XR_MSFT_scene_understanding_serialization" #define XR_MSFT_SCENE_UNDERSTANDING_SERIALIZATION_EXTENSION_NAME "XR_MSFT_scene_understanding_serialization"
typedef struct XrSerializedSceneFragmentDataGetInfoMSFT { typedef struct XrSerializedSceneFragmentDataGetInfoMSFT {
XrStructureType type; XrStructureType type;
@ -3166,7 +3170,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetFacialExpressionsHTC(
#define XR_FB_color_space 1 #define XR_FB_color_space 1
#define XR_FB_color_space_SPEC_VERSION 2 #define XR_FB_color_space_SPEC_VERSION 3
#define XR_FB_COLOR_SPACE_EXTENSION_NAME "XR_FB_color_space" #define XR_FB_COLOR_SPACE_EXTENSION_NAME "XR_FB_color_space"
typedef enum XrColorSpaceFB { typedef enum XrColorSpaceFB {
@ -3206,7 +3210,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetColorSpaceFB(
#define XR_FB_hand_tracking_mesh 1 #define XR_FB_hand_tracking_mesh 1
#define XR_FB_hand_tracking_mesh_SPEC_VERSION 2 #define XR_FB_hand_tracking_mesh_SPEC_VERSION 3
#define XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME "XR_FB_hand_tracking_mesh" #define XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME "XR_FB_hand_tracking_mesh"
typedef struct XrVector4sFB { typedef struct XrVector4sFB {
int16_t x; int16_t x;
@ -3317,6 +3321,10 @@ XR_DEFINE_ATOM(XrAsyncRequestIdFB)
typedef enum XrSpaceComponentTypeFB { typedef enum XrSpaceComponentTypeFB {
XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB = 0, XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB = 0,
XR_SPACE_COMPONENT_TYPE_STORABLE_FB = 1, XR_SPACE_COMPONENT_TYPE_STORABLE_FB = 1,
XR_SPACE_COMPONENT_TYPE_BOUNDED_2D_FB = 3,
XR_SPACE_COMPONENT_TYPE_BOUNDED_3D_FB = 4,
XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB = 5,
XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB = 6,
XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB = 7, XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB = 7,
XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB = 0x7FFFFFFF XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB = 0x7FFFFFFF
} XrSpaceComponentTypeFB; } XrSpaceComponentTypeFB;
@ -3625,7 +3633,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrTriangleMeshEndVertexBufferUpdateFB(
XR_DEFINE_HANDLE(XrPassthroughFB) XR_DEFINE_HANDLE(XrPassthroughFB)
XR_DEFINE_HANDLE(XrPassthroughLayerFB) XR_DEFINE_HANDLE(XrPassthroughLayerFB)
XR_DEFINE_HANDLE(XrGeometryInstanceFB) XR_DEFINE_HANDLE(XrGeometryInstanceFB)
#define XR_FB_passthrough_SPEC_VERSION 2 #define XR_FB_passthrough_SPEC_VERSION 3
#define XR_FB_PASSTHROUGH_EXTENSION_NAME "XR_FB_passthrough" #define XR_FB_PASSTHROUGH_EXTENSION_NAME "XR_FB_passthrough"
#define XR_PASSTHROUGH_COLOR_MAP_MONO_SIZE_FB 256 #define XR_PASSTHROUGH_COLOR_MAP_MONO_SIZE_FB 256
@ -3636,10 +3644,18 @@ typedef enum XrPassthroughLayerPurposeFB {
XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_MASKED_HANDS_FB = 1000203002, XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_MASKED_HANDS_FB = 1000203002,
XR_PASSTHROUGH_LAYER_PURPOSE_MAX_ENUM_FB = 0x7FFFFFFF XR_PASSTHROUGH_LAYER_PURPOSE_MAX_ENUM_FB = 0x7FFFFFFF
} XrPassthroughLayerPurposeFB; } XrPassthroughLayerPurposeFB;
typedef XrFlags64 XrPassthroughCapabilityFlagsFB;
// Flag bits for XrPassthroughCapabilityFlagsFB
static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_BIT_FB = 0x00000001;
static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB = 0x00000002;
static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_LAYER_DEPTH_BIT_FB = 0x00000004;
typedef XrFlags64 XrPassthroughFlagsFB; typedef XrFlags64 XrPassthroughFlagsFB;
// Flag bits for XrPassthroughFlagsFB // Flag bits for XrPassthroughFlagsFB
static const XrPassthroughFlagsFB XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB = 0x00000001; static const XrPassthroughFlagsFB XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB = 0x00000001;
static const XrPassthroughFlagsFB XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB = 0x00000002;
typedef XrFlags64 XrPassthroughStateChangedFlagsFB; typedef XrFlags64 XrPassthroughStateChangedFlagsFB;
@ -3656,6 +3672,13 @@ typedef struct XrSystemPassthroughPropertiesFB {
XrBool32 supportsPassthrough; XrBool32 supportsPassthrough;
} XrSystemPassthroughPropertiesFB; } XrSystemPassthroughPropertiesFB;
// XrSystemPassthroughProperties2FB extends XrSystemProperties
typedef struct XrSystemPassthroughProperties2FB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
XrPassthroughCapabilityFlagsFB capabilities;
} XrSystemPassthroughProperties2FB;
typedef struct XrPassthroughCreateInfoFB { typedef struct XrPassthroughCreateInfoFB {
XrStructureType type; XrStructureType type;
const void* XR_MAY_ALIAS next; const void* XR_MAY_ALIAS next;
@ -3801,7 +3824,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGeometryInstanceSetTransformFB(
#define XR_NULL_RENDER_MODEL_KEY_FB 0 #define XR_NULL_RENDER_MODEL_KEY_FB 0
XR_DEFINE_ATOM(XrRenderModelKeyFB) XR_DEFINE_ATOM(XrRenderModelKeyFB)
#define XR_FB_render_model_SPEC_VERSION 2 #define XR_FB_render_model_SPEC_VERSION 3
#define XR_FB_RENDER_MODEL_EXTENSION_NAME "XR_FB_render_model" #define XR_FB_RENDER_MODEL_EXTENSION_NAME "XR_FB_render_model"
#define XR_MAX_RENDER_MODEL_NAME_SIZE_FB 64 #define XR_MAX_RENDER_MODEL_NAME_SIZE_FB 64
typedef XrFlags64 XrRenderModelFlagsFB; typedef XrFlags64 XrRenderModelFlagsFB;
@ -4007,6 +4030,11 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetViewOffsetVARJO(
#endif /* !XR_NO_PROTOTYPES */ #endif /* !XR_NO_PROTOTYPES */
#define XR_ML_ml2_controller_interaction 1
#define XR_ML_ml2_controller_interaction_SPEC_VERSION 1
#define XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_ML_ml2_controller_interaction"
#define XR_MSFT_spatial_anchor_persistence 1 #define XR_MSFT_spatial_anchor_persistence 1
XR_DEFINE_HANDLE(XrSpatialAnchorStoreConnectionMSFT) XR_DEFINE_HANDLE(XrSpatialAnchorStoreConnectionMSFT)
#define XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT 256 #define XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT 256
@ -4303,6 +4331,93 @@ typedef struct XrSystemSpaceWarpPropertiesFB {
#define XR_FB_scene 1
#define XR_FB_scene_SPEC_VERSION 1
#define XR_FB_SCENE_EXTENSION_NAME "XR_FB_scene"
typedef struct XrExtent3DfFB {
float width;
float height;
float depth;
} XrExtent3DfFB;
typedef struct XrOffset3DfFB {
float x;
float y;
float z;
} XrOffset3DfFB;
typedef struct XrRect3DfFB {
XrOffset3DfFB offset;
XrExtent3DfFB extent;
} XrRect3DfFB;
typedef struct XrSemanticLabelsFB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
uint32_t bufferCapacityInput;
uint32_t bufferCountOutput;
char* buffer;
} XrSemanticLabelsFB;
typedef struct XrRoomLayoutFB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
XrUuidEXT floorUuid;
XrUuidEXT ceilingUuid;
uint32_t wallUuidCapacityInput;
uint32_t wallUuidCountOutput;
XrUuidEXT* wallUuids;
} XrRoomLayoutFB;
typedef struct XrBoundary2DFB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
uint32_t vertexCapacityInput;
uint32_t vertexCountOutput;
XrVector2f* vertices;
} XrBoundary2DFB;
typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundingBox2DFB)(XrSession session, XrSpace space, XrRect2Df* boundingBox2DOutput);
typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundingBox3DFB)(XrSession session, XrSpace space, XrRect3DfFB* boundingBox3DOutput);
typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceSemanticLabelsFB)(XrSession session, XrSpace space, XrSemanticLabelsFB* semanticLabelsOutput);
typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundary2DFB)(XrSession session, XrSpace space, XrBoundary2DFB* boundary2DOutput);
typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceRoomLayoutFB)(XrSession session, XrSpace space, XrRoomLayoutFB* roomLayoutOutput);
#ifndef XR_NO_PROTOTYPES
#ifdef XR_EXTENSION_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundingBox2DFB(
XrSession session,
XrSpace space,
XrRect2Df* boundingBox2DOutput);
XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundingBox3DFB(
XrSession session,
XrSpace space,
XrRect3DfFB* boundingBox3DOutput);
XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceSemanticLabelsFB(
XrSession session,
XrSpace space,
XrSemanticLabelsFB* semanticLabelsOutput);
XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundary2DFB(
XrSession session,
XrSpace space,
XrBoundary2DFB* boundary2DOutput);
XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceRoomLayoutFB(
XrSession session,
XrSpace space,
XrRoomLayoutFB* roomLayoutOutput);
#endif /* XR_EXTENSION_PROTOTYPES */
#endif /* !XR_NO_PROTOTYPES */
#define XR_EXT_palm_pose 1
#define XR_EXT_palm_pose_SPEC_VERSION 2
#define XR_EXT_PALM_POSE_EXTENSION_NAME "XR_EXT_palm_pose"
#define XR_ALMALENCE_digital_lens_control 1 #define XR_ALMALENCE_digital_lens_control 1
#define XR_ALMALENCE_digital_lens_control_SPEC_VERSION 1 #define XR_ALMALENCE_digital_lens_control_SPEC_VERSION 1
#define XR_ALMALENCE_DIGITAL_LENS_CONTROL_EXTENSION_NAME "XR_ALMALENCE_digital_lens_control" #define XR_ALMALENCE_DIGITAL_LENS_CONTROL_EXTENSION_NAME "XR_ALMALENCE_digital_lens_control"
@ -4329,13 +4444,13 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetDigitalLensControlALMALENCE(
#define XR_FB_spatial_entity_container 1 #define XR_FB_spatial_entity_container 1
#define XR_FB_spatial_entity_container_SPEC_VERSION 1 #define XR_FB_spatial_entity_container_SPEC_VERSION 2
#define XR_FB_SPATIAL_ENTITY_CONTAINER_EXTENSION_NAME "XR_FB_spatial_entity_container" #define XR_FB_SPATIAL_ENTITY_CONTAINER_EXTENSION_NAME "XR_FB_spatial_entity_container"
typedef struct XrSpaceContainerFB { typedef struct XrSpaceContainerFB {
XrStructureType type; XrStructureType type;
const void* XR_MAY_ALIAS next; const void* XR_MAY_ALIAS next;
uint32_t uuidCapacityInput; uint32_t uuidCapacityInput;
uint32_t* uuidCountOutput; uint32_t uuidCountOutput;
XrUuidEXT* uuids; XrUuidEXT* uuids;
} XrSpaceContainerFB; } XrSpaceContainerFB;

View File

@ -2,7 +2,7 @@
#define OPENXR_PLATFORM_H_ 1 #define OPENXR_PLATFORM_H_ 1
/* /*
** Copyright (c) 2017-2022, The Khronos Group Inc. ** Copyright 2017-2022 The Khronos Group Inc.
** **
** SPDX-License-Identifier: Apache-2.0 OR MIT ** SPDX-License-Identifier: Apache-2.0 OR MIT
*/ */

View File

@ -302,6 +302,7 @@ XR_ENUM_STR(XrResult);
_(XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB, 1000118003) \ _(XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB, 1000118003) \
_(XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB, 1000118004) \ _(XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB, 1000118004) \
_(XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB, 1000118005) \ _(XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB, 1000118005) \
_(XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB, 1000118006) \
_(XR_TYPE_PASSTHROUGH_STYLE_FB, 1000118020) \ _(XR_TYPE_PASSTHROUGH_STYLE_FB, 1000118020) \
_(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB, 1000118021) \ _(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB, 1000118021) \
_(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB, 1000118022) \ _(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB, 1000118022) \
@ -340,6 +341,9 @@ XR_ENUM_STR(XrResult);
_(XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB, 1000163000) \ _(XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB, 1000163000) \
_(XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB, 1000171000) \ _(XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB, 1000171000) \
_(XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB, 1000171001) \ _(XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB, 1000171001) \
_(XR_TYPE_SEMANTIC_LABELS_FB, 1000175000) \
_(XR_TYPE_ROOM_LAYOUT_FB, 1000175001) \
_(XR_TYPE_BOUNDARY_2D_FB, 1000175002) \
_(XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE, 1000196000) \ _(XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE, 1000196000) \
_(XR_TYPE_SPACE_CONTAINER_FB, 1000199000) \ _(XR_TYPE_SPACE_CONTAINER_FB, 1000199000) \
_(XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB, 1000203002) \ _(XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB, 1000203002) \
@ -660,6 +664,10 @@ XR_ENUM_STR(XrResult);
#define XR_LIST_ENUM_XrSpaceComponentTypeFB(_) \ #define XR_LIST_ENUM_XrSpaceComponentTypeFB(_) \
_(XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB, 0) \ _(XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB, 0) \
_(XR_SPACE_COMPONENT_TYPE_STORABLE_FB, 1) \ _(XR_SPACE_COMPONENT_TYPE_STORABLE_FB, 1) \
_(XR_SPACE_COMPONENT_TYPE_BOUNDED_2D_FB, 3) \
_(XR_SPACE_COMPONENT_TYPE_BOUNDED_3D_FB, 4) \
_(XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB, 5) \
_(XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB, 6) \
_(XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB, 7) \ _(XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB, 7) \
_(XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB, 0x7FFFFFFF) _(XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB, 0x7FFFFFFF)
@ -847,8 +855,14 @@ XR_ENUM_STR(XrResult);
#define XR_LIST_BITS_XrTriangleMeshFlagsFB(_) \ #define XR_LIST_BITS_XrTriangleMeshFlagsFB(_) \
_(XR_TRIANGLE_MESH_MUTABLE_BIT_FB, 0x00000001) \ _(XR_TRIANGLE_MESH_MUTABLE_BIT_FB, 0x00000001) \
#define XR_LIST_BITS_XrPassthroughCapabilityFlagsFB(_) \
_(XR_PASSTHROUGH_CAPABILITY_BIT_FB, 0x00000001) \
_(XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB, 0x00000002) \
_(XR_PASSTHROUGH_CAPABILITY_LAYER_DEPTH_BIT_FB, 0x00000004) \
#define XR_LIST_BITS_XrPassthroughFlagsFB(_) \ #define XR_LIST_BITS_XrPassthroughFlagsFB(_) \
_(XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB, 0x00000001) \ _(XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB, 0x00000001) \
_(XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB, 0x00000002) \
#define XR_LIST_BITS_XrPassthroughStateChangedFlagsFB(_) \ #define XR_LIST_BITS_XrPassthroughStateChangedFlagsFB(_) \
_(XR_PASSTHROUGH_STATE_CHANGED_REINIT_REQUIRED_BIT_FB, 0x00000001) \ _(XR_PASSTHROUGH_STATE_CHANGED_REINIT_REQUIRED_BIT_FB, 0x00000001) \
@ -2288,6 +2302,11 @@ XR_ENUM_STR(XrResult);
_(next) \ _(next) \
_(supportsPassthrough) \ _(supportsPassthrough) \
#define XR_LIST_STRUCT_XrSystemPassthroughProperties2FB(_) \
_(type) \
_(next) \
_(capabilities) \
#define XR_LIST_STRUCT_XrPassthroughCreateInfoFB(_) \ #define XR_LIST_STRUCT_XrPassthroughCreateInfoFB(_) \
_(type) \ _(type) \
_(next) \ _(next) \
@ -2589,6 +2608,43 @@ XR_ENUM_STR(XrResult);
_(recommendedMotionVectorImageRectWidth) \ _(recommendedMotionVectorImageRectWidth) \
_(recommendedMotionVectorImageRectHeight) \ _(recommendedMotionVectorImageRectHeight) \
#define XR_LIST_STRUCT_XrExtent3DfFB(_) \
_(width) \
_(height) \
_(depth) \
#define XR_LIST_STRUCT_XrOffset3DfFB(_) \
_(x) \
_(y) \
_(z) \
#define XR_LIST_STRUCT_XrRect3DfFB(_) \
_(offset) \
_(extent) \
#define XR_LIST_STRUCT_XrSemanticLabelsFB(_) \
_(type) \
_(next) \
_(bufferCapacityInput) \
_(bufferCountOutput) \
_(buffer) \
#define XR_LIST_STRUCT_XrRoomLayoutFB(_) \
_(type) \
_(next) \
_(floorUuid) \
_(ceilingUuid) \
_(wallUuidCapacityInput) \
_(wallUuidCountOutput) \
_(wallUuids) \
#define XR_LIST_STRUCT_XrBoundary2DFB(_) \
_(type) \
_(next) \
_(vertexCapacityInput) \
_(vertexCountOutput) \
_(vertices) \
#define XR_LIST_STRUCT_XrDigitalLensControlALMALENCE(_) \ #define XR_LIST_STRUCT_XrDigitalLensControlALMALENCE(_) \
_(type) \ _(type) \
_(next) \ _(next) \
@ -2785,6 +2841,7 @@ XR_ENUM_STR(XrResult);
_(XrKeyboardTrackingQueryFB, XR_TYPE_KEYBOARD_TRACKING_QUERY_FB) \ _(XrKeyboardTrackingQueryFB, XR_TYPE_KEYBOARD_TRACKING_QUERY_FB) \
_(XrTriangleMeshCreateInfoFB, XR_TYPE_TRIANGLE_MESH_CREATE_INFO_FB) \ _(XrTriangleMeshCreateInfoFB, XR_TYPE_TRIANGLE_MESH_CREATE_INFO_FB) \
_(XrSystemPassthroughPropertiesFB, XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB) \ _(XrSystemPassthroughPropertiesFB, XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB) \
_(XrSystemPassthroughProperties2FB, XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB) \
_(XrPassthroughCreateInfoFB, XR_TYPE_PASSTHROUGH_CREATE_INFO_FB) \ _(XrPassthroughCreateInfoFB, XR_TYPE_PASSTHROUGH_CREATE_INFO_FB) \
_(XrPassthroughLayerCreateInfoFB, XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB) \ _(XrPassthroughLayerCreateInfoFB, XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB) \
_(XrCompositionLayerPassthroughFB, XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB) \ _(XrCompositionLayerPassthroughFB, XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB) \
@ -2823,6 +2880,9 @@ XR_ENUM_STR(XrResult);
_(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \ _(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
_(XrCompositionLayerSpaceWarpInfoFB, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB) \ _(XrCompositionLayerSpaceWarpInfoFB, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB) \
_(XrSystemSpaceWarpPropertiesFB, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB) \ _(XrSystemSpaceWarpPropertiesFB, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB) \
_(XrSemanticLabelsFB, XR_TYPE_SEMANTIC_LABELS_FB) \
_(XrRoomLayoutFB, XR_TYPE_ROOM_LAYOUT_FB) \
_(XrBoundary2DFB, XR_TYPE_BOUNDARY_2D_FB) \
_(XrDigitalLensControlALMALENCE, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE) \ _(XrDigitalLensControlALMALENCE, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE) \
_(XrSpaceContainerFB, XR_TYPE_SPACE_CONTAINER_FB) \ _(XrSpaceContainerFB, XR_TYPE_SPACE_CONTAINER_FB) \
_(XrPassthroughKeyboardHandsIntensityFB, XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB) \ _(XrPassthroughKeyboardHandsIntensityFB, XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB) \
@ -3071,6 +3131,7 @@ XR_ENUM_STR(XrResult);
_(XR_VARJO_environment_depth_estimation, 124) \ _(XR_VARJO_environment_depth_estimation, 124) \
_(XR_VARJO_marker_tracking, 125) \ _(XR_VARJO_marker_tracking, 125) \
_(XR_VARJO_view_offset, 126) \ _(XR_VARJO_view_offset, 126) \
_(XR_ML_ml2_controller_interaction, 135) \
_(XR_MSFT_spatial_anchor_persistence, 143) \ _(XR_MSFT_spatial_anchor_persistence, 143) \
_(XR_ULTRALEAP_hand_tracking_forearm, 150) \ _(XR_ULTRALEAP_hand_tracking_forearm, 150) \
_(XR_FB_spatial_entity_query, 157) \ _(XR_FB_spatial_entity_query, 157) \
@ -3082,6 +3143,8 @@ XR_ENUM_STR(XrResult);
_(XR_FB_swapchain_update_state_vulkan, 164) \ _(XR_FB_swapchain_update_state_vulkan, 164) \
_(XR_KHR_swapchain_usage_input_attachment_bit, 166) \ _(XR_KHR_swapchain_usage_input_attachment_bit, 166) \
_(XR_FB_space_warp, 172) \ _(XR_FB_space_warp, 172) \
_(XR_FB_scene, 176) \
_(XR_EXT_palm_pose, 177) \
_(XR_ALMALENCE_digital_lens_control, 197) \ _(XR_ALMALENCE_digital_lens_control, 197) \
_(XR_FB_spatial_entity_container, 200) \ _(XR_FB_spatial_entity_container, 200) \
_(XR_FB_passthrough_keyboard_hands, 204) \ _(XR_FB_passthrough_keyboard_hands, 204) \

View File

@ -0,0 +1,33 @@
// Copyright (c) 2017-2022, The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
#pragma once
#ifdef XR_USE_PLATFORM_ANDROID
#include <memory>
#include <android/asset_manager.h>
namespace deleters {
struct AAssetDeleter {
void operator()(AAsset* asset) const noexcept {
if (asset != nullptr) {
AAsset_close(asset);
}
}
};
struct AAssetDirDeleter {
void operator()(AAssetDir* dir) const noexcept {
if (dir != nullptr) {
AAssetDir_close(dir);
}
}
};
} // namespace deleters
using UniqueAsset = std::unique_ptr<AAsset, deleters::AAssetDeleter>;
using UniqueAssetDir = std::unique_ptr<AAssetDir, deleters::AAssetDirDeleter>;
#endif

View File

@ -299,7 +299,7 @@ int getActiveRuntimeVirtualManifest(wrap::android::content::Context const &conte
auto hasFunctions = cursor.getInt(cursor.getColumnIndex(active_runtime::Columns::HAS_FUNCTIONS)) == 1; auto hasFunctions = cursor.getInt(cursor.getColumnIndex(active_runtime::Columns::HAS_FUNCTIONS)) == 1;
__android_log_print(ANDROID_LOG_INFO, TAG, "Got runtime: package: %s, so filename: %s, native lib dir: %s, has functions: %s", __android_log_print(ANDROID_LOG_INFO, TAG, "Got runtime: package: %s, so filename: %s, native lib dir: %s, has functions: %s",
packageName.c_str(), libDir.c_str(), filename.c_str(), (hasFunctions ? "yes" : "no")); packageName.c_str(), filename.c_str(), libDir.c_str(), (hasFunctions ? "yes" : "no"));
auto lib_path = libDir + "/" + filename; auto lib_path = libDir + "/" + filename;
cursor.close(); cursor.close();

View File

@ -53,7 +53,6 @@ XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_comm
uint32_t* outgoing_count, XrApiLayerProperties* api_layer_properties) { uint32_t* outgoing_count, XrApiLayerProperties* api_layer_properties) {
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files; std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
uint32_t manifest_count = 0; uint32_t manifest_count = 0;
// Validate props struct before proceeding // Validate props struct before proceeding
if (0 < incoming_count && nullptr != api_layer_properties) { if (0 < incoming_count && nullptr != api_layer_properties) {
for (uint32_t i = 0; i < incoming_count; i++) { for (uint32_t i = 0; i < incoming_count; i++) {

View File

@ -711,9 +711,6 @@ XRLOADER_ABI_CATCH_FALLBACK
XRAPI_ATTR XrResult XRAPI_CALL LoaderXrGetInstanceProcAddr(XrInstance instance, const char *name, XRAPI_ATTR XrResult XRAPI_CALL LoaderXrGetInstanceProcAddr(XrInstance instance, const char *name,
PFN_xrVoidFunction *function) XRLOADER_ABI_TRY { PFN_xrVoidFunction *function) XRLOADER_ABI_TRY {
// Initialize the function to nullptr in case it does not get caught in a known case
*function = nullptr;
if (nullptr == function) { if (nullptr == function) {
LoaderLogger::LogValidationErrorMessage("VUID-xrGetInstanceProcAddr-function-parameter", "xrGetInstanceProcAddr", LoaderLogger::LogValidationErrorMessage("VUID-xrGetInstanceProcAddr-function-parameter", "xrGetInstanceProcAddr",
"Invalid Function pointer"); "Invalid Function pointer");
@ -726,6 +723,9 @@ XRAPI_ATTR XrResult XRAPI_CALL LoaderXrGetInstanceProcAddr(XrInstance instance,
return XR_ERROR_VALIDATION_FAILURE; return XR_ERROR_VALIDATION_FAILURE;
} }
// Initialize the function to nullptr in case it does not get caught in a known case
*function = nullptr;
LoaderInstance *loader_instance = nullptr; LoaderInstance *loader_instance = nullptr;
if (instance == XR_NULL_HANDLE) { if (instance == XR_NULL_HANDLE) {
// Null instance is allowed for a few specific API entry points, otherwise return error // Null instance is allowed for a few specific API entry points, otherwise return error

View File

@ -21,6 +21,7 @@
#include "loader_platform.hpp" #include "loader_platform.hpp"
#include "platform_utils.hpp" #include "platform_utils.hpp"
#include "loader_logger.hpp" #include "loader_logger.hpp"
#include "unique_asset.h"
#include <json/json.h> #include <json/json.h>
#include <openxr/openxr.h> #include <openxr/openxr.h>
@ -50,6 +51,10 @@
#define SYSCONFDIR "/etc" #define SYSCONFDIR "/etc"
#endif // !SYSCONFDIR #endif // !SYSCONFDIR
#ifdef XR_USE_PLATFORM_ANDROID
#include <android/asset_manager.h>
#endif
#ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING #ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING
#if JSON_USE_EXCEPTIONS #if JSON_USE_EXCEPTIONS
#error \ #error \
@ -656,17 +661,68 @@ ApiLayerManifestFile::ApiLayerManifestFile(ManifestFileType type, const std::str
_description(description), _description(description),
_implementation_version(implementation_version) {} _implementation_version(implementation_version) {}
void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename, #ifdef XR_USE_PLATFORM_ANDROID
std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) { void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type,
std::ifstream json_stream(filename, std::ifstream::in); std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
AAssetManager *assetManager = (AAssetManager *)Android_Get_Asset_Manager();
std::vector<std::string> filenames;
{
std::string search_path = "";
switch (type) {
case MANIFEST_TYPE_IMPLICIT_API_LAYER:
search_path = "openxr/1/api_layers/implicit.d/";
break;
case MANIFEST_TYPE_EXPLICIT_API_LAYER:
search_path = "openxr/1/api_layers/explicit.d/";
break;
default:
return;
}
std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid "); UniqueAssetDir dir{AAssetManager_openDir(assetManager, search_path.c_str())};
if (!json_stream.is_open()) { if (!dir) {
error_ss << "failed to open " << filename << ". Does it exist?"; return;
LoaderLogger::LogErrorMessage("", error_ss.str()); }
return; const std::string json = ".json";
const char *fn = nullptr;
while ((fn = AAssetDir_getNextFileName(dir.get())) != nullptr) {
const std::string filename = search_path + fn;
if (filename.size() < json.size()) {
continue;
}
if (filename.compare(filename.size() - json.size(), json.size(), json) == 0) {
filenames.push_back(filename);
}
}
} }
for (const auto &filename : filenames) {
UniqueAsset asset{AAssetManager_open(assetManager, filename.c_str(), AASSET_MODE_BUFFER)};
if (!asset) {
LoaderLogger::LogWarningMessage(
"", "ApiLayerManifestFile::AddManifestFilesAndroid unable to open asset " + filename + ", skipping");
continue;
}
size_t length = AAsset_getLength(asset.get());
const char *buf = reinterpret_cast<const char *>(AAsset_getBuffer(asset.get()));
if (!buf) {
LoaderLogger::LogWarningMessage(
"", "ApiLayerManifestFile::AddManifestFilesAndroid unable to access asset" + filename + ", skipping");
continue;
}
std::istringstream json_stream(std::string{buf, length});
CreateIfValid(ManifestFileType::MANIFEST_TYPE_EXPLICIT_API_LAYER, filename, json_stream,
&ApiLayerManifestFile::LocateLibraryInAssets, manifest_files);
}
}
#endif // XR_USE_PLATFORM_ANDROID
void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename, std::istream &json_stream,
LibraryLocator locate_library,
std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid ");
Json::CharReaderBuilder builder; Json::CharReaderBuilder builder;
std::string errors; std::string errors;
Json::Value root_node = Json::nullValue; Json::Value root_node = Json::nullValue;
@ -757,9 +813,7 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
} else { } else {
// Otherwise, treat the library path as a relative path based on the JSON file. // Otherwise, treat the library path as a relative path based on the JSON file.
std::string combined_path; std::string combined_path;
std::string file_parent; if (!locate_library(filename, library_path, combined_path)) {
if (!FileSysUtilsGetParentPath(filename, file_parent) ||
!FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
error_ss << filename << " library " << combined_path << " does not appear to exist"; error_ss << filename << " library " << combined_path << " does not appear to exist";
LoaderLogger::LogErrorMessage("", error_ss.str()); LoaderLogger::LogErrorMessage("", error_ss.str());
return; return;
@ -781,6 +835,46 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
manifest_files.back()->ParseCommon(layer_root_node); manifest_files.back()->ParseCommon(layer_root_node);
} }
void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename,
std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
std::ifstream json_stream(filename, std::ifstream::in);
if (!json_stream.is_open()) {
std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid ");
error_ss << "failed to open " << filename << ". Does it exist?";
LoaderLogger::LogErrorMessage("", error_ss.str());
return;
}
CreateIfValid(type, filename, json_stream, &ApiLayerManifestFile::LocateLibraryRelativeToJson, manifest_files);
}
bool ApiLayerManifestFile::LocateLibraryRelativeToJson(
const std::string &json_filename, const std::string &library_path,
std::string &out_combined_path) { // Otherwise, treat the library path as a relative path based on the JSON file.
std::string combined_path;
std::string file_parent;
if (!FileSysUtilsGetParentPath(json_filename, file_parent) ||
!FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
out_combined_path = combined_path;
return false;
}
out_combined_path = combined_path;
return true;
}
#ifdef XR_USE_PLATFORM_ANDROID
bool ApiLayerManifestFile::LocateLibraryInAssets(const std::string & /* json_filename */, const std::string &library_path,
std::string &out_combined_path) {
std::string combined_path;
std::string file_parent = GetAndroidNativeLibraryDir();
if (!FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
out_combined_path = combined_path;
return false;
}
out_combined_path = combined_path;
return true;
}
#endif
void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &props) const { void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &props) const {
props.layerVersion = _implementation_version; props.layerVersion = _implementation_version;
props.specVersion = XR_MAKE_VERSION(_api_version.major, _api_version.minor, _api_version.patch); props.specVersion = XR_MAKE_VERSION(_api_version.major, _api_version.minor, _api_version.patch);
@ -841,5 +935,9 @@ XrResult ApiLayerManifestFile::FindManifestFiles(ManifestFileType type,
ApiLayerManifestFile::CreateIfValid(type, cur_file, manifest_files); ApiLayerManifestFile::CreateIfValid(type, cur_file, manifest_files);
} }
#ifdef XR_USE_PLATFORM_ANDROID
ApiLayerManifestFile::AddManifestFilesAndroid(type, manifest_files);
#endif // XR_USE_PLATFORM_ANDROID
return XR_SUCCESS; return XR_SUCCESS;
} }

View File

@ -14,6 +14,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include <iosfwd>
#include <unordered_map> #include <unordered_map>
namespace Json { namespace Json {
@ -79,6 +80,8 @@ class RuntimeManifestFile : public ManifestFile {
std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files); std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files);
}; };
using LibraryLocator = bool (*)(const std::string &json_filename, const std::string &library_path, std::string &out_combined_path);
// ApiLayerManifestFile class - // ApiLayerManifestFile class -
// Responsible for finding and parsing API Layer-specific manifest files. // Responsible for finding and parsing API Layer-specific manifest files.
class ApiLayerManifestFile : public ManifestFile { class ApiLayerManifestFile : public ManifestFile {
@ -93,8 +96,19 @@ class ApiLayerManifestFile : public ManifestFile {
ApiLayerManifestFile(ManifestFileType type, const std::string &filename, const std::string &layer_name, ApiLayerManifestFile(ManifestFileType type, const std::string &filename, const std::string &layer_name,
const std::string &description, const JsonVersion &api_version, const uint32_t &implementation_version, const std::string &description, const JsonVersion &api_version, const uint32_t &implementation_version,
const std::string &library_path); const std::string &library_path);
static void CreateIfValid(ManifestFileType type, const std::string &filename, std::istream &json_stream,
LibraryLocator locate_library, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
static void CreateIfValid(ManifestFileType type, const std::string &filename, static void CreateIfValid(ManifestFileType type, const std::string &filename,
std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files); std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
/// @return false if we could not find the library.
static bool LocateLibraryRelativeToJson(const std::string &json_filename, const std::string &library_path,
std::string &out_combined_path);
#ifdef XR_USE_PLATFORM_ANDROID
static bool LocateLibraryInAssets(const std::string &json_filename, const std::string &library_path,
std::string &out_combined_path);
static void AddManifestFilesAndroid(ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
#endif
JsonVersion _api_version; JsonVersion _api_version;
std::string _layer_name; std::string _layer_name;

View File

@ -27,6 +27,7 @@
#ifdef XR_USE_PLATFORM_ANDROID #ifdef XR_USE_PLATFORM_ANDROID
#include "android_utilities.h" #include "android_utilities.h"
#include <android/asset_manager_jni.h>
#include <json/value.h> #include <json/value.h>
#endif // XR_USE_PLATFORM_ANDROID #endif // XR_USE_PLATFORM_ANDROID
@ -50,6 +51,14 @@ class LoaderInitData {
* Type alias for the platform-specific structure type. * Type alias for the platform-specific structure type.
*/ */
using StructType = XrLoaderInitInfoAndroidKHR; using StructType = XrLoaderInitInfoAndroidKHR;
/*!
* Native library path.
*/
std::string _native_library_path;
/*!
* Android asset manager.
*/
AAssetManager* _android_asset_manager;
#endif #endif
/*! /*!
@ -99,6 +108,30 @@ XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) {
_data = *cast_info; _data = *cast_info;
jni::init((jni::JavaVM*)_data.applicationVM); jni::init((jni::JavaVM*)_data.applicationVM);
_data.next = nullptr; _data.next = nullptr;
JNIEnv* Env;
((jni::JavaVM*)(cast_info->applicationVM))->AttachCurrentThread(&Env, nullptr);
const jclass contextClass = Env->GetObjectClass((jobject)_data.applicationContext);
const jmethodID getAssetsMethod = Env->GetMethodID(contextClass, "getAssets", "()Landroid/content/res/AssetManager;");
const jobject AssetManagerObject = Env->CallObjectMethod((jobject)_data.applicationContext, getAssetsMethod);
_android_asset_manager = AAssetManager_fromJava(Env, AssetManagerObject);
const jmethodID getApplicationContextMethod =
Env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;");
const jobject contextObject = Env->CallObjectMethod((jobject)_data.applicationContext, getApplicationContextMethod);
const jmethodID getApplicationInfoMethod =
Env->GetMethodID(contextClass, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
const jobject applicationInfoObject = Env->CallObjectMethod(contextObject, getApplicationInfoMethod);
const jfieldID nativeLibraryDirField =
Env->GetFieldID(Env->GetObjectClass(applicationInfoObject), "nativeLibraryDir", "Ljava/lang/String;");
const jobject nativeLibraryDirObject = Env->GetObjectField(applicationInfoObject, nativeLibraryDirField);
const jmethodID getBytesMethod =
Env->GetMethodID(Env->GetObjectClass(nativeLibraryDirObject), "getBytes", "(Ljava/lang/String;)[B");
const auto bytesObject =
static_cast<jbyteArray>(Env->CallObjectMethod(nativeLibraryDirObject, getBytesMethod, Env->NewStringUTF("UTF-8")));
const size_t length = Env->GetArrayLength(bytesObject);
const jbyte* const bytes = Env->GetByteArrayElements(bytesObject, nullptr);
_native_library_path = std::string(reinterpret_cast<const char*>(bytes), length);
_initialized = true; _initialized = true;
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -109,6 +142,10 @@ XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo) {
return LoaderInitData::instance().initialize(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 #endif // XR_KHR_LOADER_INIT_SUPPORT
#ifdef XR_USE_PLATFORM_ANDROID #ifdef XR_USE_PLATFORM_ANDROID

View File

@ -31,6 +31,8 @@ class Value;
//! Initialize loader, where required. //! Initialize loader, where required.
XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo); XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo);
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest); XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest);
std::string GetAndroidNativeLibraryDir();
void* Android_Get_Asset_Manager();
#endif #endif
class RuntimeManifestFile; class RuntimeManifestFile;