Update sample with latest XrUtility, SDK 1.0.29, and bug fixes. (#126)
* Update xrutility and samples * Update to 1.0.29 headers * Remove unused NVOF lib.
This commit is contained in:
Родитель
b893f615a8
Коммит
65f4723052
|
@ -30,8 +30,8 @@ The [openxr_preview](https://github.com/microsoft/OpenXR-MixedReality/tree/main/
|
|||
[openxr_msft_preview.h](https://github.com/microsoft/OpenXR-MixedReality/tree/main/openxr_preview/include/openxr/openxr_msft_preview.h) header to offer
|
||||
the following OpenXR extensions that are only available [in preview runtime](http://aka.ms/openxr-preview).
|
||||
|
||||
1. [XR_EXTX_hand_interaction](https://github.com/microsoft/OpenXR-MixedReality/tree/main/openxr_preview/include/openxr/preview/xr_ext_hand_interaction.h)
|
||||
2. [XR_MSFTX_scene_marker](https://github.com/microsoft/OpenXR-MixedReality/tree/main/openxr_preview/include/openxr/preview/xr_msft_scene_marker.h)
|
||||
1. [XR_EXT_user_presence](https://github.com/microsoft/OpenXR-MixedReality/tree/main/openxr_preview/include/openxr/openxr.h)
|
||||
2. [XR_MSFT_scene_marker](https://github.com/microsoft/OpenXR-MixedReality/tree/main/openxr_preview/include/openxr/openxr.h)
|
||||
|
||||
Please send feedback on preview extensions and samples at [GitHub issues](https://github.com/microsoft/OpenXR-MixedReality/issues).
|
||||
We are planning to incorporate your feedback and finalize these extensions as vendor extensions (MSFT) or cross-vendor extensions (EXT)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) Microsoft Corporation. All Rights Reserved
|
||||
|
||||
#include "preview/xr_ext_hand_interaction.h"
|
||||
#include "preview/xr_msft_scene_marker.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Supports XrStructTraits and ValidateStruct
|
||||
#define XR_LIST_STRUCTURE_TYPES_MSFT_PREVIEW(_) \
|
||||
XR_LIST_STRUCTURE_TYPES_EXT_hand_interaction(_) \
|
||||
XR_LIST_STRUCTURE_TYPES_MSFT_scene_marker(_)
|
||||
|
||||
// Supports IXrExtensionConfiguration.EnabledExtensions()
|
||||
#define XR_LIST_EXTENSIONS_MSFT_PREVIEW(_) \
|
||||
XR_LIST_EXTENSIONS_EXT_hand_interaction(_) \
|
||||
XR_LIST_EXTENSIONS_MSFT_scene_marker(_)
|
||||
|
||||
// Supports xrStructureTypeToString and IsKnownStructType
|
||||
#define XR_LIST_ENUM_XrStructureType_MSFT_PREVIEW(_) \
|
||||
XR_LIST_ENUM_XrStructureType_EXT_hand_interaction(_) \
|
||||
XR_LIST_ENUM_XrStructureType_MSFT_scene_marker(_)
|
||||
|
||||
// Supports XrDispatchTable.h
|
||||
#define XR_LIST_FUNCTIONS_MSFT_PREVIEW(_) \
|
||||
XR_LIST_FUNCTIONS_MSFT_scene_marker(_)
|
||||
|
||||
// clang-format on
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_PLATFORM_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2017-2022 The Khronos Group Inc.
|
||||
** Copyright 2017-2023 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -454,9 +454,9 @@ typedef XrSwapchainImageVulkanKHR XrSwapchainImageVulkan2KHR;
|
|||
|
||||
typedef XrGraphicsRequirementsVulkanKHR XrGraphicsRequirementsVulkan2KHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanInstanceKHR)(XrInstance instance, const XrVulkanInstanceCreateInfoKHR* createInfo, VkInstance* vulkanInstance, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanDeviceKHR)(XrInstance instance, const XrVulkanDeviceCreateInfoKHR* createInfo, VkDevice* vulkanDevice, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDevice2KHR)(XrInstance instance, const XrVulkanGraphicsDeviceGetInfoKHR* getInfo, VkPhysicalDevice* vulkanPhysicalDevice);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanInstanceKHR)(XrInstance instance, const XrVulkanInstanceCreateInfoKHR* createInfo, VkInstance* vulkanInstance, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanDeviceKHR)(XrInstance instance, const XrVulkanDeviceCreateInfoKHR* createInfo, VkDevice* vulkanDevice, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDevice2KHR)(XrInstance instance, const XrVulkanGraphicsDeviceGetInfoKHR* getInfo, VkPhysicalDevice* vulkanPhysicalDevice);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsRequirements2KHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
|
@ -491,14 +491,15 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsRequirements2KHR(
|
|||
#define XR_MNDX_egl_enable 1
|
||||
#define XR_MNDX_egl_enable_SPEC_VERSION 1
|
||||
#define XR_MNDX_EGL_ENABLE_EXTENSION_NAME "XR_MNDX_egl_enable"
|
||||
typedef void *(*PFN_xrEglGetProcAddressMNDX)(const char *name);
|
||||
// XrGraphicsBindingEGLMNDX extends XrSessionCreateInfo
|
||||
typedef struct XrGraphicsBindingEGLMNDX {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
PFNEGLGETPROCADDRESSPROC getProcAddress;
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
PFN_xrEglGetProcAddressMNDX getProcAddress;
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
} XrGraphicsBindingEGLMNDX;
|
||||
|
||||
#endif /* XR_USE_PLATFORM_EGL */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -103,6 +103,10 @@ typedef unsigned __int64 uint64_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(XR_CPP_NULLPTR_SUPPORTED)
|
||||
#define XR_CPP_NULLPTR_SUPPORTED 0
|
||||
#endif // !defined(XR_CPP_NULLPTR_SUPPORTED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_REFLECTION_PARENT_STRUCTS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -58,12 +58,12 @@ This file contains expansion macros (X Macros) for OpenXR structures that have a
|
|||
_avail(XrEventDataSpatialAnchorCreateCompleteFB, XR_TYPE_EVENT_DATA_SPATIAL_ANCHOR_CREATE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceSetStatusCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SET_STATUS_COMPLETE_FB) \
|
||||
_avail(XrEventDataMarkerTrackingUpdateVARJO, XR_TYPE_EVENT_DATA_MARKER_TRACKING_UPDATE_VARJO) \
|
||||
_avail(XrEventDataChromaKeyConfigChangedVARJO, XR_TYPE_EVENT_DATA_CHROMA_KEY_CONFIG_CHANGED_VARJO) \
|
||||
_avail(XrEventDataCameraControlChangedVARJO, XR_TYPE_EVENT_DATA_CAMERA_CONTROL_CHANGED_VARJO) \
|
||||
_avail(XrEventDataSpaceQueryResultsAvailableFB, XR_TYPE_EVENT_DATA_SPACE_QUERY_RESULTS_AVAILABLE_FB) \
|
||||
_avail(XrEventDataSpaceQueryCompleteFB, XR_TYPE_EVENT_DATA_SPACE_QUERY_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SAVE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceShareCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SHARE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_REFLECTION_STRUCTS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -223,17 +223,13 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrSystemMarkerTrackingPropertiesVARJO, XR_TYPE_SYSTEM_MARKER_TRACKING_PROPERTIES_VARJO) \
|
||||
_avail(XrEventDataMarkerTrackingUpdateVARJO, XR_TYPE_EVENT_DATA_MARKER_TRACKING_UPDATE_VARJO) \
|
||||
_avail(XrMarkerSpaceCreateInfoVARJO, XR_TYPE_MARKER_SPACE_CREATE_INFO_VARJO) \
|
||||
_avail(XrSystemChromaKeyPropertiesVARJO, XR_TYPE_SYSTEM_CHROMA_KEY_PROPERTIES_VARJO) \
|
||||
_avail(XrCompositionLayerChromaKeyVARJO, XR_TYPE_COMPOSITION_LAYER_CHROMA_KEY_VARJO) \
|
||||
_avail(XrChromaKeyConfigVARJO, XR_TYPE_CHROMA_KEY_CONFIG_VARJO) \
|
||||
_avail(XrEventDataChromaKeyConfigChangedVARJO, XR_TYPE_EVENT_DATA_CHROMA_KEY_CONFIG_CHANGED_VARJO) \
|
||||
_avail(XrCameraControlValidValueVARJO, XR_TYPE_CAMERA_CONTROL_VALID_VALUE_VARJO) \
|
||||
_avail(XrCameraControlVARJO, XR_TYPE_CAMERA_CONTROL_VARJO) \
|
||||
_avail(XrEventDataCameraControlChangedVARJO, XR_TYPE_EVENT_DATA_CAMERA_CONTROL_CHANGED_VARJO) \
|
||||
_avail(XrFrameEndInfoML, XR_TYPE_FRAME_END_INFO_ML) \
|
||||
_avail(XrGlobalDimmerFrameEndInfoML, XR_TYPE_GLOBAL_DIMMER_FRAME_END_INFO_ML) \
|
||||
_avail(XrSpatialAnchorPersistenceInfoMSFT, XR_TYPE_SPATIAL_ANCHOR_PERSISTENCE_INFO_MSFT) \
|
||||
_avail(XrSpatialAnchorFromPersistedAnchorCreateInfoMSFT, XR_TYPE_SPATIAL_ANCHOR_FROM_PERSISTED_ANCHOR_CREATE_INFO_MSFT) \
|
||||
_avail(XrSceneMarkersMSFT, XR_TYPE_SCENE_MARKERS_MSFT) \
|
||||
_avail(XrSceneMarkerTypeFilterMSFT, XR_TYPE_SCENE_MARKER_TYPE_FILTER_MSFT) \
|
||||
_avail(XrSceneMarkerQRCodesMSFT, XR_TYPE_SCENE_MARKER_QR_CODES_MSFT) \
|
||||
_avail(XrSpaceQueryInfoFB, XR_TYPE_SPACE_QUERY_INFO_FB) \
|
||||
_avail(XrSpaceStorageLocationFilterInfoFB, XR_TYPE_SPACE_STORAGE_LOCATION_FILTER_INFO_FB) \
|
||||
_avail(XrSpaceUuidFilterInfoFB, XR_TYPE_SPACE_UUID_FILTER_INFO_FB) \
|
||||
|
@ -245,12 +241,15 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrSpaceEraseInfoFB, XR_TYPE_SPACE_ERASE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SAVE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
|
||||
_avail(XrSpaceShareInfoFB, XR_TYPE_SPACE_SHARE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceShareCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SHARE_COMPLETE_FB) \
|
||||
_avail(XrCompositionLayerSpaceWarpInfoFB, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB) \
|
||||
_avail(XrSystemSpaceWarpPropertiesFB, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB) \
|
||||
_avail(XrHapticAmplitudeEnvelopeVibrationFB, XR_TYPE_HAPTIC_AMPLITUDE_ENVELOPE_VIBRATION_FB) \
|
||||
_avail(XrSemanticLabelsFB, XR_TYPE_SEMANTIC_LABELS_FB) \
|
||||
_avail(XrRoomLayoutFB, XR_TYPE_ROOM_LAYOUT_FB) \
|
||||
_avail(XrBoundary2DFB, XR_TYPE_BOUNDARY_2D_FB) \
|
||||
_avail(XrSemanticLabelsSupportInfoFB, XR_TYPE_SEMANTIC_LABELS_SUPPORT_INFO_FB) \
|
||||
_avail(XrDigitalLensControlALMALENCE, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE) \
|
||||
_avail(XrEventDataSceneCaptureCompleteFB, XR_TYPE_EVENT_DATA_SCENE_CAPTURE_COMPLETE_FB) \
|
||||
_avail(XrSceneCaptureRequestInfoFB, XR_TYPE_SCENE_CAPTURE_REQUEST_INFO_FB) \
|
||||
|
@ -272,9 +271,34 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrDevicePcmSampleRateStateFB, XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB) \
|
||||
_avail(XrCompositionLayerDepthTestFB, XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB) \
|
||||
_avail(XrLocalDimmingFrameEndInfoMETA, XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META) \
|
||||
_avail(XrPassthroughPreferencesMETA, XR_TYPE_PASSTHROUGH_PREFERENCES_META) \
|
||||
_avail(XrSystemVirtualKeyboardPropertiesMETA, XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META) \
|
||||
_avail(XrVirtualKeyboardCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META) \
|
||||
_avail(XrVirtualKeyboardSpaceCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META) \
|
||||
_avail(XrVirtualKeyboardLocationInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_LOCATION_INFO_META) \
|
||||
_avail(XrVirtualKeyboardModelVisibilitySetInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_MODEL_VISIBILITY_SET_INFO_META) \
|
||||
_avail(XrVirtualKeyboardAnimationStateMETA, XR_TYPE_VIRTUAL_KEYBOARD_ANIMATION_STATE_META) \
|
||||
_avail(XrVirtualKeyboardModelAnimationStatesMETA, XR_TYPE_VIRTUAL_KEYBOARD_MODEL_ANIMATION_STATES_META) \
|
||||
_avail(XrVirtualKeyboardTextureDataMETA, XR_TYPE_VIRTUAL_KEYBOARD_TEXTURE_DATA_META) \
|
||||
_avail(XrVirtualKeyboardInputInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_INPUT_INFO_META) \
|
||||
_avail(XrVirtualKeyboardTextContextChangeInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_TEXT_CONTEXT_CHANGE_INFO_META) \
|
||||
_avail(XrEventDataVirtualKeyboardCommitTextMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_COMMIT_TEXT_META) \
|
||||
_avail(XrEventDataVirtualKeyboardBackspaceMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_BACKSPACE_META) \
|
||||
_avail(XrEventDataVirtualKeyboardEnterMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_ENTER_META) \
|
||||
_avail(XrEventDataVirtualKeyboardShownMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_SHOWN_META) \
|
||||
_avail(XrEventDataVirtualKeyboardHiddenMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_HIDDEN_META) \
|
||||
_avail(XrExternalCameraOCULUS, XR_TYPE_EXTERNAL_CAMERA_OCULUS) \
|
||||
_avail(XrPerformanceMetricsStateMETA, XR_TYPE_PERFORMANCE_METRICS_STATE_META) \
|
||||
_avail(XrPerformanceMetricsCounterMETA, XR_TYPE_PERFORMANCE_METRICS_COUNTER_META) \
|
||||
_avail(XrSpaceListSaveInfoFB, XR_TYPE_SPACE_LIST_SAVE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \
|
||||
_avail(XrSpaceUserCreateInfoFB, XR_TYPE_SPACE_USER_CREATE_INFO_FB) \
|
||||
_avail(XrSystemHeadsetIdPropertiesMETA, XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META) \
|
||||
_avail(XrPassthroughColorLutCreateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META) \
|
||||
_avail(XrPassthroughColorLutUpdateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META) \
|
||||
_avail(XrPassthroughColorMapLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META) \
|
||||
_avail(XrPassthroughColorMapInterpolatedLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META) \
|
||||
_avail(XrSystemPassthroughColorLutPropertiesMETA, XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META) \
|
||||
_avail(XrPassthroughCreateInfoHTC, XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC) \
|
||||
_avail(XrPassthroughColorHTC, XR_TYPE_PASSTHROUGH_COLOR_HTC) \
|
||||
_avail(XrPassthroughMeshTransformInfoHTC, XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC) \
|
||||
|
@ -283,6 +307,19 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrFoveationDynamicModeInfoHTC, XR_TYPE_FOVEATION_DYNAMIC_MODE_INFO_HTC) \
|
||||
_avail(XrFoveationCustomModeInfoHTC, XR_TYPE_FOVEATION_CUSTOM_MODE_INFO_HTC) \
|
||||
_avail(XrActiveActionSetPrioritiesEXT, XR_TYPE_ACTIVE_ACTION_SET_PRIORITIES_EXT) \
|
||||
_avail(XrSystemForceFeedbackCurlPropertiesMNDX, XR_TYPE_SYSTEM_FORCE_FEEDBACK_CURL_PROPERTIES_MNDX) \
|
||||
_avail(XrForceFeedbackCurlApplyLocationsMNDX, XR_TYPE_FORCE_FEEDBACK_CURL_APPLY_LOCATIONS_MNDX) \
|
||||
_avail(XrHandTrackingDataSourceInfoEXT, XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT) \
|
||||
_avail(XrHandTrackingDataSourceStateEXT, XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT) \
|
||||
_avail(XrSystemPlaneDetectionPropertiesEXT, XR_TYPE_SYSTEM_PLANE_DETECTION_PROPERTIES_EXT) \
|
||||
_avail(XrPlaneDetectorCreateInfoEXT, XR_TYPE_PLANE_DETECTOR_CREATE_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorBeginInfoEXT, XR_TYPE_PLANE_DETECTOR_BEGIN_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorGetInfoEXT, XR_TYPE_PLANE_DETECTOR_GET_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorLocationEXT, XR_TYPE_PLANE_DETECTOR_LOCATION_EXT) \
|
||||
_avail(XrPlaneDetectorLocationsEXT, XR_TYPE_PLANE_DETECTOR_LOCATIONS_EXT) \
|
||||
_avail(XrPlaneDetectorPolygonBufferEXT, XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT) \
|
||||
_avail(XrEventDataUserPresenceChangedEXT, XR_TYPE_EVENT_DATA_USER_PRESENCE_CHANGED_EXT) \
|
||||
_avail(XrSystemUserPresencePropertiesEXT, XR_TYPE_SYSTEM_USER_PRESENCE_PROPERTIES_EXT) \
|
||||
|
||||
|
||||
#if defined(XR_USE_GRAPHICS_API_D3D11)
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) Microsoft Corporation. All Rights Reserved
|
||||
|
||||
#ifndef XR_EXT_HAND_INTERACTION_H_
|
||||
#define XR_EXT_HAND_INTERACTION_H 1
|
||||
|
||||
#define XR_LIST_EXTENSIONS_EXT_hand_interaction(_) _(XR_EXT_hand_interaction, 303)
|
||||
#define XR_LIST_STRUCTURE_TYPES_EXT_hand_interaction(_)
|
||||
#define XR_LIST_ENUM_XrStructureType_EXT_hand_interaction(_)
|
||||
|
||||
#define XR_EXT_hand_interaction 1
|
||||
#define XR_EXT_hand_interaction_SPEC_VERSION 3
|
||||
#define XR_EXT_HAND_INTERACTION_EXTENSION_NAME "XR_EXT_hand_interaction"
|
||||
/// There are two goals of this XR_EXT_hand_interaction extension:
|
||||
///
|
||||
/// - Seeking the alignment of commonly used hand poses and corresponding actions for hand interactions across motion controller and hand
|
||||
/// tracking devices.
|
||||
///
|
||||
/// - Providing a new interaction profile for hand tracking input device to provide actions through the OpenXR action system.
|
||||
///
|
||||
/// The design is focusing on the following 4 commonly used hand interaction scenarios:
|
||||
///
|
||||
/// - Interacting with far object out of user's reach, such as using a virtual laser pointer to click a button on the wall, using
|
||||
/// .../aim/pose.
|
||||
///
|
||||
/// - Picking up a big object or holding a grip, for example, pulling a door handle or holding a sword, using .../grip/pose.
|
||||
///
|
||||
/// - Pinching or interacting with a small object within reach, such as turning a key to open a lock or moving the knob on a slider bar,
|
||||
/// using .../pinch_ext/pose.
|
||||
///
|
||||
/// - For finger tip touch interaction, such as pressing a push button, swiping to slide a browser view, or typing on a virtual keyboard,
|
||||
/// using .../poke_ext/pose.
|
||||
///
|
||||
/// The above 4 hand poses must be supported by all interaction profile supporting /user/hand/left or /user/hand/right
|
||||
/// top-level paths, including motion controller interaction profiles, as well as the following new interaction profile for hand tracking.
|
||||
///
|
||||
/// The 4 hand poses are typically used together with appropriate buttons on controller or corresponding hand gesture actions in following
|
||||
/// new interaction profile.
|
||||
///
|
||||
/// The new interaction profile is added for optical hand tracking input devices, this interaction profile includes the 4 poses as above, as
|
||||
/// well as following gesture actions:
|
||||
///
|
||||
/// - The .../aim_activate_ext/value action that's optimized for stabilizing .../aim/pose for interacting with objects out of user's direct
|
||||
/// reach. Also added bool action .../aim_activate_ext/ready_ext to indicate if the aim gesture is ready to be used.
|
||||
///
|
||||
/// - The .../grasp/value action that's optimized to be used together with .../grip/pose for direct manipulation. Also added bool action
|
||||
/// .../grasp/ready_ext to indicate if the grasp gesture is ready to be used.
|
||||
///
|
||||
/// - The .../pinch_ext/value that's optimized to be used together with the .../pinch_ext/pose for pinch gestures. Also added bool action
|
||||
/// .../pinch_ext/ready_ext to indicate if the pinch gesture is ready to be used.
|
||||
///
|
||||
/// The new actions are only available with the new /interaction_profiles/ext/hand_interaction_ext profile for hand tracking devices, and they
|
||||
/// will not affect existing controller interaction profiles.
|
||||
|
||||
#endif // XR_EXT_HAND_INTERACTION_H_
|
|
@ -1,184 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) Microsoft Corporation. All Rights Reserved
|
||||
|
||||
#ifndef XR_MSFT_SCENE_MARKER_H_
|
||||
#define XR_MSFT_SCENE_MARKER_H_ 1
|
||||
|
||||
#ifndef DEFINE_ENUM_VALUE
|
||||
#ifdef __cplusplus
|
||||
#define DEFINE_ENUM_VALUE(Type, Name, Value) constexpr Type Name = static_cast<Type>(Value)
|
||||
#else
|
||||
#define DEFINE_ENUM_VALUE(Type, Name, Value) Type Name = (Type)(Value)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// This extension enables marker tracking inputs through scene understanding extension.
|
||||
#define XR_LIST_EXTENSIONS_MSFT_scene_marker(_) _(XR_MSFTX_scene_marker, 148)
|
||||
|
||||
#define XR_MSFTX_scene_marker 1
|
||||
#define XR_MSFTX_scene_marker_SPEC_VERSION 1
|
||||
#define XR_MSFTX_SCENE_MARKER_EXTENSION_NAME "XR_MSFTX_scene_marker"
|
||||
/// The application must: also enable the `<<XR_MSFT_scene_understanding>>` extension in order to use this extension.
|
||||
/// The runtime will call RequestAccessAsync() for the first flink:xrComputeNewSceneMSFT function call.
|
||||
/// The application can use flink:xrLocateSceneComponentsMSFT to locate a QR code.
|
||||
/// This extension include QR code types that HL2 supports today, and easy to extend in future:
|
||||
/// https://docs.microsoft.com/en-us/windows/mixed-reality/develop/advanced-concepts/qr-code-tracking-overview#supported-qr-code-versions
|
||||
/// The convention of each marker's location is similar to XrScenePlane.
|
||||
/// - The Position of the marker is most stable / accurate point of the marker from a detection point of view;
|
||||
/// e.g. for a QR Code, it's one of the marker corners.
|
||||
/// - The XY axis is within the plane of the marker
|
||||
/// - The +Z direction is pointing to the normal direction of the front face of the marker.
|
||||
/// - The XrSceneMarkerMSFT.center are the coordinates of the marker's center in the XY plane related to the marker's position.
|
||||
/// - The XrSceneMarkerMSFT.size has width/height corresponding to the XY direction.
|
||||
/// The markerId returned in XrSceneComponent.id is used to identify each marker in related functions.
|
||||
/// This markerId has type of XrUuidMSFT.
|
||||
/// The application should do
|
||||
/// 1. Call xrCreateSceneObserverMSFT
|
||||
/// 2. Call xrEnumerateSceneComputeFeaturesMSFT to check if observer supports XR_SCENE_COMPUTE_FEATURE_MARKER_MSFT
|
||||
/// 3. If supported, call xrComputeNewSceneMSFT including XR_SCENE_COMPUTE_FEATURE_MARKER_MSFT
|
||||
/// 4. Poll xrGetSceneComputeStateMSFT, waiting for compute complete
|
||||
/// 5. Call xrCreateSceneMSFT to get compute result
|
||||
/// 6. Call xrGetSceneComponentsMSFT with XR_SCENE_COMPONENT_TYPE_MARKER_MSFT to query for markers.
|
||||
/// 6.1 Chain XrSceneMarkersMSFT to the next of XrSceneComponents to receive marker type, and lastSeenTime
|
||||
/// 6.2 Alternative, chain XrSceneMarkerTypeFilter to the next of XrSceneComponentsGetInfoMSFT when calling xrGetSceneComponentsMSFT
|
||||
/// to filter down the result to only specific marker type.
|
||||
/// If the XrSceneMarkerQrCodes are in next chain of XrSceneMarker on the output XrSceneComponents
|
||||
/// when calling xrGetSceneComponentsMSFT, get additional marker type specifc info. When marker filter is specified, the output
|
||||
/// struct must have matching struct. E.g. if marker filter is asking for other types of markers than QR Codes but the
|
||||
/// output structs have XrSceneMarkersQRCodesMSFT struct, the function returns XR_ERROR_VALIDATION_FAILURE.
|
||||
/// Note: the filters on xrGetSceneComponents works with "and" logic when multiple filters are provided.
|
||||
/// Therefore, if two marker types filter are specified with 2 different types, the result list will be empty.
|
||||
/// 7. Call xrDecodeMarkerStringMSFT to get the string encoded in a given markerId using the two call idions.
|
||||
/// 8. Optionally, call xrGetSceneMarkerRawDataMSFT to get raw data of given markerId as byte arrays using two call idioms.
|
||||
/// 9. Call xrLocateSceneComponentsMSFT to locate each marker using the markerId.
|
||||
|
||||
DEFINE_ENUM_VALUE(XrSceneComputeFeatureMSFT, XR_SCENE_COMPUTE_FEATURE_MARKER_MSFT, 1000147000);
|
||||
DEFINE_ENUM_VALUE(XrSceneComponentTypeMSFT, XR_SCENE_COMPONENT_TYPE_MARKER_MSFT, 1000147000);
|
||||
DEFINE_ENUM_VALUE(XrStructureType, XR_TYPE_SCENE_MARKERS_MSFT, 1000147000);
|
||||
DEFINE_ENUM_VALUE(XrStructureType, XR_TYPE_SCENE_MARKER_TYPE_FILTER_MSFT, 1000147001);
|
||||
DEFINE_ENUM_VALUE(XrStructureType, XR_TYPE_SCENE_MARKER_QR_CODES_MSFT, 1000147002);
|
||||
DEFINE_ENUM_VALUE(XrResult, XR_SCENE_MARKER_DATA_NO_STRING_MSFT, 1000147000);
|
||||
|
||||
#undef DEFINE_ENUM_VALUE
|
||||
|
||||
#define XR_LIST_ENUM_XrStructureType_MSFT_scene_marker(_) \
|
||||
_(XR_TYPE_SCENE_MARKERS_MSFT, 1000147000) \
|
||||
_(XR_TYPE_SCENE_MARKER_TYPE_FILTER_MSFT, 1000147001) \
|
||||
_(XR_TYPE_SCENE_MARKER_QR_CODES_MSFT, 1000147002)
|
||||
|
||||
#define XR_LIST_STRUCTURE_TYPES_MSFT_scene_marker(_) \
|
||||
_(XrSceneMarkersMSFT, XR_TYPE_SCENE_MARKERS_MSFT) \
|
||||
_(XrSceneMarkerTypeFilterMSFT, XR_TYPE_SCENE_MARKER_TYPE_FILTER_MSFT) \
|
||||
_(XrSceneMarkerQRCodesMSFT, XR_TYPE_SCENE_MARKER_QR_CODES_MSFT)
|
||||
|
||||
typedef enum XrSceneMarkerTypeMSFT {
|
||||
XR_SCENE_MARKER_TYPE_QR_CODE_MSFT = 1,
|
||||
XR_SCENE_MARKER_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} XrSceneMarkerTypeMSFT;
|
||||
|
||||
typedef enum XrSceneMarkerQRCodeSymbolTypeMSFT {
|
||||
XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_QR_CODE_MSFT = 1,
|
||||
XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_MICRO_QR_CODE_MSFT = 2,
|
||||
XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} XrSceneMarkerQRCodeSymbolTypeMSFT;
|
||||
|
||||
|
||||
/// Return from xrGetSceneComponents when using XR_SCENE_COMPONENT_TYPE_MARKER_MSFT
|
||||
/// The markerId is returned from corresponding XrSceneComponent.Id.
|
||||
/// Typically, corresponding XrSceneComponent.parentId is uuid_null
|
||||
typedef struct XrSceneMarkerMSFT {
|
||||
XrSceneMarkerTypeMSFT markerType; // Use marker type to query for xrGetSceneMarkerProperties function for additional typed properties.
|
||||
XrTime lastSeenTime; // lastSeenTime is earlier or equal to the XrSceneComponent.updateTime.
|
||||
XrOffset2Df center; // The location of the center of the axis-aligned bounding box of marker in the XY plane of the marker's space.
|
||||
XrExtent2Df size; // The width and height of the axis-aligned bounding box of marker in the XY plane of the marker's space.
|
||||
} XrSceneMarkerMSFT;
|
||||
|
||||
/// Return a list of of XrSceneMarkerMSFT from xrGetSceneComponents when using XR_SCENE_COMPONENT_TYPE_MARKER_MSFT
|
||||
/// Chained to the next pointer of XrSceneComponentsMSFT and must keep the same array size.
|
||||
typedef struct XrSceneMarkersMSFT {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
uint32_t sceneMarkerCount; // must: be the same as corresponding XrSceneComponentsMSFT.componentCountInput
|
||||
XrSceneMarkerMSFT* sceneMarkers; // caller allocated buffer to receive the array of scene markers
|
||||
} XrSceneMarkersMSFT;
|
||||
|
||||
/// Chain to next of XrSceneComponentsGetInfo to filter the xrGetSceneComponents to return only specific marker types.
|
||||
typedef struct XrSceneMarkerTypeFilterMSFT {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
uint32_t markerTypeCount; // The number of markerTypes in the filter.
|
||||
XrSceneMarkerTypeMSFT* markerTypes; // Marker types to be returned.
|
||||
} XrSceneMarkerTypeFilterMSFT;
|
||||
|
||||
/// Returns the QRCode specific data, combine it with corresponding XrSceneMarker and XrSceneComponent.
|
||||
/// Data and version are immutable for the lifetime of a markerId
|
||||
typedef struct XrSceneMarkerQRCodeMSFT {
|
||||
XrSceneMarkerQRCodeSymbolTypeMSFT symbolType;
|
||||
uint8_t qrVersion; // runtime must: return a valid qr version according to ISO_IEC_18004.2015
|
||||
// 1 to 40 for QR Versions 1 to 40
|
||||
// 1 to 4 for Micro QR versions M1 to M4
|
||||
} XrSceneMarkerQRCodeMSFT;
|
||||
|
||||
/// XrSceneMarkersQRCodesMSFT extends XrSceneComponentsMSFT
|
||||
typedef struct XrSceneMarkerQRCodesMSFT {
|
||||
XrStructureType type;
|
||||
void* XR_MAY_ALIAS next;
|
||||
uint32_t qrCodeCount; // must: be the same as corresponding XrSceneComponentsMSFT.componentCountInput
|
||||
XrSceneMarkerQRCodeMSFT* qrCodes; // caller allocated buffer to receive the returned XrSceneMarkerQRCodeMSFT
|
||||
} XrSceneMarkerQRCodesMSFT;
|
||||
|
||||
/// xrGetSceneMarkerRawDataMSFT gets the raw data of a given markerId as a byte array, using two call idioms.
|
||||
/// This function works for any marker type, and input markerIds can have different marker types.
|
||||
/// Returns XR_ERROR_SCENE_COMPONENT_ID_INVALID_MSFT if markerId not a scene component id
|
||||
/// Returns XR_ERROR_SCENE_COMPONENT_TYPE_MISMATCH_MSFT if markerId is not a marker id
|
||||
typedef XrResult(XRAPI_PTR* PFN_xrGetSceneMarkerRawDataMSFT)(
|
||||
XrSceneMSFT scene, // A scene snapshot the result of a scene compute
|
||||
const XrUuidMSFT* markerId, // A valid uuid previously obtained from XrSceneComponent.Id
|
||||
uint32_t dataCapacityInput,
|
||||
uint32_t* dataCountOutput,
|
||||
uint8_t* data);
|
||||
|
||||
/// xrDecodeMarkerStringMSFT gets string content of a given markerId as an UTF8 string, using two call idioms.
|
||||
/// Returns XR_ERROR_SCENE_COMPONENT_ID_INVALID_MSFT if markerId is not a scene component id
|
||||
/// Returns XR_ERROR_SCENE_COMPONENT_TYPE_MISMATCH_MSFT if markerId is a scene component id but does not identify a marker
|
||||
/// Returns XR_SCENE_MARKER_DATA_NO_STRING_MSFT if marker's data do not have a string representation
|
||||
typedef XrResult(XRAPI_PTR* PFN_xrGetSceneMarkerDecodedStringMSFT)(
|
||||
XrSceneMSFT scene, // A scene snapshot the result of a scene compute
|
||||
const XrUuidMSFT* markerId, // A valid uuid previously obtained from XrSceneComponent.Id
|
||||
uint32_t stringCapacityInput, // Capacity of the string in char including the null terminator
|
||||
uint32_t* stringCountOutput, // Length of the marker string in char including the null terminator
|
||||
char* string);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
#ifdef XR_EXTENSION_PROTOTYPES
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetSceneMarkerRawDataMSFT(
|
||||
XrSceneMSFT scene, const XrUuidMSFT* markerId, uint32_t dataCapacityInput, uint32_t* dataCountOutput, uint8_t* data);
|
||||
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrGetSceneMarkerDecodedStringMSFT(
|
||||
XrSceneMSFT scene, const XrUuidMSFT* markerId, uint32_t stringCapacityInput, uint32_t* stringCountOutput, char* string);
|
||||
|
||||
#endif /* XR_EXTENSION_PROTOTYPES */
|
||||
#endif /* !XR_NO_PROTOTYPES */
|
||||
|
||||
#define XR_LIST_FUNCTIONS_MSFT_scene_marker(_) \
|
||||
_(xrGetSceneMarkerRawDataMSFT) \
|
||||
_(xrGetSceneMarkerDecodedStringMSFT)
|
||||
|
||||
#define XR_LIST_ENUM_XrSceneMarkerTypeMSFT(_) \
|
||||
_(XR_SCENE_MARKER_TYPE_QR_CODE_MSFT, 1) \
|
||||
_(XR_SCENE_MARKER_TYPE_MAX_ENUM, 0x7FFFFFFF)
|
||||
|
||||
#define XR_LIST_ENUM_XrSceneMarkerQRCodeSymbolTypeMSFT(_) \
|
||||
_(XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_QR_CODE_MSFT, 1) \
|
||||
_(XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_MICRO_QR_CODE_MSFT, 1) \
|
||||
_(XR_SCENE_MARKER_QR_CODE_SYMBOL_TYPE_MAX_ENUM, 0x7FFFFFFF)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // XR_MSFT_SCENE_MARKER_H_
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) Microsoft Corporation. All Rights Reserved
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Supports XrStructTraits and ValidateStruct
|
||||
#define XR_LIST_STRUCTURE_TYPES_MSFT_PREVIEW(_)
|
||||
|
||||
// Supports IXrExtensionConfiguration.EnabledExtensions()
|
||||
#define XR_LIST_EXTENSIONS_MSFT_PREVIEW(_)
|
||||
|
||||
// Supports xrStructureTypeToString and IsKnownStructType
|
||||
#define XR_LIST_ENUM_XrStructureType_MSFT_PREVIEW(_)
|
||||
|
||||
// Supports XrDispatchTable.h
|
||||
#define XR_LIST_FUNCTIONS_MSFT_PREVIEW(_)
|
||||
|
||||
// clang-format on
|
|
@ -31,7 +31,7 @@ namespace {
|
|||
struct EyeGazeInteractionScene : public engine::Scene {
|
||||
EyeGazeInteractionScene(engine::Context& context)
|
||||
: Scene(context)
|
||||
, m_supportsEyeGazeAction(context.Extensions.SupportsEyeGazeInteraction &&
|
||||
, m_supportsEyeGazeAction(context.Extensions.XR_EXT_eye_gaze_interaction_enabled &&
|
||||
context.System.EyeGazeInteractionProperties.supportsEyeGazeInteraction) {
|
||||
if (m_supportsEyeGazeAction) {
|
||||
sample::ActionSet& actionSet =
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace {
|
|||
{m_motionRangeModeChangeAction, "/user/hand/left/input/select/click"},
|
||||
});
|
||||
|
||||
if (context.Extensions.SupportsHPMixedRealityController) {
|
||||
if (context.Extensions.XR_EXT_hp_mixed_reality_controller_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/hp/mixed_reality_controller",
|
||||
{
|
||||
{m_motionRangeModeChangeAction, "/user/hand/right/input/trigger"},
|
||||
|
@ -44,7 +44,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_motionRangeModeChangeAction, "/user/hand/left/input/select"},
|
||||
|
@ -52,7 +52,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/ext/hand_interaction_ext",
|
||||
{
|
||||
{m_motionRangeModeChangeAction, "/user/hand/left/input/aim_activate_ext"},
|
||||
|
@ -398,11 +398,11 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
std::unique_ptr<engine::Scene> TryCreateHandTrackingScene(engine::Context& context) {
|
||||
if (!context.Extensions.SupportsHandJointTracking || !context.System.HandTrackingProperties.supportsHandTracking) {
|
||||
if (!context.Extensions.XR_EXT_hand_tracking_enabled || !context.System.HandTrackingProperties.supportsHandTracking) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const bool enableHandMesh = context.Extensions.SupportsHandMeshTracking && context.System.HandMeshProperties.supportsHandTrackingMesh;
|
||||
const bool enableHandMesh = context.Extensions.XR_MSFT_hand_tracking_mesh_enabled && context.System.HandMeshProperties.supportsHandTrackingMesh;
|
||||
|
||||
return std::make_unique<HandTrackingScene>(context, enableHandMesh);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace {
|
|||
{m_selectAction, "/user/hand/left/input/trigger"},
|
||||
});
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_selectAction, "/user/hand/right/input/select"},
|
||||
|
@ -43,7 +43,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/ext/hand_interaction_ext",
|
||||
{
|
||||
{m_selectAction, "/user/hand/right/input/aim_activate_ext"},
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace {
|
|||
axis->SetParent(controllerData.gripRoot);
|
||||
}
|
||||
|
||||
if (m_context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (m_context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
// Initialize objects attached to pinch pose
|
||||
{
|
||||
XrAction pinchAction = FindAction(m_actions, pinchPoseActionName[side]).action;
|
||||
|
@ -141,7 +141,7 @@ namespace {
|
|||
}
|
||||
|
||||
// Find the pinch action
|
||||
if (m_context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (m_context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
XrAction pinchAction = FindAction(m_actions, "pinch").action;
|
||||
if (pinchAction) {
|
||||
XrActionStateGetInfo getInfo{XR_TYPE_ACTION_STATE_GET_INFO};
|
||||
|
@ -231,7 +231,7 @@ namespace {
|
|||
|
||||
private:
|
||||
static std::vector<ActionInfo> CreateActions(sample::ActionContext& actionContext,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
const char* actionSetName) {
|
||||
sample::ActionSet& actionSet = actionContext.CreateActionSet(actionSetName, actionSetName);
|
||||
std::vector<ActionInfo> actions{};
|
||||
|
@ -407,7 +407,7 @@ namespace {
|
|||
{InteractionProfiles::TouchController, "grip/pose", UserHandPath[side]},
|
||||
});
|
||||
|
||||
if (extensions.SupportsHandInteractionEXT) {
|
||||
if (extensions.XR_EXT_hand_interaction_enabled) {
|
||||
addAction(pinchPoseActionName[side],
|
||||
XR_ACTION_TYPE_POSE_INPUT,
|
||||
{
|
||||
|
@ -456,7 +456,7 @@ namespace {
|
|||
|
||||
static void InitializeSuggestBindings(uint32_t side,
|
||||
sample::ActionContext& actionContext,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
const std::vector<ActionInfo>& actions) {
|
||||
const std::string subactionPath = UserHandPath[side];
|
||||
|
||||
|
@ -480,22 +480,22 @@ namespace {
|
|||
actionContext.SuggestInteractionProfileBindings(InteractionProfiles::TouchController,
|
||||
suggestedBindings[InteractionProfiles::TouchController]);
|
||||
|
||||
if (extensions.SupportsHPMixedRealityController) {
|
||||
if (extensions.XR_EXT_hp_mixed_reality_controller_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings(InteractionProfiles::HPMixedRealityController,
|
||||
suggestedBindings[InteractionProfiles::HPMixedRealityController]);
|
||||
}
|
||||
|
||||
if (extensions.SupportsHandInteractionMSFT) {
|
||||
if (extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings(InteractionProfiles::HandInteractionMSFT,
|
||||
suggestedBindings[InteractionProfiles::HandInteractionMSFT]);
|
||||
}
|
||||
|
||||
if (extensions.SupportsHandInteractionEXT) {
|
||||
if (extensions.XR_EXT_hand_interaction_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings(InteractionProfiles::HandInteractionEXT,
|
||||
suggestedBindings[InteractionProfiles::HandInteractionEXT]);
|
||||
}
|
||||
|
||||
if (extensions.SupportsSamsungOdysseyController) {
|
||||
if (extensions.XR_EXT_samsung_odyssey_controller_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings(InteractionProfiles::SamsungController,
|
||||
suggestedBindings[InteractionProfiles::SamsungController]);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace {
|
|||
{m_gripPoseAction, "/user/hand/left/input/grip"},
|
||||
});
|
||||
|
||||
if (context.Extensions.SupportsHPMixedRealityController) {
|
||||
if (context.Extensions.XR_EXT_hp_mixed_reality_controller_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/hp/mixed_reality_controller",
|
||||
{
|
||||
{m_gripPoseAction, "/user/hand/right/input/grip"},
|
||||
|
@ -47,7 +47,8 @@ namespace {
|
|||
for (ControllerData& controller : {std::ref(m_leftController), std::ref(m_rightController)}) {
|
||||
actionSpaceCreateInfo.subactionPath = controller.UserPath;
|
||||
actionSpaceCreateInfo.action = m_gripPoseAction;
|
||||
CHECK_XRCMD(xrCreateActionSpace(m_context.Session.Handle, &actionSpaceCreateInfo, controller.GripSpace.Put(xrDestroySpace)));
|
||||
CHECK_XRCMD(
|
||||
xrCreateActionSpace(m_context.Session.Handle, &actionSpaceCreateInfo, controller.GripSpace.Put(xrDestroySpace)));
|
||||
|
||||
// Controller objects are created with empty model. It will be loaded when available.
|
||||
controller.Object = AddObject(CreateControllerObject(m_context, controller.UserPath));
|
||||
|
@ -88,5 +89,5 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
std::unique_ptr<engine::Scene> TryCreateControllerModelScene(engine::Context& context) {
|
||||
return context.Extensions.SupportsControllerModel ? std::make_unique<ControllerModelScene>(context) : nullptr;
|
||||
return context.Extensions.XR_MSFT_controller_model_enabled ? std::make_unique<ControllerModelScene>(context) : nullptr;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
|||
{m_gripSpaceAction, "/user/hand/right/input/grip/pose"},
|
||||
});
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_gripSpaceAction, "/user/hand/left/input/grip/pose"},
|
||||
|
@ -47,7 +47,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/ext/hand_interaction_ext",
|
||||
{
|
||||
{m_gripSpaceAction, "/user/hand/left/input/grip/pose"},
|
||||
|
@ -55,7 +55,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHPMixedRealityController) {
|
||||
if (context.Extensions.XR_EXT_hp_mixed_reality_controller_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/hp/mixed_reality_controller",
|
||||
{
|
||||
{m_gripSpaceAction, "/user/hand/left/input/grip/pose"},
|
||||
|
|
|
@ -17,7 +17,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
|
|||
appConfig.RequestedExtensions.push_back(XR_MSFT_SPATIAL_ANCHOR_EXTENSION_NAME);
|
||||
appConfig.RequestedExtensions.push_back(XR_MSFT_SCENE_UNDERSTANDING_EXTENSION_NAME);
|
||||
appConfig.RequestedExtensions.push_back(XR_MSFT_SCENE_UNDERSTANDING_SERIALIZATION_EXTENSION_NAME);
|
||||
appConfig.RequestedExtensions.push_back(XR_MSFTX_SCENE_MARKER_EXTENSION_NAME);
|
||||
appConfig.RequestedExtensions.push_back(XR_MSFT_SCENE_MARKER_EXTENSION_NAME);
|
||||
|
||||
auto app = CreateXrApp(appConfig);
|
||||
app->AddScene(TryCreateTitleScene(app->Context()));
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace {
|
|||
{m_placeObjectAction, "/user/hand/right/input/select/click"},
|
||||
{m_placeObjectAction, "/user/hand/left/input/select/click"},
|
||||
});
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_aimPoseAction, "/user/hand/right/input/aim"},
|
||||
|
@ -130,7 +130,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
actionContext.SuggestInteractionProfileBindings("/interaction_profiles/ext/hand_interaction_ext",
|
||||
{
|
||||
{m_aimPoseAction, "/user/hand/right/input/aim"},
|
||||
|
@ -666,5 +666,5 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
std::unique_ptr<engine::Scene> TryCreatePlacementScene(engine::Context& context) {
|
||||
return context.Extensions.SupportsSceneUnderstanding ? std::make_unique<PlacementScene>(context) : nullptr;
|
||||
return context.Extensions.XR_MSFT_scene_understanding_enabled ? std::make_unique<PlacementScene>(context) : nullptr;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace {
|
|||
{m_switchFilterAction, "/user/hand/right/input/select/click"},
|
||||
{m_switchFilterAction, "/user/hand/left/input/select/click"},
|
||||
});
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_switchFilterAction, "/user/hand/left/input/select/value"},
|
||||
|
@ -178,10 +178,12 @@ namespace {
|
|||
for (size_t i = 0; i < m_markerIds.size(); ++i) {
|
||||
const XrSceneComponentLocationMSFT& location = m_componentLocations[i];
|
||||
auto& visualInfo = m_markerVisuals[m_markerIds[i]];
|
||||
const std::shared_ptr<engine::Object>& object = visualInfo.second;
|
||||
const std::shared_ptr<engine::PbrModelObject>& object = visualInfo.second;
|
||||
const auto centerToPose = visualInfo.first;
|
||||
if (xr::math::Pose::IsPoseValid(location.flags)) {
|
||||
object->Pose() = xr::math::Pose::Multiply(centerToPose, location.pose);
|
||||
object->SetFillMode(xr::math::Pose::IsPoseTracked(location.flags) ? Pbr::FillMode::Solid
|
||||
: Pbr::FillMode::Wireframe);
|
||||
} else {
|
||||
object->SetVisible(false);
|
||||
}
|
||||
|
@ -352,6 +354,7 @@ namespace {
|
|||
xr::InsertExtensionStruct(getInfo, typesFilter);
|
||||
XrSceneComponentsMSFT sceneComponents{XR_TYPE_SCENE_COMPONENTS_MSFT};
|
||||
|
||||
|
||||
// Get the number of markers
|
||||
CHECK_XRCMD(xrGetSceneComponentsMSFT(m_scene.Get(), &getInfo, &sceneComponents));
|
||||
const uint32_t count = sceneComponents.componentCountOutput;
|
||||
|
@ -362,13 +365,13 @@ namespace {
|
|||
|
||||
std::vector<XrSceneMarkerMSFT> markers(count);
|
||||
XrSceneMarkersMSFT sceneMarkers{XR_TYPE_SCENE_MARKERS_MSFT};
|
||||
sceneMarkers.sceneMarkerCount = count;
|
||||
sceneMarkers.sceneMarkerCapacityInput = count;
|
||||
sceneMarkers.sceneMarkers = markers.data();
|
||||
xr::InsertExtensionStruct(sceneComponents, sceneMarkers);
|
||||
|
||||
std::vector<XrSceneMarkerQRCodeMSFT> qrcodes(count);
|
||||
XrSceneMarkerQRCodesMSFT sceneQRCodes{XR_TYPE_SCENE_MARKER_QR_CODES_MSFT};
|
||||
sceneQRCodes.qrCodeCount = count;
|
||||
sceneQRCodes.qrCodeCapacityInput = count;
|
||||
sceneQRCodes.qrCodes = qrcodes.data();
|
||||
xr::InsertExtensionStruct(sceneComponents, sceneQRCodes);
|
||||
|
||||
|
@ -380,14 +383,15 @@ namespace {
|
|||
for (uint32_t i = 0; i < count; ++i) {
|
||||
const XrDuration markerAgeNanos = predictedDisplayTime - markers[i].lastSeenTime;
|
||||
std::chrono::nanoseconds markerAge = duration<XrDuration, std::nano>(markerAgeNanos);
|
||||
std::chrono::duration<float> markerAgeSeconds = markerAge;
|
||||
if (markerAge < MaxMarkerAge) {
|
||||
auto& markerId = components[i].id;
|
||||
|
||||
// Always re-create to enable color change and dimension change
|
||||
auto visual = CreateMarkerVisual(
|
||||
markerId,
|
||||
markers[i],
|
||||
qrcodes[i]);
|
||||
auto visual = CreateMarkerVisual(markerId,
|
||||
markers[i],
|
||||
qrcodes[i],
|
||||
markerAgeSeconds.count());
|
||||
XrQuaternionf rotation = xr::math::Quaternion::RotationAxisAngle(XrVector3f{1.0f, 0.0f, 0.0f}, XM_PI);
|
||||
XrVector3f centerOffset{markers[i].center.x, markers[i].center.y, 0.0f};
|
||||
auto centerToPose = xr::math::Pose::MakePose(rotation, centerOffset);
|
||||
|
@ -412,7 +416,8 @@ namespace {
|
|||
// Create a Quad which covers the marker and displays the marker's string as text
|
||||
std::shared_ptr<engine::PbrModelObject> CreateMarkerVisual(const XrUuidMSFT& markerId,
|
||||
const XrSceneMarkerMSFT& marker,
|
||||
const XrSceneMarkerQRCodeMSFT& qrcode) {
|
||||
const XrSceneMarkerQRCodeMSFT& qrcode,
|
||||
float ageSeconds) {
|
||||
uint32_t stringLength{0};
|
||||
std::vector<char> markerString;
|
||||
CHECK_XRCMD(xrGetSceneMarkerDecodedStringMSFT(m_scene.Get(), &markerId, 0, &stringLength, nullptr));
|
||||
|
@ -432,7 +437,9 @@ namespace {
|
|||
textInfo.FontSize = 32.0f;
|
||||
|
||||
auto textTexture = std::make_unique<engine::TextTexture>(m_context, textInfo);
|
||||
textTexture->Draw(markerString.data());
|
||||
char label[512];
|
||||
sprintf_s(label, "%s\n%.3f s", markerString.data(), ageSeconds);
|
||||
textTexture->Draw(label);
|
||||
const auto& material = textTexture->CreatePbrMaterial(m_context.PbrResources);
|
||||
return engine::CreateQuad(m_context.PbrResources, size, material);
|
||||
}
|
||||
|
@ -442,7 +449,7 @@ namespace {
|
|||
xr::UniqueXrHandle<XrSceneMSFT> m_scene;
|
||||
std::vector<XrUuidMSFT> m_markerIds;
|
||||
std::vector<XrSceneComponentLocationMSFT> m_componentLocations;
|
||||
std::unordered_map<XrUuidMSFT, std::pair<XrPosef, std::shared_ptr<engine::Object>>> m_markerVisuals;
|
||||
std::unordered_map<XrUuidMSFT, std::pair<XrPosef, std::shared_ptr<engine::PbrModelObject>>> m_markerVisuals;
|
||||
XrTime m_lastTimeOfUpdate{};
|
||||
XrNewSceneComputeInfoMSFT m_sceneComputeInfo{XR_TYPE_NEW_SCENE_COMPUTE_INFO_MSFT};
|
||||
XrSceneSphereBoundMSFT m_sphereBounds{0.0f};
|
||||
|
@ -466,6 +473,6 @@ namespace {
|
|||
} // namespace
|
||||
|
||||
std::unique_ptr<engine::Scene> TryCreateQRCodeScene(engine::Context& context) {
|
||||
return context.Extensions.SupportsSceneMarker ? std::make_unique<QRCodeScene>(context) : nullptr;
|
||||
return context.Extensions.XR_MSFT_scene_marker_enabled ? std::make_unique<QRCodeScene>(context) : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
#include <openxr/openxr_reflection.h>
|
||||
#include <openxr/openxr_msft_preview.h>
|
||||
#include <openxr_preview/openxr_msft_preview.h>
|
||||
|
||||
#define ENABLE_GLOBAL_XR_DISPATCH_TABLE
|
||||
#include <XrUtility/XrDispatchTable.h>
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
|||
{m_aimPoseAction, "/user/hand/right/input/aim/pose"},
|
||||
});
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionMSFT) {
|
||||
if (context.Extensions.XR_MSFT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/microsoft/hand_interaction",
|
||||
{
|
||||
{m_selectAction, "/user/hand/left/input/select/value"},
|
||||
|
@ -49,7 +49,7 @@ namespace {
|
|||
});
|
||||
}
|
||||
|
||||
if (context.Extensions.SupportsHandInteractionEXT) {
|
||||
if (context.Extensions.XR_EXT_hand_interaction_enabled) {
|
||||
ActionContext().SuggestInteractionProfileBindings("/interaction_profiles/ext/hand_interaction_ext",
|
||||
{
|
||||
{m_selectAction, "/user/hand/left/input/aim_activate_ext/value"},
|
||||
|
@ -72,7 +72,7 @@ namespace {
|
|||
m_holograms.emplace_back(m_localSpace.Get(),
|
||||
AddObject(engine::CreateAxis(m_context.PbrResources, 0.1f /*length*/, 0.05f /*thickness*/)));
|
||||
|
||||
if (m_context.Extensions.SupportsUnboundedSpace) {
|
||||
if (m_context.Extensions.XR_MSFT_unbounded_reference_space_enabled) {
|
||||
referenceSpaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT;
|
||||
CHECK_XRCMD(xrCreateReferenceSpace(m_context.Session.Handle, &referenceSpaceCreateInfo, m_unboundedSpace.Put(xrDestroySpace)));
|
||||
|
||||
|
@ -181,7 +181,7 @@ namespace {
|
|||
}
|
||||
|
||||
XrSpace CreateSpacialAnchorSpace(XrSpace space, XrTime time) {
|
||||
if (!m_context.Extensions.SupportsSpatialAnchor) {
|
||||
if (!m_context.Extensions.XR_MSFT_spatial_anchor_enabled) {
|
||||
return XR_NULL_HANDLE; // cannot create hologram on spatial anchor.
|
||||
}
|
||||
|
||||
|
|
|
@ -127,10 +127,10 @@ namespace sample::dx {
|
|||
std::tuple<XrGraphicsBindingD3D11KHR, winrt::com_ptr<ID3D11Device>, winrt::com_ptr<ID3D11DeviceContext>>
|
||||
CreateD3D11Binding(XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
bool singleThreadedD3D11Device,
|
||||
const std::vector<D3D_FEATURE_LEVEL>& appSupportedFeatureLevels) {
|
||||
if (!extensions.SupportsD3D11) {
|
||||
if (!extensions.XR_KHR_D3D11_enable_enabled) {
|
||||
throw std::exception("The runtime doesn't support D3D11 extensions.");
|
||||
}
|
||||
_Analysis_assume_(xrGetD3D11GraphicsRequirementsKHR != nullptr);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <winrt/base.h> // winrt::com_ptr
|
||||
#include <d3dcommon.h> //ID3DBlob
|
||||
#include <XrUtility/XrHandle.h>
|
||||
#include <XrUtility/XrExtensionContext.h>
|
||||
#include <XrUtility/XrEnabledExtensions.h>
|
||||
|
||||
namespace sample::dx {
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace sample::dx {
|
|||
std::tuple<XrGraphicsBindingD3D11KHR, winrt::com_ptr<ID3D11Device>, winrt::com_ptr<ID3D11DeviceContext>>
|
||||
CreateD3D11Binding(XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
bool singleThreadedD3D11Device,
|
||||
const std::vector<D3D_FEATURE_LEVEL>& appSupportedFeatureLevels);
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ namespace sample {
|
|||
// note: all runtimes must support VIEW and LOCAL reference spaces.
|
||||
std::vector<XrReferenceSpaceType> SupportedReferenceSpaces;
|
||||
bool SupportsStageSpace;
|
||||
bool SupportsUnboundedSpace;
|
||||
bool XR_MSFT_unbounded_reference_space_enabled;
|
||||
|
||||
explicit SessionContext(xr::SessionHandle sessionHandle,
|
||||
const sample::SystemContext& system,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
XrViewConfigurationType primaryViewConfigurationType,
|
||||
const std::vector<XrViewConfigurationType>& appEnabledSecondaryViewConfigurationTypes,
|
||||
const std::vector<DXGI_FORMAT>& appSupportedColorSwapchainFormats,
|
||||
|
@ -53,8 +53,8 @@ namespace sample {
|
|||
assert(xr::Contains(SupportedReferenceSpaces, XR_REFERENCE_SPACE_TYPE_VIEW));
|
||||
assert(xr::Contains(SupportedReferenceSpaces, XR_REFERENCE_SPACE_TYPE_LOCAL));
|
||||
SupportsStageSpace = xr::Contains(SupportedReferenceSpaces, XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
SupportsUnboundedSpace =
|
||||
extensions.SupportsUnboundedSpace && xr::Contains(SupportedReferenceSpaces, XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT);
|
||||
XR_MSFT_unbounded_reference_space_enabled =
|
||||
extensions.XR_MSFT_unbounded_reference_space_enabled&& xr::Contains(SupportedReferenceSpaces, XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include "XrUtility/XrEnumerate.h"
|
||||
#include "XrUtility/XrExtensionContext.h"
|
||||
#include "XrUtility/XrEnabledExtensions.h"
|
||||
#include "XrUtility/XrStruct.h"
|
||||
#include "XrUtility/XrViewConfiguration.h"
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace sample {
|
|||
|
||||
inline std::optional<sample::SystemContext>
|
||||
CreateSystemContext(XrInstance instance,
|
||||
const xr::ExtensionContext& extensions,
|
||||
const xr::EnabledExtensions& extensions,
|
||||
XrFormFactor formFactor,
|
||||
const std::vector<XrViewConfigurationType>& appSupportedViewConfigurationTypes,
|
||||
const std::vector<XrEnvironmentBlendMode>& appSupportedEnvironmentBlendMode) {
|
||||
|
@ -43,13 +43,13 @@ namespace sample {
|
|||
system.FormFactor = formFactor;
|
||||
|
||||
// Initialize system properties including extension system properties.
|
||||
if (extensions.SupportsHandJointTracking) {
|
||||
if (extensions.XR_EXT_hand_tracking_enabled) {
|
||||
xr::InsertExtensionStruct(system.Properties, system.HandTrackingProperties);
|
||||
}
|
||||
if (extensions.SupportsHandMeshTracking) {
|
||||
if (extensions.XR_MSFT_hand_tracking_mesh_enabled) {
|
||||
xr::InsertExtensionStruct(system.Properties, system.HandMeshProperties);
|
||||
}
|
||||
if (extensions.SupportsEyeGazeInteraction) {
|
||||
if (extensions.XR_EXT_eye_gaze_interaction_enabled) {
|
||||
xr::InsertExtensionStruct(system.Properties, system.EyeGazeInteractionProperties);
|
||||
}
|
||||
CHECK_XRCMD(xrGetSystemProperties(instance, system.Id, &system.Properties));
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace sample {
|
||||
// The properties of a view configuration that's immutable for a system
|
||||
struct ViewProperties {
|
||||
XrViewConfigurationType Type;
|
||||
XrBool32 FovMutable;
|
||||
XrEnvironmentBlendMode BlendMode;
|
||||
std::vector<XrEnvironmentBlendMode> SupportedBlendModes;
|
||||
};
|
||||
|
||||
// The state of a view configuration that's changing during a session but immutable for a frame
|
||||
struct ViewConfigurationState {
|
||||
XrViewConfigurationType Type;
|
||||
std::vector<XrViewConfigurationView> ViewConfigViews;
|
||||
std::vector<XrView> Views;
|
||||
bool Active;
|
||||
};
|
||||
|
||||
constexpr bool IsPrimaryViewConfigurationType(XrViewConfigurationType type) {
|
||||
return type == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO || type == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO ||
|
||||
type == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_QUAD_VARJO;
|
||||
}
|
||||
|
||||
inline ViewProperties CreateViewProperties(XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrViewConfigurationType viewConfigurationType,
|
||||
const std::vector<XrEnvironmentBlendMode>& appSupportedEnvironmentBlendModes) {
|
||||
XrViewConfigurationProperties viewConfigProperties{XR_TYPE_VIEW_CONFIGURATION_PROPERTIES};
|
||||
CHECK_XRCMD(xrGetViewConfigurationProperties(instance, systemId, viewConfigurationType, &viewConfigProperties));
|
||||
|
||||
ViewProperties properties{};
|
||||
properties.Type = viewConfigurationType;
|
||||
properties.FovMutable = viewConfigProperties.fovMutable;
|
||||
properties.SupportedBlendModes = xr::EnumerateEnvironmentBlendModes(instance, systemId, viewConfigurationType);
|
||||
properties.BlendMode = xr::PickEnvironmentBlendMode(properties.SupportedBlendModes, appSupportedEnvironmentBlendModes);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
inline ViewConfigurationState CreateViewConfigurationState(XrViewConfigurationType viewConfigurationType,
|
||||
XrInstance instance,
|
||||
XrSystemId systemId) {
|
||||
ViewConfigurationState state{};
|
||||
state.Type = viewConfigurationType;
|
||||
state.ViewConfigViews = xr::EnumerateViewConfigurationViews(instance, systemId, viewConfigurationType);
|
||||
state.Views.resize(state.ViewConfigViews.size(), {XR_TYPE_VIEW});
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
inline bool IsRecommendedSwapchainSizeChanged(const std::vector<XrViewConfigurationView>& oldConfigs,
|
||||
const std::vector<XrViewConfigurationView>& newConfigs) {
|
||||
assert(oldConfigs.size() == newConfigs.size());
|
||||
size_t end = (std::min)(oldConfigs.size(), newConfigs.size());
|
||||
for (size_t i = 0; i < end; i++) {
|
||||
if ((oldConfigs[i].recommendedImageRectWidth != newConfigs[i].recommendedImageRectWidth) ||
|
||||
(oldConfigs[i].recommendedImageRectHeight != newConfigs[i].recommendedImageRectHeight)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace sample
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <pbr/PbrResources.h>
|
||||
#include <XrUtility/XrString.h>
|
||||
#include <XrUtility/XrExtensionContext.h>
|
||||
#include <XrUtility/XrEnabledExtensions.h>
|
||||
#include <SampleShared/XrInstanceContext.h>
|
||||
#include <SampleShared/XrSystemContext.h>
|
||||
#include <SampleShared/XrSessionContext.h>
|
||||
|
@ -15,7 +15,7 @@ namespace engine {
|
|||
// Session-related resources shared across multiple Scenes.
|
||||
struct Context final {
|
||||
Context(sample::InstanceContext instance,
|
||||
xr::ExtensionContext extensions,
|
||||
xr::EnabledExtensions extensions,
|
||||
sample::SystemContext system,
|
||||
sample::SessionContext session,
|
||||
XrSpace appSpace,
|
||||
|
@ -32,7 +32,7 @@ namespace engine {
|
|||
, DeviceContext(std::move(deviceContext)) {
|
||||
}
|
||||
|
||||
const xr::ExtensionContext Extensions;
|
||||
const xr::EnabledExtensions Extensions;
|
||||
const sample::InstanceContext Instance;
|
||||
const sample::SystemContext System;
|
||||
const sample::SessionContext Session;
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace {
|
|||
};
|
||||
|
||||
ControllerObject::ControllerObject(engine::Context& context, XrPath controllerUserPath)
|
||||
: m_extensionSupported(context.Extensions.SupportsControllerModel)
|
||||
: m_extensionSupported(context.Extensions.XR_MSFT_controller_model_enabled)
|
||||
, m_controllerUserPath(controllerUserPath) {
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ void engine::ProjectionLayer::PrepareRendering(const Context& context,
|
|||
const uint32_t arrayLength = layerCurrentConfig.DoubleWideMode ? 1 : (uint32_t)viewConfigViews.size();
|
||||
|
||||
const std::optional<XrViewConfigurationType> viewConfigurationForSwapchain =
|
||||
context.Extensions.SupportsSecondaryViewConfiguration ? std::optional{viewConfigType} : std::nullopt;
|
||||
context.Extensions.XR_MSFT_secondary_view_configuration_enabled ? std::optional{viewConfigType} : std::nullopt;
|
||||
|
||||
// Create color swapchain with recommended properties.
|
||||
viewConfigComponent.ColorSwapchain =
|
||||
|
@ -217,7 +217,7 @@ bool engine::ProjectionLayer::Render(Context& context,
|
|||
projectionViews[viewIndex].subImage.imageRect = viewConfigComponent.LayerColorImageRect[viewIndex];
|
||||
|
||||
D3D11_VIEWPORT viewport = viewports[viewIndex];
|
||||
if (currentConfig.SubmitDepthInfo && context.Extensions.SupportsDepthInfo) {
|
||||
if (currentConfig.SubmitDepthInfo && context.Extensions.XR_KHR_composition_layer_depth_enabled) {
|
||||
depthInfo[viewIndex] = {XR_TYPE_COMPOSITION_LAYER_DEPTH_INFO_KHR};
|
||||
depthInfo[viewIndex].minDepth = viewport.MinDepth = normalizedViewportMinDepth;
|
||||
depthInfo[viewIndex].maxDepth = viewport.MaxDepth = normalizedViewportMaxDepth;
|
||||
|
|
|
@ -153,34 +153,35 @@ namespace {
|
|||
// Create an instance using combined extensions of XrSceneLib and the application.
|
||||
// The extension context record those supported by the runtime and enabled by the instance.
|
||||
std::vector<std::string> requestedExtensions = CombineSceneLibRequestedExtensions(m_appConfiguration.RequestedExtensions);
|
||||
std::vector<const char*> requestedExtensionsCStr;
|
||||
for (const std::string& ext : requestedExtensions) {
|
||||
requestedExtensionsCStr.push_back(ext.c_str());
|
||||
}
|
||||
std::vector<XrExtensionProperties> instanceExtensions = xr::EnumerateInstanceExtensionProperties();
|
||||
std::vector<std::string> selectedExtensions = xr::Intersect(
|
||||
requestedExtensions, instanceExtensions, [](const std::string& extension, const XrExtensionProperties& supported) {
|
||||
return extension == supported.extensionName;
|
||||
});
|
||||
std::vector<const char*> selectedExtensionsCstr = xr::StringsToCStrings(selectedExtensions);
|
||||
|
||||
xr::ExtensionContext extensions = xr::CreateExtensionContext(requestedExtensionsCStr);
|
||||
sample::InstanceContext instance =
|
||||
sample::CreateInstanceContext(m_appConfiguration.AppInfo, {"XrSceneLib", 1}, selectedExtensionsCstr);
|
||||
xr::EnabledExtensions enabledExtensions = xr::EnabledExtensions(selectedExtensionsCstr, instanceExtensions);
|
||||
|
||||
xr::g_dispatchTable.Initialize(instance.Handle, xrGetInstanceProcAddr);
|
||||
|
||||
// For example, this sample currently requires D3D11 extension to be supported.
|
||||
if (!extensions.SupportsD3D11) {
|
||||
if (!enabledExtensions.XR_KHR_D3D11_enable_enabled) {
|
||||
throw std::logic_error("This sample currently only supports D3D11.");
|
||||
}
|
||||
#if UWP
|
||||
if (!extensions.SupportsAppContainer) {
|
||||
if (!enabledExtensions.XR_EXT_win32_appcontainer_compatible_enabled) {
|
||||
throw std::logic_error("The UWP version of this sample requires XR_EXT_win32_appcontainer_compatible extension.");
|
||||
}
|
||||
#endif
|
||||
|
||||
sample::InstanceContext instance =
|
||||
sample::CreateInstanceContext(m_appConfiguration.AppInfo, {"XrSceneLib", 1}, extensions.EnabledExtensions);
|
||||
|
||||
xr::g_dispatchTable.Initialize(instance.Handle, xrGetInstanceProcAddr);
|
||||
|
||||
// Then get the active system with required form factor.
|
||||
// If no system is plugged in, wait until the device is plugged in.
|
||||
sample::SystemContext system = [&instance, &extensions] {
|
||||
sample::SystemContext system = [&instance, &enabledExtensions] {
|
||||
std::optional<sample::SystemContext> systemOpt;
|
||||
while (!(systemOpt = sample::CreateSystemContext(instance.Handle,
|
||||
extensions,
|
||||
enabledExtensions,
|
||||
XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY,
|
||||
SupportedViewConfigurationTypes,
|
||||
SupportedEnvironmentBlendModes))) {
|
||||
|
@ -195,7 +196,7 @@ namespace {
|
|||
}
|
||||
|
||||
auto [d3d11Binding, device, deviceContext] = sample::dx::CreateD3D11Binding(
|
||||
instance.Handle, system.Id, extensions, m_appConfiguration.SingleThreadedD3D11Device, SupportedFeatureLevels);
|
||||
instance.Handle, system.Id, enabledExtensions, m_appConfiguration.SingleThreadedD3D11Device, SupportedFeatureLevels);
|
||||
|
||||
xr::SessionHandle sessionHandle;
|
||||
XrSessionCreateInfo sessionCreateInfo{XR_TYPE_SESSION_CREATE_INFO, nullptr, 0, system.Id};
|
||||
|
@ -203,7 +204,7 @@ namespace {
|
|||
xr::InsertExtensionStruct(sessionCreateInfo, d3d11Binding);
|
||||
|
||||
XrHolographicWindowAttachmentMSFT holographicWindowAttachment;
|
||||
if (m_appConfiguration.HolographicWindowAttachment.has_value() && extensions.SupportsHolographicWindowAttachment) {
|
||||
if (m_appConfiguration.HolographicWindowAttachment.has_value() && enabledExtensions.XR_MSFT_holographic_window_attachment_enabled) {
|
||||
holographicWindowAttachment = m_appConfiguration.HolographicWindowAttachment.value();
|
||||
xr::InsertExtensionStruct(sessionCreateInfo, holographicWindowAttachment);
|
||||
}
|
||||
|
@ -212,7 +213,7 @@ namespace {
|
|||
|
||||
sample::SessionContext session(std::move(sessionHandle),
|
||||
system,
|
||||
extensions,
|
||||
enabledExtensions,
|
||||
PrimaryViewConfigurationType,
|
||||
SupportedViewConfigurationTypes, // enable all supported secondary view config
|
||||
SupportedColorSwapchainFormats,
|
||||
|
@ -231,14 +232,15 @@ namespace {
|
|||
CHECK_XRCMD(xrCreateReferenceSpace(session.Handle, &spaceCreateInfo, m_viewSpace.Put(xrDestroySpace)));
|
||||
|
||||
// Create main app space
|
||||
spaceCreateInfo.referenceSpaceType =
|
||||
extensions.SupportsUnboundedSpace ? XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT : XR_REFERENCE_SPACE_TYPE_LOCAL;
|
||||
spaceCreateInfo.referenceSpaceType = enabledExtensions.XR_MSFT_unbounded_reference_space_enabled
|
||||
? XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT
|
||||
: XR_REFERENCE_SPACE_TYPE_LOCAL;
|
||||
CHECK_XRCMD(xrCreateReferenceSpace(session.Handle, &spaceCreateInfo, m_appSpace.Put(xrDestroySpace)));
|
||||
|
||||
Pbr::Resources pbrResources = sample::InitializePbrResources(device.get());
|
||||
|
||||
m_context = std::make_unique<engine::Context>(std::move(instance),
|
||||
std::move(extensions),
|
||||
std::move(enabledExtensions),
|
||||
std::move(system),
|
||||
std::move(session),
|
||||
m_appSpace.Get(),
|
||||
|
@ -443,7 +445,7 @@ namespace {
|
|||
|
||||
XrSecondaryViewConfigurationSessionBeginInfoMSFT secondaryViewConfigInfo{
|
||||
XR_TYPE_SECONDARY_VIEW_CONFIGURATION_SESSION_BEGIN_INFO_MSFT};
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration &&
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled &&
|
||||
Context().Session.EnabledSecondaryViewConfigurationTypes.size() > 0) {
|
||||
secondaryViewConfigInfo.viewConfigurationCount = (uint32_t)Context().Session.EnabledSecondaryViewConfigurationTypes.size();
|
||||
secondaryViewConfigInfo.enabledViewConfigurationTypes = Context().Session.EnabledSecondaryViewConfigurationTypes.data();
|
||||
|
@ -473,7 +475,7 @@ namespace {
|
|||
std::vector<XrSecondaryViewConfigurationStateMSFT> secondaryViewConfigStates(enabledSecondaryViewConfigCount,
|
||||
{XR_TYPE_SECONDARY_VIEW_CONFIGURATION_STATE_MSFT});
|
||||
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration && enabledSecondaryViewConfigCount > 0) {
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled && enabledSecondaryViewConfigCount > 0) {
|
||||
secondaryViewConfigFrameState.viewConfigurationCount = (uint32_t)secondaryViewConfigStates.size();
|
||||
secondaryViewConfigFrameState.viewConfigurationStates = secondaryViewConfigStates.data();
|
||||
xr::InsertExtensionStruct(frameState, secondaryViewConfigFrameState);
|
||||
|
@ -482,7 +484,7 @@ namespace {
|
|||
XrFrameWaitInfo waitFrameInfo{XR_TYPE_FRAME_WAIT_INFO};
|
||||
CHECK_XRCMD(xrWaitFrame(Context().Session.Handle, &waitFrameInfo, &frameState));
|
||||
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration) {
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled) {
|
||||
std::scoped_lock lock(m_secondaryViewConfigActiveMutex);
|
||||
m_secondaryViewConfigurationsState = std::move(secondaryViewConfigStates);
|
||||
}
|
||||
|
@ -529,7 +531,7 @@ namespace {
|
|||
XrFrameBeginInfo beginFrameDescription{XR_TYPE_FRAME_BEGIN_INFO};
|
||||
CHECK_XRCMD(xrBeginFrame(Context().Session.Handle, &beginFrameDescription));
|
||||
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration) {
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled) {
|
||||
std::scoped_lock lock(m_secondaryViewConfigActiveMutex);
|
||||
for (auto& state : m_secondaryViewConfigurationsState) {
|
||||
SetSecondaryViewConfigurationActive(m_viewConfigStates.at(state.viewConfigurationType), state.active);
|
||||
|
@ -554,7 +556,7 @@ namespace {
|
|||
std::vector<XrSecondaryViewConfigurationLayerInfoMSFT> activeSecondaryViewConfigLayerInfos;
|
||||
|
||||
// Chain secondary view configuration layers data to endFrameInfo
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration &&
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled &&
|
||||
Context().Session.EnabledSecondaryViewConfigurationTypes.size() > 0) {
|
||||
for (auto& secondaryViewConfigType : Context().Session.EnabledSecondaryViewConfigurationTypes) {
|
||||
auto& secondaryViewConfig = m_viewConfigStates.at(secondaryViewConfigType);
|
||||
|
@ -593,7 +595,7 @@ namespace {
|
|||
endFrameInfo.layers = primaryViewConfigLayers.LayerData();
|
||||
|
||||
// Render layers for any active secondary view configurations too.
|
||||
if (Context().Extensions.SupportsSecondaryViewConfiguration && activeSecondaryViewConfigLayerInfos.size() > 0) {
|
||||
if (Context().Extensions.XR_MSFT_secondary_view_configuration_enabled && activeSecondaryViewConfigLayerInfos.size() > 0) {
|
||||
for (size_t i = 0; i < activeSecondaryViewConfigLayerInfos.size(); i++) {
|
||||
XrSecondaryViewConfigurationLayerInfoMSFT& secondaryViewConfigLayerInfo = activeSecondaryViewConfigLayerInfos.at(i);
|
||||
engine::CompositionLayers& secondaryViewConfigLayers = layersForAllViewConfigs.at(i + 1);
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <XrUtility/XrPlatformDependencies.h>
|
||||
#include <openxr/openxr.h>
|
||||
#include <openxr/openxr_platform.h>
|
||||
#include <openxr/openxr_reflection.h>
|
||||
#include <openxr/openxr_msft_preview.h>
|
||||
#include <openxr_preview/openxr_msft_preview.h>
|
||||
|
||||
#include "XrListFunctions.h"
|
||||
|
||||
|
@ -30,6 +29,7 @@ namespace xr {
|
|||
XR_LIST_FUNCTIONS_OPENXR_FUNCTIONS(XR_DISPATCH_TABLE_MEMBER);
|
||||
XR_LIST_FUNCTIONS_OPENXR_EXTENSIONS(XR_DISPATCH_TABLE_MEMBER, XR_DISPATCH_TABLE_MEMBER_VOID);
|
||||
XR_LIST_FUNCTIONS_MSFT_PREVIEW(XR_DISPATCH_TABLE_MEMBER);
|
||||
|
||||
#undef XR_DISPATCH_TABLE_DEFINE_MEMBER
|
||||
#undef XR_DISPATCH_TABLE_MEMBER_VOID
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include <openxr/openxr_reflection.h>
|
||||
#include <openxr_preview/openxr_msft_preview.h>
|
||||
|
||||
namespace xr {
|
||||
|
||||
// Struct of enabled flags is generated using openxr_reflection. Any non-public extensions will need to be added manually.
|
||||
struct EnabledExtensions {
|
||||
EnabledExtensions() = default;
|
||||
EnabledExtensions(const std::vector<const char*>& enabledExtensions, const std::vector<XrExtensionProperties>& extensionProperties)
|
||||
: EnabledExtensions(enabledExtensions.data(), (uint32_t)enabledExtensions.size(), extensionProperties) {
|
||||
}
|
||||
EnabledExtensions(const char* const* enabledExtensionNames,
|
||||
uint32_t enabledExtensionNamesCount,
|
||||
const std::vector<XrExtensionProperties>& extensionProperties) {
|
||||
auto getExtensionVersion = [&](const char* extensionName) -> uint32_t {
|
||||
for (const auto& extension : extensionProperties) {
|
||||
if (strcmp(extension.extensionName, extensionName) == 0) {
|
||||
return extension.extensionVersion;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
// "_enabled" or "_version" is token concat to the name because the extension name is also a C MACRO that can conflict.
|
||||
#define SET_EXTENSION_IF_MATCH(name, _) \
|
||||
if (strcmp(enabledExtensionNames[i], #name) == 0) { \
|
||||
name##_enabled = true; \
|
||||
name##_version = getExtensionVersion(#name); \
|
||||
continue; \
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < enabledExtensionNamesCount; i++) {
|
||||
XR_LIST_EXTENSIONS(SET_EXTENSION_IF_MATCH)
|
||||
XR_LIST_EXTENSIONS_MSFT_PREVIEW(SET_EXTENSION_IF_MATCH)
|
||||
}
|
||||
|
||||
#undef SET_EXTENSION_IF_MATCH
|
||||
}
|
||||
|
||||
// Example: for extension name `XR_KHR_extension_name`, there will be two fields define for it.
|
||||
// bool XR_KHR_extension_name_enabled; // it will be true if the extension is enabled by the current xrInstance
|
||||
// uint32 XR_KHR_extension_name_version; // it will be > 0 if the extension is enabled by the current xrInstance.
|
||||
#define DEFINE_EXTENSION_FIELD(name, _) \
|
||||
bool name##_enabled = false; \
|
||||
uint32_t name##_version = 0;
|
||||
|
||||
XR_LIST_EXTENSIONS(DEFINE_EXTENSION_FIELD)
|
||||
XR_LIST_EXTENSIONS_MSFT_PREVIEW(DEFINE_EXTENSION_FIELD)
|
||||
|
||||
#undef MSXR_ADD_EXTENSION_FIELD
|
||||
};
|
||||
|
||||
} // namespace xr
|
||||
|
|
@ -14,8 +14,31 @@ namespace xr {
|
|||
return std::end(array) != std::find(std::begin(array), std::end(array), value);
|
||||
}
|
||||
|
||||
template <class A, class B, class TIntersectPredicate>
|
||||
inline std::vector<A> Intersect(const std::vector<A>& listA, const std::vector<B>& listB, TIntersectPredicate predicate) {
|
||||
std::vector<A> result;
|
||||
for (auto& a : listA) {
|
||||
for (auto& b : listB) {
|
||||
if (predicate(a, b)) {
|
||||
result.push_back(a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::vector<XrApiLayerProperties> EnumerateApiLayerProperties() {
|
||||
uint32_t apiLayerCount = 0;
|
||||
CHECK_XRCMD(xrEnumerateApiLayerProperties(0, &apiLayerCount, nullptr));
|
||||
std::vector<XrApiLayerProperties> apiLayerProperties(apiLayerCount, {XR_TYPE_API_LAYER_PROPERTIES});
|
||||
CHECK_XRCMD(xrEnumerateApiLayerProperties(apiLayerCount, &apiLayerCount, apiLayerProperties.data()));
|
||||
apiLayerProperties.resize(apiLayerCount);
|
||||
return apiLayerProperties;
|
||||
}
|
||||
|
||||
inline std::vector<XrExtensionProperties> EnumerateInstanceExtensionProperties(const char* layerName = nullptr) {
|
||||
uint32_t extensionCount;
|
||||
uint32_t extensionCount = 0;
|
||||
CHECK_XRCMD(xrEnumerateInstanceExtensionProperties(layerName, 0, &extensionCount, nullptr));
|
||||
std::vector<XrExtensionProperties> extensionProperties(extensionCount, {XR_TYPE_EXTENSION_PROPERTIES});
|
||||
CHECK_XRCMD(xrEnumerateInstanceExtensionProperties(layerName, extensionCount, &extensionCount, extensionProperties.data()));
|
||||
|
@ -35,7 +58,7 @@ namespace xr {
|
|||
inline std::vector<XrViewConfigurationView> EnumerateViewConfigurationViews(XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrViewConfigurationType viewConfigurationType) {
|
||||
uint32_t viewCount;
|
||||
uint32_t viewCount = 0;
|
||||
CHECK_XRCMD(xrEnumerateViewConfigurationViews(instance, systemId, viewConfigurationType, 0, &viewCount, nullptr));
|
||||
|
||||
std::vector<XrViewConfigurationView> viewConfigViews(viewCount, {XR_TYPE_VIEW_CONFIGURATION_VIEW});
|
||||
|
@ -48,7 +71,7 @@ namespace xr {
|
|||
inline std::vector<XrEnvironmentBlendMode> EnumerateEnvironmentBlendModes(XrInstance instance,
|
||||
XrSystemId systemId,
|
||||
XrViewConfigurationType viewConfigType) {
|
||||
uint32_t blendModeCount;
|
||||
uint32_t blendModeCount = 0;
|
||||
CHECK_XRCMD(xrEnumerateEnvironmentBlendModes(instance, systemId, viewConfigType, 0, &blendModeCount, nullptr));
|
||||
|
||||
std::vector<XrEnvironmentBlendMode> blendModes(blendModeCount);
|
||||
|
@ -73,7 +96,7 @@ namespace xr {
|
|||
}
|
||||
|
||||
inline std::vector<int64_t> EnumerateSwapchainFormats(XrSession session) {
|
||||
uint32_t swapchainFormatsCount;
|
||||
uint32_t swapchainFormatsCount = 0;
|
||||
CHECK_XRCMD(xrEnumerateSwapchainFormats(session, 0, &swapchainFormatsCount, nullptr));
|
||||
|
||||
std::vector<int64_t> runtimeFormats(swapchainFormatsCount);
|
||||
|
@ -97,7 +120,7 @@ namespace xr {
|
|||
}
|
||||
|
||||
inline std::vector<XrReferenceSpaceType> EnumerateReferenceSpaceTypes(XrSession session) {
|
||||
uint32_t spaceCountOutput;
|
||||
uint32_t spaceCountOutput = 0;
|
||||
CHECK_XRCMD(xrEnumerateReferenceSpaces(session, 0, &spaceCountOutput, nullptr));
|
||||
|
||||
std::vector<XrReferenceSpaceType> runtimeSupportedReferenceSpaces(spaceCountOutput);
|
||||
|
@ -109,7 +132,7 @@ namespace xr {
|
|||
inline std::set<std::string> QueryActionLocalizedName(XrSession session, XrAction action, XrInputSourceLocalizedNameFlags flags) {
|
||||
std::set<std::string> names;
|
||||
uint32_t nameCapacityOutput = 0;
|
||||
uint32_t sourcesCount;
|
||||
uint32_t sourcesCount = 0;
|
||||
|
||||
XrBoundSourcesForActionEnumerateInfo enumerateBoundSourcesInfo{XR_TYPE_BOUND_SOURCES_FOR_ACTION_ENUMERATE_INFO};
|
||||
enumerateBoundSourcesInfo.action = action;
|
||||
|
|
|
@ -9,11 +9,15 @@
|
|||
#include "XrToString.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#define CHECK_XRCMD(cmd) xr::detail::_CheckXrResult(cmd, #cmd, FILE_AND_LINE)
|
||||
#define CHECK_XRRESULT(res, cmdStr) xr::detail::_CheckXrResult(res, cmdStr, FILE_AND_LINE)
|
||||
|
||||
#define CHECK_XRCMD_PRINT(cmd) xr::detail::_CheckXrResultPrint(cmd, #cmd, FILE_AND_LINE)
|
||||
|
||||
#define CHECK_HRCMD(cmd) xr::detail::_CheckHResult(cmd, #cmd, FILE_AND_LINE)
|
||||
#define CHECK_HRESULT(res, cmdStr) xr::detail::_CheckHResult(res, cmdStr, FILE_AND_LINE)
|
||||
|
||||
|
@ -55,6 +59,23 @@ namespace xr::detail {
|
|||
throw std::logic_error(failureMessage);
|
||||
}
|
||||
|
||||
inline void _Print(std::string failureMessage, const char* originator = nullptr, const char* sourceLocation = nullptr) {
|
||||
if (originator != nullptr) {
|
||||
failureMessage += _Fmt("\n Origin: %s", originator);
|
||||
}
|
||||
if (sourceLocation != nullptr) {
|
||||
failureMessage += _Fmt("\n Source: %s", sourceLocation);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
::OutputDebugStringA(failureMessage.c_str());
|
||||
#elif __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_INFO, "XrUtility", "%s", failureMessage.c_str());
|
||||
#else
|
||||
#error Unsupported platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
#define THROW(msg) xr::detail::_Throw(msg, nullptr, FILE_AND_LINE)
|
||||
#define CHECK(exp) \
|
||||
{ \
|
||||
|
@ -81,6 +102,18 @@ namespace xr::detail {
|
|||
return res;
|
||||
}
|
||||
|
||||
inline void _PrintXrResult(XrResult res, const char* originator = nullptr, const char* sourceLocation = nullptr) {
|
||||
_Print(_Fmt("XrResult failure [%s]", xr::ToCString(res)), originator, sourceLocation);
|
||||
}
|
||||
|
||||
inline XrResult _CheckXrResultPrint(XrResult res, const char* originator = nullptr, const char* sourceLocation = nullptr) {
|
||||
if (XR_FAILED(res)) {
|
||||
xr::detail::_PrintXrResult(res, originator, sourceLocation);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
[[noreturn]] inline void _ThrowHResult(HRESULT hr, const char* originator = nullptr, const char* sourceLocation = nullptr) {
|
||||
xr::detail::_Throw(xr::detail::_Fmt("HRESULT failure [%x]", hr), originator, sourceLocation);
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openxr/openxr_msft_preview.h>
|
||||
#include "XrEnumerate.h"
|
||||
|
||||
namespace xr {
|
||||
struct ExtensionContext {
|
||||
bool SupportsD3D11{false};
|
||||
bool SupportsD3D12{false};
|
||||
bool SupportsDepthInfo{false};
|
||||
bool SupportsVisibilityMask{false};
|
||||
bool SupportsUnboundedSpace{false};
|
||||
bool SupportsSpatialAnchor{false};
|
||||
bool SupportsHandInteractionEXT{false};
|
||||
bool SupportsHandInteractionMSFT{false};
|
||||
bool SupportsEyeGazeInteraction{false};
|
||||
bool SupportsHandJointTracking{false};
|
||||
bool SupportsHandMeshTracking{false};
|
||||
bool SupportsSpatialGraphBridge{false};
|
||||
bool SupportsControllerModel{false};
|
||||
bool SupportsSecondaryViewConfiguration{false};
|
||||
bool SupportsAppContainer{false};
|
||||
bool SupportsHolographicWindowAttachment{false};
|
||||
bool SupportsSamsungOdysseyController{false};
|
||||
bool SupportsHPMixedRealityController{false};
|
||||
bool SupportsSpatialAnchorPersistence{false};
|
||||
bool SupportsPerceptionAnchorInterop{false};
|
||||
bool SupportsColorScaleBias{false};
|
||||
bool SupportsSceneUnderstanding{false};
|
||||
bool SupportsSceneUnderstandingSerialization{false};
|
||||
bool SupportsReprojectionConfiguration{false};
|
||||
bool SupportsPalmPose{false};
|
||||
bool SupportsSceneMarker{false};
|
||||
|
||||
std::vector<const char*> EnabledExtensions;
|
||||
|
||||
inline bool IsEnabled(const char* extensionName) const {
|
||||
const auto it = std::find_if(
|
||||
EnabledExtensions.begin(), EnabledExtensions.end(), [&extensionName](auto&& i) { return 0 == strcmp(i, extensionName); });
|
||||
return it != EnabledExtensions.end();
|
||||
}
|
||||
};
|
||||
|
||||
inline ExtensionContext CreateExtensionContext(const std::vector<const char*>& requestedExtensions) {
|
||||
const std::vector<XrExtensionProperties> runtimeSupportedExtensions = xr::EnumerateInstanceExtensionProperties();
|
||||
|
||||
// Filter requested extensions to make sure enabled extensions are supported by current runtime
|
||||
xr::ExtensionContext extensions{};
|
||||
for (auto& requestedExtension : requestedExtensions) {
|
||||
for (const auto& supportedExtension : runtimeSupportedExtensions) {
|
||||
if (strcmp(supportedExtension.extensionName, requestedExtension) == 0) {
|
||||
extensions.EnabledExtensions.push_back(requestedExtension);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Record enabled extensions in extension context as bool for easy usage.
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D11
|
||||
extensions.SupportsD3D11 = extensions.IsEnabled(XR_KHR_D3D11_ENABLE_EXTENSION_NAME);
|
||||
#endif
|
||||
#ifdef XR_USE_GRAPHICS_API_D3D12
|
||||
extensions.SupportsD3D12 = extensions.IsEnabled(XR_KHR_D3D12_ENABLE_EXTENSION_NAME);
|
||||
#endif
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
extensions.SupportsAppContainer = extensions.IsEnabled(XR_EXT_WIN32_APPCONTAINER_COMPATIBLE_EXTENSION_NAME);
|
||||
extensions.SupportsHolographicWindowAttachment = extensions.IsEnabled(XR_MSFT_HOLOGRAPHIC_WINDOW_ATTACHMENT_EXTENSION_NAME);
|
||||
extensions.SupportsPerceptionAnchorInterop = extensions.IsEnabled(XR_MSFT_PERCEPTION_ANCHOR_INTEROP_EXTENSION_NAME);
|
||||
#endif
|
||||
extensions.SupportsDepthInfo = extensions.IsEnabled(XR_KHR_COMPOSITION_LAYER_DEPTH_EXTENSION_NAME);
|
||||
extensions.SupportsVisibilityMask = extensions.IsEnabled(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME);
|
||||
extensions.SupportsUnboundedSpace = extensions.IsEnabled(XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME);
|
||||
extensions.SupportsSpatialAnchor = extensions.IsEnabled(XR_MSFT_SPATIAL_ANCHOR_EXTENSION_NAME);
|
||||
extensions.SupportsHandInteractionEXT = extensions.IsEnabled(XR_EXT_HAND_INTERACTION_EXTENSION_NAME);
|
||||
extensions.SupportsHandInteractionMSFT = extensions.IsEnabled(XR_MSFT_HAND_INTERACTION_EXTENSION_NAME);
|
||||
extensions.SupportsEyeGazeInteraction = extensions.IsEnabled(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
|
||||
extensions.SupportsSecondaryViewConfiguration = extensions.IsEnabled(XR_MSFT_SECONDARY_VIEW_CONFIGURATION_EXTENSION_NAME);
|
||||
extensions.SupportsHandJointTracking = extensions.IsEnabled(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
|
||||
extensions.SupportsHandMeshTracking = extensions.IsEnabled(XR_MSFT_HAND_TRACKING_MESH_EXTENSION_NAME);
|
||||
extensions.SupportsSpatialGraphBridge = extensions.IsEnabled(XR_MSFT_SPATIAL_GRAPH_BRIDGE_EXTENSION_NAME);
|
||||
extensions.SupportsControllerModel = extensions.IsEnabled(XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME);
|
||||
extensions.SupportsSamsungOdysseyController = extensions.IsEnabled(XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME);
|
||||
extensions.SupportsHPMixedRealityController = extensions.IsEnabled(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
|
||||
extensions.SupportsColorScaleBias = extensions.IsEnabled(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
|
||||
extensions.SupportsSceneUnderstanding = extensions.IsEnabled(XR_MSFT_SCENE_UNDERSTANDING_EXTENSION_NAME);
|
||||
extensions.SupportsSceneUnderstandingSerialization = extensions.IsEnabled(XR_MSFT_SCENE_UNDERSTANDING_SERIALIZATION_EXTENSION_NAME);
|
||||
extensions.SupportsReprojectionConfiguration = extensions.IsEnabled(XR_MSFT_COMPOSITION_LAYER_REPROJECTION_EXTENSION_NAME);
|
||||
extensions.SupportsSpatialAnchorPersistence = extensions.IsEnabled(XR_MSFT_SPATIAL_ANCHOR_PERSISTENCE_EXTENSION_NAME);
|
||||
extensions.SupportsPalmPose = extensions.IsEnabled(XR_EXT_PALM_POSE_EXTENSION_NAME);
|
||||
extensions.SupportsSceneMarker = extensions.IsEnabled(XR_MSFTX_SCENE_MARKER_EXTENSION_NAME);
|
||||
|
||||
return extensions;
|
||||
}
|
||||
} // namespace xr
|
||||
|
|
@ -65,12 +65,6 @@
|
|||
#define XR_MSFT_spatial_graph_bridge_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_MSFT_holographic_remoting
|
||||
#define XR_MSFT_holographic_remoting_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_MSFT_holographic_remoting_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_MSFT_perception_anchor_interop
|
||||
#define XR_MSFT_perception_anchor_interop_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
|
@ -101,8 +95,80 @@
|
|||
#define XR_MSFT_composition_layer_reprojection_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_MSFTX_scene_marker
|
||||
#define XR_MSFTX_scene_marker_DEFINED(_, defined, undefined) _(defined)
|
||||
#ifdef XR_VARJO_marker_tracking
|
||||
#define XR_varjo_marker_tracking_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_MSFTX_scene_marker_DEFINED(_, defined, undefined) _(undefined)
|
||||
#define XR_varjo_marker_tracking_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_render_model
|
||||
#define XR_FB_render_model_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_render_model_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_keyboard_tracking
|
||||
#define XR_FB_keyboard_tracking_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_keyboard_tracking_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_MSFT_scene_marker
|
||||
#define XR_MSFT_scene_marker_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_MSFT_scene_marker_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_EXT_performance_settings
|
||||
#define XR_EXT_performance_settings_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_EXT_performance_settings_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_foveation
|
||||
#define XR_FB_foveation_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_foveation_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_swapchain_update_state
|
||||
#define XR_FB_swapchain_update_state_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_swapchain_update_state_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_passthrough
|
||||
#define XR_FB_passthrough_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_passthrough_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_keyboard_tracking
|
||||
#define XR_FB_keyboard_tracking_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_keyboard_tracking_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_display_refresh_rate
|
||||
#define XR_FB_display_refresh_rate_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_display_refresh_rate_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_VARJO_marker_tracking
|
||||
#define XR_varjo_marker_tracking_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_varjo_marker_tracking_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_FB_render_model
|
||||
#define XR_FB_render_model_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_FB_render_model_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
||||
#ifdef XR_MSFT_scene_marker
|
||||
#define XR_MSFT_scene_marker_DEFINED(_, defined, undefined) _(defined)
|
||||
#else
|
||||
#define XR_MSFT_scene_marker_DEFINED(_, defined, undefined) _(undefined)
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <functional>
|
||||
#include <string.h>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr {
|
||||
|
||||
|
|
|
@ -101,15 +101,6 @@
|
|||
_(xrDestroySpatialGraphNodeBindingMSFT) \
|
||||
_(xrGetSpatialGraphNodeBindingPropertiesMSFT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_MSFT_holographic_remoting(_) \
|
||||
_(xrRemotingSetContextPropertiesMSFT) \
|
||||
_(xrRemotingConnectMSFT) \
|
||||
_(xrRemotingListenMSFT) \
|
||||
_(xrRemotingDisconnectMSFT) \
|
||||
_(xrRemotingGetConnectionStateMSFT) \
|
||||
_(xrRemotingSetSecureConnectionClientCallbacksMSFT) \
|
||||
_(xrRemotingSetSecureConnectionServerCallbacksMSFT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_MSFT_perception_anchor_interop(_) \
|
||||
_(xrCreateSpatialAnchorFromPerceptionAnchorMSFT) \
|
||||
_(xrTryGetPerceptionAnchorFromSpatialAnchorMSFT)
|
||||
|
@ -130,6 +121,10 @@
|
|||
_(xrDeserializeSceneMSFT) \
|
||||
_(xrGetSerializedSceneFragmentDataMSFT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_MSFT_scene_marker(_) \
|
||||
_(xrGetSceneMarkerRawDataMSFT) \
|
||||
_(xrGetSceneMarkerDecodedStringMSFT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_MSFT_spatial_anchor_persistence(_) \
|
||||
_(xrCreateSpatialAnchorStoreConnectionMSFT) \
|
||||
_(xrDestroySpatialAnchorStoreConnectionMSFT) \
|
||||
|
@ -141,6 +136,52 @@
|
|||
|
||||
#define XR_LIST_FUNCTIONS_XR_MSFT_composition_layer_reprojection(_) _(xrEnumerateReprojectionModesMSFT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_EXT_performance_settings(_) _(xrPerfSettingsSetPerformanceLevelEXT)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_foveation(_) \
|
||||
_(xrCreateFoveationProfileFB) \
|
||||
_(xrDestroyFoveationProfileFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_swapchain_update_state(_) \
|
||||
_(xrUpdateSwapchainFB) \
|
||||
_(xrGetSwapchainStateFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_swapchain_update_state(_) \
|
||||
_(xrUpdateSwapchainFB) \
|
||||
_(xrGetSwapchainStateFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_passthrough(_) \
|
||||
_(xrCreatePassthroughFB) \
|
||||
_(xrDestroyPassthroughFB) \
|
||||
_(xrPassthroughStartFB) \
|
||||
_(xrPassthroughPauseFB) \
|
||||
_(xrCreatePassthroughLayerFB) \
|
||||
_(xrDestroyPassthroughLayerFB) \
|
||||
_(xrPassthroughLayerPauseFB) \
|
||||
_(xrPassthroughLayerResumeFB) \
|
||||
_(xrPassthroughLayerSetStyleFB) \
|
||||
_(xrCreateGeometryInstanceFB) \
|
||||
_(xrDestroyGeometryInstanceFB) \
|
||||
_(xrGeometryInstanceSetTransformFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_keyboard_tracking(_) \
|
||||
_(xrQuerySystemTrackedKeyboardFB) \
|
||||
_(xrCreateKeyboardSpaceFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_display_refresh_rate(_) \
|
||||
_(xrEnumerateDisplayRefreshRatesFB) \
|
||||
_(xrGetDisplayRefreshRateFB) \
|
||||
_(xrRequestDisplayRefreshRateFB)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_varjo_marker_tracking(_) \
|
||||
_(xrSetMarkerTrackingVARJO) \
|
||||
_(xrCreateMarkerSpaceVARJO)
|
||||
|
||||
#define XR_LIST_FUNCTIONS_XR_FB_render_model(_) \
|
||||
_(xrEnumerateRenderModelPathsFB) \
|
||||
_(xrGetRenderModelPropertiesFB) \
|
||||
_(xrLoadRenderModelFB)
|
||||
|
||||
// clang-format off
|
||||
#define XR_LIST_FUNCTIONS_OPENXR_EXTENSIONS(_, __) \
|
||||
XR_KHR_win32_convert_performance_counter_time_DEFINED(XR_LIST_FUNCTIONS_XR_KHR_win32_convert_performance_counter_time, _, __) \
|
||||
|
@ -153,10 +194,18 @@
|
|||
XR_EXT_hand_tracking_DEFINED(XR_LIST_FUNCTIONS_XR_EXT_hand_tracking, _, __) \
|
||||
XR_MSFT_hand_tracking_mesh_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_hand_tracking_mesh, _, __) \
|
||||
XR_MSFT_spatial_graph_bridge_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_spatial_graph_bridge, _, __) \
|
||||
XR_MSFT_holographic_remoting_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_holographic_remoting, _, __) \
|
||||
XR_MSFT_perception_anchor_interop_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_perception_anchor_interop, _, __) \
|
||||
XR_MSFT_scene_understanding_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_scene_understanding, _, __) \
|
||||
XR_MSFT_scene_understanding_serialization_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_scene_understanding_serialization, _, __) \
|
||||
XR_MSFT_scene_marker_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_scene_marker, _, __) \
|
||||
XR_MSFT_spatial_anchor_persistence_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_spatial_anchor_persistence, _, __) \
|
||||
XR_MSFT_composition_layer_reprojection_DEFINED(XR_LIST_FUNCTIONS_XR_MSFT_composition_layer_reprojection, _, __) \
|
||||
XR_EXT_performance_settings_DEFINED(XR_LIST_FUNCTIONS_XR_EXT_performance_settings, _, __) \
|
||||
XR_FB_foveation_DEFINED(XR_LIST_FUNCTIONS_XR_FB_foveation, _, __) \
|
||||
XR_FB_swapchain_update_state_DEFINED(XR_LIST_FUNCTIONS_XR_FB_swapchain_update_state, _, __) \
|
||||
XR_FB_passthrough_DEFINED(XR_LIST_FUNCTIONS_XR_FB_passthrough, _, __) \
|
||||
XR_FB_keyboard_tracking_DEFINED(XR_LIST_FUNCTIONS_XR_FB_keyboard_tracking, _, __) \
|
||||
XR_FB_display_refresh_rate_DEFINED(XR_LIST_FUNCTIONS_XR_FB_display_refresh_rate, _, __) \
|
||||
XR_varjo_marker_tracking_DEFINED(XR_LIST_FUNCTIONS_XR_varjo_marker_tracking, _, __) \
|
||||
XR_FB_render_model_DEFINED(XR_LIST_FUNCTIONS_XR_FB_render_model, _, __)
|
||||
// clang-format on
|
||||
|
|
|
@ -22,9 +22,8 @@ namespace xr::math {
|
|||
XrPosef Multiply(const XrPosef& a, const XrPosef& b);
|
||||
XrPosef Slerp(const XrPosef& a, const XrPosef& b, float alpha);
|
||||
XrPosef Invert(const XrPosef& pose);
|
||||
|
||||
bool NearEqual(const XrPosef& a, const XrPosef& b, const float epsilon);
|
||||
constexpr bool IsIdentity(const XrPosef& pose);
|
||||
|
||||
constexpr bool IsPoseValid(const XrSpaceLocation& location);
|
||||
constexpr bool IsPoseTracked(const XrSpaceLocation& location);
|
||||
constexpr bool IsPoseValid(const XrHandJointLocationEXT& jointLocation);
|
||||
|
@ -256,9 +255,10 @@ namespace xr::math {
|
|||
}
|
||||
|
||||
inline DirectX::XMMATRIX XM_CALLCONV LoadXrPose(const XrPosef& pose) {
|
||||
DirectX::XMMATRIX matrix = DirectX::XMMatrixRotationQuaternion(LoadXrQuaternion(pose.orientation));
|
||||
const XrVector3f& p = pose.position;
|
||||
matrix.r[3] = DirectX::XMVectorSet(p.x, p.y, p.z, 1.0f);
|
||||
const DirectX::XMVECTOR orientation = LoadXrQuaternion(pose.orientation);
|
||||
const DirectX::XMVECTOR position = LoadXrVector3(pose.position);
|
||||
DirectX::XMMATRIX matrix = DirectX::XMMatrixRotationQuaternion(orientation);
|
||||
matrix.r[3] = DirectX::XMVectorAdd(matrix.r[3], position);
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
@ -364,6 +364,27 @@ namespace xr::math {
|
|||
pose.orientation.y == 0 && pose.orientation.z == 0 && pose.orientation.w == 1;
|
||||
}
|
||||
|
||||
inline bool NearEqual(const XrPosef& a, const XrPosef& b, const float epsilon) {
|
||||
// Construct the difference in these poses as A^-1 * B
|
||||
const DirectX::XMVECTOR qaInverted = DirectX::XMQuaternionConjugate(LoadXrQuaternion(a.orientation));
|
||||
const DirectX::XMVECTOR paInverted = DirectX::XMVector3Rotate(DirectX::XMVectorNegate(LoadXrVector3(a.position)), qaInverted);
|
||||
const DirectX::XMVECTOR pb = LoadXrVector3(b.position);
|
||||
const DirectX::XMVECTOR qb = LoadXrQuaternion(b.orientation);
|
||||
|
||||
XrPosef diff;
|
||||
StoreXrQuaternion(&diff.orientation, DirectX::XMQuaternionMultiply(qaInverted, qb));
|
||||
StoreXrVector3(&diff.position, DirectX::XMVectorAdd(DirectX::XMVector3Rotate(paInverted, qb), pb));
|
||||
|
||||
// Check if the difference is the identity pose (within error of epsilon)
|
||||
return std::fabs(diff.position.x - Identity().position.x) < epsilon &&
|
||||
std::fabs(diff.position.y - Identity().position.y) < epsilon &&
|
||||
std::fabs(diff.position.z - Identity().position.z) < epsilon &&
|
||||
std::fabs(diff.orientation.x - Identity().orientation.x) < epsilon &&
|
||||
std::fabs(diff.orientation.y - Identity().orientation.y) < epsilon &&
|
||||
std::fabs(diff.orientation.z - Identity().orientation.z) < epsilon &&
|
||||
std::fabs(diff.orientation.w - Identity().orientation.w) < epsilon;
|
||||
}
|
||||
|
||||
constexpr bool IsPoseValid(XrSpaceLocationFlags locationFlags) {
|
||||
constexpr XrSpaceLocationFlags PoseValidFlags = XR_SPACE_LOCATION_POSITION_VALID_BIT | XR_SPACE_LOCATION_ORIENTATION_VALID_BIT;
|
||||
return (locationFlags & PoseValidFlags) == PoseValidFlags;
|
||||
|
|
|
@ -51,9 +51,8 @@ namespace xr::su {
|
|||
|
||||
struct SceneMarker { // XR_SCENE_COMPONENT_TYPE_MARKER_MSFT
|
||||
using Id = TypedUuid<SceneMarker>;
|
||||
using MarkerType = ::XrSceneMarkerTypeMSFT;
|
||||
SceneMarker::Id id;
|
||||
MarkerType markerType;
|
||||
::XrSceneMarkerTypeMSFT markerType;
|
||||
XrTime lastSeenTime;
|
||||
XrOffset2Df center;
|
||||
XrExtent2Df size;
|
||||
|
@ -258,47 +257,13 @@ namespace xr::su {
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class GetMarkerExtension {
|
||||
public:
|
||||
GetMarkerExtension(int count) {}
|
||||
|
||||
template <typename XrStruct>
|
||||
void Insert(XrStruct& xrStruct) {}
|
||||
|
||||
void CopyTo(T*, int k){}
|
||||
};
|
||||
|
||||
template <>
|
||||
class GetMarkerExtension<SceneQRCode> {
|
||||
std::vector<XrSceneMarkerQRCodeMSFT> m_qrCodes;
|
||||
XrSceneMarkerQRCodesMSFT m_sceneQRCodes{XR_TYPE_SCENE_MARKER_QR_CODES_MSFT};
|
||||
|
||||
public:
|
||||
GetMarkerExtension(int count)
|
||||
: m_qrCodes(count){
|
||||
m_sceneQRCodes.qrCodeCount = count;
|
||||
m_sceneQRCodes.qrCodes = m_qrCodes.data();
|
||||
}
|
||||
|
||||
template <typename XrStruct>
|
||||
void Insert(XrStruct& xrStruct) {
|
||||
xr::InsertExtensionStruct(xrStruct, m_sceneQRCodes);
|
||||
}
|
||||
|
||||
void CopyTo(SceneQRCode* target, int k) {
|
||||
target->qrVersion= m_qrCodes[k].qrVersion;
|
||||
target->symbolType = m_qrCodes[k].symbolType;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline std::vector<T> GetSceneMarkers(XrSceneMSFT scene) {
|
||||
XrSceneComponentsGetInfoMSFT getInfo{XR_TYPE_SCENE_COMPONENTS_GET_INFO_MSFT};
|
||||
getInfo.componentType = XR_SCENE_COMPONENT_TYPE_MARKER_MSFT;
|
||||
|
||||
XrSceneMarkerTypeFilterMSFT typesFilter{XR_TYPE_SCENE_MARKER_TYPE_FILTER_MSFT};
|
||||
XrSceneMarkerTypeMSFT markerTypes[1] = {XrSceneMarkerTypeMSFT::XR_SCENE_MARKER_TYPE_QR_CODE_MSFT };
|
||||
XrSceneMarkerTypeMSFT markerTypes[1] = {XrSceneMarkerTypeMSFT::XR_SCENE_MARKER_TYPE_QR_CODE_MSFT};
|
||||
typesFilter.markerTypeCount = static_cast<uint32_t>(std::size(markerTypes));
|
||||
typesFilter.markerTypes = markerTypes;
|
||||
xr::InsertExtensionStruct(getInfo, typesFilter);
|
||||
|
@ -314,12 +279,16 @@ namespace xr::su {
|
|||
|
||||
std::vector<XrSceneMarkerMSFT> markers(count);
|
||||
XrSceneMarkersMSFT sceneMarkers{XR_TYPE_SCENE_MARKERS_MSFT};
|
||||
sceneMarkers.sceneMarkerCount = count;
|
||||
sceneMarkers.sceneMarkerCapacityInput = count;
|
||||
sceneMarkers.sceneMarkers = markers.data();
|
||||
xr::InsertExtensionStruct(sceneComponents, sceneMarkers);
|
||||
|
||||
GetMarkerExtension<T> extension(count);
|
||||
extension.Insert(sceneComponents);
|
||||
std::vector<XrSceneMarkerQRCodeMSFT> qrCodes(count);
|
||||
XrSceneMarkerQRCodesMSFT sceneQRCodes{XR_TYPE_SCENE_MARKER_QR_CODES_MSFT};
|
||||
sceneQRCodes.qrCodeCapacityInput = count;
|
||||
sceneQRCodes.qrCodes = qrCodes.data();
|
||||
|
||||
xr::InsertExtensionStruct(sceneComponents, sceneQRCodes);
|
||||
|
||||
CHECK_XRCMD(xrGetSceneComponentsMSFT(scene, &getInfo, &sceneComponents));
|
||||
|
||||
|
@ -331,26 +300,25 @@ namespace xr::su {
|
|||
m.lastSeenTime = markers[k].lastSeenTime;
|
||||
m.center = markers[k].center;
|
||||
m.size = markers[k].size;
|
||||
extension.CopyTo(&m, k);
|
||||
m.qrVersion = qrCodes[k].version;
|
||||
m.symbolType = qrCodes[k].symbolType;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void GetSceneMarkerRawData(XrSceneMSFT scene, const SceneMarker::Id& markerId, std::vector<uint8_t>& data) {
|
||||
uint32_t dataSize;
|
||||
uint32_t dataSize = 0;
|
||||
CHECK_XRCMD(xrGetSceneMarkerRawDataMSFT(scene, (XrUuidMSFT*)&markerId, 0, &dataSize, nullptr));
|
||||
data.resize(dataSize);
|
||||
CHECK_XRCMD(xrGetSceneMarkerRawDataMSFT(scene, (XrUuidMSFT*)&markerId, dataSize, &dataSize, data.data()));
|
||||
}
|
||||
|
||||
inline std::string GetSceneMarkerDecodedString(XrSceneMSFT scene, const SceneMarker::Id& markerId) {
|
||||
uint32_t characterCount;
|
||||
uint32_t characterCount = 0;
|
||||
CHECK_XRCMD(xrGetSceneMarkerDecodedStringMSFT(scene, (XrUuidMSFT*)&markerId, 0, &characterCount, nullptr));
|
||||
std::string ret;
|
||||
ret.resize(characterCount);
|
||||
ret.resize(characterCount - 1); // std::string includes room for the null terminator.
|
||||
CHECK_XRCMD(xrGetSceneMarkerDecodedStringMSFT(scene, (XrUuidMSFT*)&markerId, characterCount, &characterCount, ret.data()));
|
||||
// characterCount includes the null terminator needed to fill the buffer but we need to trim it
|
||||
ret.resize(characterCount - 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,23 +26,29 @@ namespace xr {
|
|||
uint32_t count;
|
||||
CHECK_XRCMD(xrPathToString(instance, path, 0, &count, nullptr));
|
||||
std::string string;
|
||||
string.resize(count);
|
||||
string.resize(count - 1); // OpenXR size includes '\0', std::string::size doesn't.
|
||||
CHECK_XRCMD(xrPathToString(instance, path, count, &count, string.data()));
|
||||
// Remove the null character
|
||||
string.resize(count - 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
inline std::vector<XrPath> StringsToPaths(XrInstance instance, const std::vector<std::string>& strings) {
|
||||
std::vector<XrPath> paths;
|
||||
|
||||
for (auto string : strings) {
|
||||
for (auto& string : strings) {
|
||||
paths.push_back(xr::StringToPath(instance, string.c_str()));
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
inline std::vector<const char*> StringsToCStrings(const std::vector<std::string>& strings) {
|
||||
std::vector<const char*> cStrings;
|
||||
for (auto& string : strings) {
|
||||
cStrings.push_back(string.c_str());
|
||||
}
|
||||
return cStrings;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
inline std::wstring utf8_to_wide(std::string_view utf8Text) {
|
||||
if (utf8Text.empty()) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace xr {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include <openxr/openxr_platform.h>
|
||||
#include <openxr/openxr_reflection.h>
|
||||
#include <openxr_preview/openxr_msft_preview.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace msxr {
|
||||
|
||||
// Type trait which can be used for validation of extensible struct types. Does not validate position of member variables yet.
|
||||
template <typename T>
|
||||
using is_xr_struct =
|
||||
std::conjunction<std::is_same<XrStructureType, std::remove_const_t<decltype(T::type)>>, // T::type is XrStructureType
|
||||
std::is_same<void, std::remove_const_t<std::remove_pointer_t<decltype(T::next)>>>>; // T::next is void* or const
|
||||
// void*
|
||||
template <typename T>
|
||||
inline constexpr bool is_xr_struct_v = is_xr_struct<T>::value;
|
||||
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
||||
template <typename T>
|
||||
struct XrStructTraits {
|
||||
static_assert(sizeof(T) == -1, "Must define traits for your struct");
|
||||
};
|
||||
|
||||
#define DECLARE_XR_STRUCT_TRAITS(Type, Enum) \
|
||||
template <> \
|
||||
struct XrStructTraits<Type> { \
|
||||
static constexpr std::string_view name{#Type##sv}; \
|
||||
static constexpr XrStructureType type{static_cast<XrStructureType>(Enum)}; \
|
||||
};
|
||||
|
||||
XR_LIST_STRUCTURE_TYPES(DECLARE_XR_STRUCT_TRAITS)
|
||||
XR_LIST_STRUCTURE_TYPES_MSFT_PREVIEW(DECLARE_XR_STRUCT_TRAITS)
|
||||
} // namespace msxr
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#include "os.h"
|
||||
#warning "fmt/posix.h is deprecated; use fmt/os.h instead"
|
Загрузка…
Ссылка в новой задаче