From aa2b0f9f1d638becd6bb9ca3c357ac2561a36b07 Mon Sep 17 00:00:00 2001 From: Beyley Thomas Date: Fri, 29 Nov 2024 02:29:01 -0800 Subject: [PATCH] st/oxr: Implement the EXT_active_action_set_priority extension This is required for proper action set priority emulation in OpenComposite. Part-of: --- CMakeLists.txt | 96 ++++++++++--------- doc/changes/state_trackers/mr.2370.md | 1 + scripts/generate_oxr_ext_support.py | 1 + scripts/mapping.imp | 1 + .../include/xrt/xrt_config_build.h.cmake_in | 1 + src/xrt/state_trackers/oxr/oxr_api_action.c | 16 +++- src/xrt/state_trackers/oxr/oxr_chain.h | 2 +- .../oxr/oxr_extension_support.h | 13 +++ src/xrt/state_trackers/oxr/oxr_input.c | 56 ++++++++--- src/xrt/state_trackers/oxr/oxr_objects.h | 3 +- 10 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 doc/changes/state_trackers/mr.2370.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c7956b4c..d2fb15f62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,7 @@ set(XRT_OXR_RUNTIME_SUFFIX monado CACHE STRING "OpenXR client library suffix") mark_as_advanced(XRT_MODULE_COMPOSITOR_MAIN XRT_MODULE_COMPOSITOR_NULL XRT_FEATURE_OPENXR) # Misc extension support. +option(XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY "Enable XR_EXT_active_action_set_priority" ON) option(XRT_FEATURE_OPENXR_BODY_TRACKING_FB "Enable XR_FB_body_tracking" OFF) option(XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE "Enable XR_FB_display_refresh_rate" ON) option(XRT_FEATURE_OPENXR_FACE_TRACKING2_FB "Enable XR_FB_face_tracking2" OFF) @@ -574,53 +575,54 @@ message(STATUS "# MODULE_IPC: ${XRT_MODULE_IPC}") message(STATUS "# MODULE_MONADO_GUI: ${XRT_MODULE_MONADO_GUI}") message(STATUS "# MODULE_MONADO_CLI: ${XRT_MODULE_MONADO_CLI}") message(STATUS "#") -message(STATUS "# FEATURE_AHARDWARE_BUFFER: ${XRT_FEATURE_AHARDWARE_BUFFER}") -message(STATUS "# FEATURE_CLIENT_DEBUG_GUI: ${XRT_FEATURE_CLIENT_DEBUG_GUI}") -message(STATUS "# FEATURE_COLOR_LOG: ${XRT_FEATURE_COLOR_LOG}") -message(STATUS "# FEATURE_DEBUG_GUI: ${XRT_FEATURE_DEBUG_GUI}") -message(STATUS "# FEATURE_OPENXR: ${XRT_FEATURE_OPENXR}") -message(STATUS "# FEATURE_OPENXR_BODY_TRACKING_FB: ${XRT_FEATURE_OPENXR_BODY_TRACKING_FB}") -message(STATUS "# FEATURE_OPENXR_FACE_TRACKING2_FB: ${XRT_FEATURE_OPENXR_FACE_TRACKING2_FB}") -message(STATUS "# FEATURE_OPENXR_DEBUG_UTILS: ${XRT_FEATURE_OPENXR_DEBUG_UTILS}") -message(STATUS "# FEATURE_OPENXR_DISPLAY_REFRESH_RATE: ${XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE}") -message(STATUS "# FEATURE_OPENXR_FACIAL_TRACKING_HTC: ${XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC}") -message(STATUS "# FEATURE_OPENXR_FORCE_FEEDBACK_CURL: ${XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL}") -message(STATUS "# FEATURE_OPENXR_HAND_TRACKING_EXT: ${XRT_FEATURE_OPENXR_HAND_TRACKING_EXT}") -message(STATUS "# FEATURE_OPENXR_HEADLESS: ${XRT_FEATURE_OPENXR_HEADLESS}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_HAND: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_ML2: ${XRT_FEATURE_OPENXR_INTERACTION_ML2}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_MNDX: ${XRT_FEATURE_OPENXR_INTERACTION_MNDX}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_MSFT_HAND: ${XRT_FEATURE_OPENXR_INTERACTION_MSFT_HAND}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_OPPO: ${XRT_FEATURE_OPENXR_INTERACTION_OPPO}") -message(STATUS "# FEATURE_OPENXR_INTERACTION_WINMR: ${XRT_FEATURE_OPENXR_INTERACTION_WINMR}") -message(STATUS "# FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS: ${XRT_FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS}") -message(STATUS "# FEATURE_OPENXR_LAYER_CUBE: ${XRT_FEATURE_OPENXR_LAYER_CUBE}") -message(STATUS "# FEATURE_OPENXR_LAYER_CYLINDER: ${XRT_FEATURE_OPENXR_LAYER_CYLINDER}") -message(STATUS "# FEATURE_OPENXR_LAYER_DEPTH: ${XRT_FEATURE_OPENXR_LAYER_DEPTH}") -message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT1: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT1}") -message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT2: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT2}") -message(STATUS "# FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND: ${XRT_FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND}") -message(STATUS "# FEATURE_OPENXR_LAYER_FB_DEPTH_TEST: ${XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST}") -message(STATUS "# FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT ${XRT_FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT}") -message(STATUS "# FEATURE_OPENXR_LAYER_FB_SETTINGS: ${XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS}") -message(STATUS "# FEATURE_OPENXR_LAYER_FB_PASSTHROUGH: ${XRT_FEATURE_OPENXR_LAYER_FB_PASSTHROUGH}") -message(STATUS "# FEATURE_OPENXR_OVERLAY: ${XRT_FEATURE_OPENXR_OVERLAY}") -message(STATUS "# FEATURE_OPENXR_PERFORMANCE_SETTINGS: ${XRT_FEATURE_OPENXR_PERFORMANCE_SETTINGS}") -message(STATUS "# FEATURE_OPENXR_SPACE_LOCAL_FLOOR: ${XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR}") -message(STATUS "# FEATURE_OPENXR_SPACE_UNBOUNDED: ${XRT_FEATURE_OPENXR_SPACE_UNBOUNDED}") -message(STATUS "# FEATURE_OPENXR_VISIBILITY_MASK ${XRT_FEATURE_OPENXR_VISIBILITY_MASK}") -message(STATUS "# FEATURE_OPENXR_VULKAN_SWAPCHAIN_FORMAT_LIST ${XRT_FEATURE_OPENXR_VULKAN_SWAPCHAIN_FORMAT_LIST}") -message(STATUS "# FEATURE_OPENXR_XDEV_SPACE: ${XRT_FEATURE_OPENXR_XDEV_SPACE}") -message(STATUS "# FEATURE_RENDERDOC: ${XRT_FEATURE_RENDERDOC}") -message(STATUS "# FEATURE_SERVICE: ${XRT_FEATURE_SERVICE}") -message(STATUS "# FEATURE_SERVICE_SYSTEMD: ${XRT_FEATURE_SERVICE_SYSTEMD}") -message(STATUS "# FEATURE_SLAM: ${XRT_FEATURE_SLAM}") -message(STATUS "# FEATURE_SSE2: ${XRT_FEATURE_SSE2}") -message(STATUS "# FEATURE_STEAMVR_PLUGIN: ${XRT_FEATURE_STEAMVR_PLUGIN}") -message(STATUS "# FEATURE_TRACING: ${XRT_FEATURE_TRACING}") -message(STATUS "# FEATURE_WINDOW_PEEK: ${XRT_FEATURE_WINDOW_PEEK}") +message(STATUS "# FEATURE_AHARDWARE_BUFFER: ${XRT_FEATURE_AHARDWARE_BUFFER}") +message(STATUS "# FEATURE_CLIENT_DEBUG_GUI: ${XRT_FEATURE_CLIENT_DEBUG_GUI}") +message(STATUS "# FEATURE_COLOR_LOG: ${XRT_FEATURE_COLOR_LOG}") +message(STATUS "# FEATURE_DEBUG_GUI: ${XRT_FEATURE_DEBUG_GUI}") +message(STATUS "# FEATURE_OPENXR: ${XRT_FEATURE_OPENXR}") +message(STATUS "# FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY: ${XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY}") +message(STATUS "# FEATURE_OPENXR_BODY_TRACKING_FB: ${XRT_FEATURE_OPENXR_BODY_TRACKING_FB}") +message(STATUS "# FEATURE_OPENXR_FACE_TRACKING2_FB: ${XRT_FEATURE_OPENXR_FACE_TRACKING2_FB}") +message(STATUS "# FEATURE_OPENXR_DEBUG_UTILS: ${XRT_FEATURE_OPENXR_DEBUG_UTILS}") +message(STATUS "# FEATURE_OPENXR_DISPLAY_REFRESH_RATE: ${XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE}") +message(STATUS "# FEATURE_OPENXR_FACIAL_TRACKING_HTC: ${XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC}") +message(STATUS "# FEATURE_OPENXR_FORCE_FEEDBACK_CURL: ${XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL}") +message(STATUS "# FEATURE_OPENXR_HAND_TRACKING_EXT: ${XRT_FEATURE_OPENXR_HAND_TRACKING_EXT}") +message(STATUS "# FEATURE_OPENXR_HEADLESS: ${XRT_FEATURE_OPENXR_HEADLESS}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_HAND: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE: ${XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_ML2: ${XRT_FEATURE_OPENXR_INTERACTION_ML2}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_MNDX: ${XRT_FEATURE_OPENXR_INTERACTION_MNDX}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_MSFT_HAND: ${XRT_FEATURE_OPENXR_INTERACTION_MSFT_HAND}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_OPPO: ${XRT_FEATURE_OPENXR_INTERACTION_OPPO}") +message(STATUS "# FEATURE_OPENXR_INTERACTION_WINMR: ${XRT_FEATURE_OPENXR_INTERACTION_WINMR}") +message(STATUS "# FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS: ${XRT_FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS}") +message(STATUS "# FEATURE_OPENXR_LAYER_CUBE: ${XRT_FEATURE_OPENXR_LAYER_CUBE}") +message(STATUS "# FEATURE_OPENXR_LAYER_CYLINDER: ${XRT_FEATURE_OPENXR_LAYER_CYLINDER}") +message(STATUS "# FEATURE_OPENXR_LAYER_DEPTH: ${XRT_FEATURE_OPENXR_LAYER_DEPTH}") +message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT1: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT1}") +message(STATUS "# FEATURE_OPENXR_LAYER_EQUIRECT2: ${XRT_FEATURE_OPENXR_LAYER_EQUIRECT2}") +message(STATUS "# FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND: ${XRT_FEATURE_OPENXR_LAYER_FB_ALPHA_BLEND}") +message(STATUS "# FEATURE_OPENXR_LAYER_FB_DEPTH_TEST: ${XRT_FEATURE_OPENXR_LAYER_FB_DEPTH_TEST}") +message(STATUS "# FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT ${XRT_FEATURE_OPENXR_LAYER_FB_IMAGE_LAYOUT}") +message(STATUS "# FEATURE_OPENXR_LAYER_FB_SETTINGS: ${XRT_FEATURE_OPENXR_LAYER_FB_SETTINGS}") +message(STATUS "# FEATURE_OPENXR_LAYER_FB_PASSTHROUGH: ${XRT_FEATURE_OPENXR_LAYER_FB_PASSTHROUGH}") +message(STATUS "# FEATURE_OPENXR_OVERLAY: ${XRT_FEATURE_OPENXR_OVERLAY}") +message(STATUS "# FEATURE_OPENXR_PERFORMANCE_SETTINGS: ${XRT_FEATURE_OPENXR_PERFORMANCE_SETTINGS}") +message(STATUS "# FEATURE_OPENXR_SPACE_LOCAL_FLOOR: ${XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR}") +message(STATUS "# FEATURE_OPENXR_SPACE_UNBOUNDED: ${XRT_FEATURE_OPENXR_SPACE_UNBOUNDED}") +message(STATUS "# FEATURE_OPENXR_VISIBILITY_MASK: ${XRT_FEATURE_OPENXR_VISIBILITY_MASK}") +message(STATUS "# FEATURE_OPENXR_VULKAN_SWAPCHAIN_FORMAT_LIST: ${XRT_FEATURE_OPENXR_VULKAN_SWAPCHAIN_FORMAT_LIST}") +message(STATUS "# FEATURE_OPENXR_XDEV_SPACE: ${XRT_FEATURE_OPENXR_XDEV_SPACE}") +message(STATUS "# FEATURE_RENDERDOC: ${XRT_FEATURE_RENDERDOC}") +message(STATUS "# FEATURE_SERVICE: ${XRT_FEATURE_SERVICE}") +message(STATUS "# FEATURE_SERVICE_SYSTEMD: ${XRT_FEATURE_SERVICE_SYSTEMD}") +message(STATUS "# FEATURE_SLAM: ${XRT_FEATURE_SLAM}") +message(STATUS "# FEATURE_SSE2: ${XRT_FEATURE_SSE2}") +message(STATUS "# FEATURE_STEAMVR_PLUGIN: ${XRT_FEATURE_STEAMVR_PLUGIN}") +message(STATUS "# FEATURE_TRACING: ${XRT_FEATURE_TRACING}") +message(STATUS "# FEATURE_WINDOW_PEEK: ${XRT_FEATURE_WINDOW_PEEK}") message(STATUS "#") message(STATUS "# DRIVER_ANDROID: ${XRT_BUILD_DRIVER_ANDROID}") message(STATUS "# DRIVER_ARDUINO: ${XRT_BUILD_DRIVER_ARDUINO}") diff --git a/doc/changes/state_trackers/mr.2370.md b/doc/changes/state_trackers/mr.2370.md new file mode 100644 index 000000000..a8bfbb869 --- /dev/null +++ b/doc/changes/state_trackers/mr.2370.md @@ -0,0 +1 @@ +- st/oxr: Implement the EXT_active_action_set_priority extension. diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index b31b413ef..56e996e39 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -57,6 +57,7 @@ EXTENSIONS = ( ['XR_KHR_vulkan_enable2', 'XR_USE_GRAPHICS_API_VULKAN'], ['XR_KHR_vulkan_swapchain_format_list', 'XR_USE_GRAPHICS_API_VULKAN', 'XRT_FEATURE_OPENXR_VULKAN_SWAPCHAIN_FORMAT_LIST'], ['XR_KHR_win32_convert_performance_counter_time', 'XR_USE_PLATFORM_WIN32'], + ['XR_EXT_active_action_set_priority', 'XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY'], ['XR_EXT_debug_utils', 'XRT_FEATURE_OPENXR_DEBUG_UTILS'], ['XR_EXT_dpad_binding'], ['XR_EXT_eye_gaze_interaction', 'XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE'], diff --git a/scripts/mapping.imp b/scripts/mapping.imp index e0d9c5e26..3dd8b6866 100644 --- a/scripts/mapping.imp +++ b/scripts/mapping.imp @@ -32,6 +32,7 @@ { symbol: ["XRT_FEATURE_COLOR_LOG", "public", "\"xrt/xrt_config_build.h\"", "public"] }, { symbol: ["XRT_FEATURE_DEBUG_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] }, { symbol: ["XRT_FEATURE_OPENXR", "public", "\"xrt/xrt_config_build.h\"", "public"] }, +{ symbol: ["XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY", "public", "\"xrt/xrt_config_build.h\"", "public"] }, { symbol: ["XRT_FEATURE_OPENXR_BODY_TRACKING_FB", "public", "\"xrt/xrt_config_build.h\"", "public"] }, { symbol: ["XRT_FEATURE_OPENXR_DEBUG_UTILS", "public", "\"xrt/xrt_config_build.h\"", "public"] }, { symbol: ["XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE", "public", "\"xrt/xrt_config_build.h\"", "public"] }, diff --git a/src/xrt/include/xrt/xrt_config_build.h.cmake_in b/src/xrt/include/xrt/xrt_config_build.h.cmake_in index 6a6e6c4f9..ab14c1aa9 100644 --- a/src/xrt/include/xrt/xrt_config_build.h.cmake_in +++ b/src/xrt/include/xrt/xrt_config_build.h.cmake_in @@ -29,6 +29,7 @@ #cmakedefine XRT_FEATURE_COLOR_LOG #cmakedefine XRT_FEATURE_DEBUG_GUI #cmakedefine XRT_FEATURE_OPENXR +#cmakedefine XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY #cmakedefine XRT_FEATURE_OPENXR_BODY_TRACKING_FB #cmakedefine XRT_FEATURE_OPENXR_DEBUG_UTILS #cmakedefine XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE diff --git a/src/xrt/state_trackers/oxr/oxr_api_action.c b/src/xrt/state_trackers/oxr/oxr_api_action.c index e112255eb..d12452953 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_action.c +++ b/src/xrt/state_trackers/oxr/oxr_api_action.c @@ -132,6 +132,19 @@ oxr_xrSyncActions(XrSession session, const XrActionsSyncInfo *syncInfo) OXR_VERIFY_SESSION_NOT_LOST(&log, sess); OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, syncInfo, XR_TYPE_ACTIONS_SYNC_INFO); + const XrActiveActionSetPrioritiesEXT *active_priorities = NULL; + +#ifdef OXR_HAVE_EXT_active_action_set_priority + active_priorities = OXR_GET_OUTPUT_FROM_CHAIN(syncInfo->next, XR_TYPE_ACTIVE_ACTION_SET_PRIORITIES_EXT, + const XrActiveActionSetPrioritiesEXT); + + // ensure that if the active priority override is present, + // the EXT_active_action_set_priority extension is enabled + if (active_priorities) { + OXR_VERIFY_EXTENSION(&log, sess->sys->inst, EXT_active_action_set_priority); + } +#endif + struct xrt_system_roles sys_roles = XRT_STRUCT_INIT; xrt_system_devices_get_roles(sess->sys->xsysd, &sys_roles); { @@ -159,7 +172,8 @@ oxr_xrSyncActions(XrSession session, const XrActionsSyncInfo *syncInfo) } } - return oxr_action_sync_data(&log, sess, syncInfo->countActiveActionSets, syncInfo->activeActionSets); + return oxr_action_sync_data(&log, sess, syncInfo->countActiveActionSets, syncInfo->activeActionSets, + active_priorities); } XRAPI_ATTR XrResult XRAPI_CALL diff --git a/src/xrt/state_trackers/oxr/oxr_chain.h b/src/xrt/state_trackers/oxr/oxr_chain.h index f5adbfc35..f7db9c573 100644 --- a/src/xrt/state_trackers/oxr/oxr_chain.h +++ b/src/xrt/state_trackers/oxr/oxr_chain.h @@ -61,7 +61,7 @@ oxr_find_input_in_chain(const void *ptr, XrStructureType desired) * casting. */ static inline XrBaseOutStructure * -oxr_find_output_in_chain(void *ptr, XrStructureType desired) +oxr_find_output_in_chain(const void *ptr, XrStructureType desired) { while (ptr != NULL) { XrBaseOutStructure *base = (XrBaseOutStructure *)ptr; diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index df5a7ecb8..538717eda 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -293,6 +293,18 @@ #endif +/* + * XR_EXT_active_action_set_priority + */ +#if defined(XR_EXT_active_action_set_priority) && defined(XRT_FEATURE_OPENXR_ACTIVE_ACTION_SET_PRIORITY) +#define OXR_HAVE_EXT_active_action_set_priority +#define OXR_EXTENSION_SUPPORT_EXT_active_action_set_priority(_) \ + _(EXT_active_action_set_priority, EXT_ACTIVE_ACTION_SET_PRIORITY) +#else +#define OXR_EXTENSION_SUPPORT_EXT_active_action_set_priority(_) +#endif + + /* * XR_EXT_debug_utils */ @@ -783,6 +795,7 @@ OXR_EXTENSION_SUPPORT_KHR_vulkan_enable2(_) \ OXR_EXTENSION_SUPPORT_KHR_vulkan_swapchain_format_list(_) \ OXR_EXTENSION_SUPPORT_KHR_win32_convert_performance_counter_time(_) \ + OXR_EXTENSION_SUPPORT_EXT_active_action_set_priority(_) \ OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \ OXR_EXTENSION_SUPPORT_EXT_dpad_binding(_) \ OXR_EXTENSION_SUPPORT_EXT_eye_gaze_interaction(_) \ diff --git a/src/xrt/state_trackers/oxr/oxr_input.c b/src/xrt/state_trackers/oxr/oxr_input.c index 266316539..bf69e79ac 100644 --- a/src/xrt/state_trackers/oxr/oxr_input.c +++ b/src/xrt/state_trackers/oxr/oxr_input.c @@ -58,7 +58,8 @@ oxr_action_cache_update(struct oxr_logger *log, struct oxr_action_cache *cache, int64_t time, struct oxr_subaction_paths *subaction_path, - bool select); + bool select, + const XrActiveActionSetPrioritiesEXT *active_priorities); static void oxr_action_attachment_update(struct oxr_logger *log, @@ -67,7 +68,8 @@ oxr_action_attachment_update(struct oxr_logger *log, const XrActiveActionSet *actionSets, struct oxr_action_attachment *act_attached, int64_t time, - struct oxr_subaction_paths subaction_paths); + struct oxr_subaction_paths subaction_paths, + const XrActiveActionSetPrioritiesEXT *active_priorities); static void oxr_action_bind_io(struct oxr_logger *log, @@ -925,16 +927,37 @@ oxr_input_is_bound_in_act_set(struct oxr_action_input *action_input, struct oxr_ return false; } +static uint32_t +oxr_get_action_set_priority(const struct oxr_action_set_ref *act_set_ref, + const XrActiveActionSetPrioritiesEXT *active_priorities) +{ + if (active_priorities) { + for (uint32_t i = 0; i < active_priorities->actionSetPriorityCount; i++) { + XrActiveActionSetPriorityEXT act_set_priority = active_priorities->actionSetPriorities[i]; + + struct oxr_action_set *action_set = + XRT_CAST_OXR_HANDLE_TO_PTR(struct oxr_action_set *, act_set_priority.actionSet); + + if (action_set->data == act_set_ref) { + return act_set_priority.priorityOverride; + } + } + } + + return act_set_ref->priority; +} + static bool oxr_input_supressed(struct oxr_session *sess, uint32_t countActionSets, const XrActiveActionSet *actionSets, struct oxr_subaction_paths *subaction_path, struct oxr_action_attachment *act_attached, - struct oxr_action_input *action_input) + struct oxr_action_input *action_input, + const XrActiveActionSetPrioritiesEXT *active_priorities) { struct oxr_action_set_ref *act_set_ref = act_attached->act_set_attached->act_set_ref; - uint32_t priority = act_set_ref->priority; + uint32_t priority = oxr_get_action_set_priority(act_set_ref, active_priorities); // find sources that are bound to an action in a set with higher prio for (uint32_t i = 0; i < countActionSets; i++) { @@ -954,7 +977,7 @@ oxr_input_supressed(struct oxr_session *sess, } /* input may be suppressed by action set with higher prio */ - if (other_act_set_attached->act_set_ref->priority <= priority) { + if (oxr_get_action_set_priority(other_act_set_attached->act_set_ref, active_priorities) <= priority) { continue; } @@ -993,7 +1016,8 @@ oxr_input_combine_input(struct oxr_session *sess, struct oxr_action_cache *cache, struct oxr_input_value_tagged *out_input, int64_t *out_timestamp, - bool *out_is_active) + bool *out_is_active, + const XrActiveActionSetPrioritiesEXT *active_priorities) { struct oxr_action_input *inputs = cache->inputs; size_t input_count = cache->input_count; @@ -1013,8 +1037,8 @@ oxr_input_combine_input(struct oxr_session *sess, // suppress input if it is also bound to action in set with // higher priority - if (oxr_input_supressed(sess, countActionSets, actionSets, subaction_path, act_attached, - action_input)) { + if (oxr_input_supressed(sess, countActionSets, actionSets, subaction_path, act_attached, action_input, + active_priorities)) { continue; } @@ -1111,7 +1135,8 @@ oxr_action_cache_update(struct oxr_logger *log, struct oxr_action_cache *cache, int64_t time, struct oxr_subaction_paths *subaction_path, - bool selected) + bool selected, + const XrActiveActionSetPrioritiesEXT *active_priorities) { struct oxr_action_state last = cache->current; @@ -1144,7 +1169,8 @@ oxr_action_cache_update(struct oxr_logger *log, cache, // cache &combined, // out_input ×tamp, // out_timestamp - &is_active); // out_is_active + &is_active, // out_is_active + active_priorities); // active_priorities if (!bret) { oxr_log(log, "Failed to get/combine input values '%s'", act_attached->act_ref->name); return; @@ -1291,7 +1317,8 @@ oxr_action_attachment_update(struct oxr_logger *log, const XrActiveActionSet *actionSets, struct oxr_action_attachment *act_attached, int64_t time, - struct oxr_subaction_paths subaction_paths) + struct oxr_subaction_paths subaction_paths, + const XrActiveActionSetPrioritiesEXT *active_priorities) { // This really shouldn't be happening. if (act_attached == NULL) { @@ -1303,7 +1330,7 @@ oxr_action_attachment_update(struct oxr_logger *log, subaction_paths_##X.X = true; \ bool select_##X = subaction_paths.X || subaction_paths.any; \ oxr_action_cache_update(log, sess, countActionSets, actionSets, act_attached, &act_attached->X, time, \ - &subaction_paths_##X, select_##X); + &subaction_paths_##X, select_##X, active_priorities); OXR_FOR_EACH_VALID_SUBACTION_PATH(UPDATE_SELECT) #undef UPDATE_SELECT @@ -1792,7 +1819,8 @@ XrResult oxr_action_sync_data(struct oxr_logger *log, struct oxr_session *sess, uint32_t countActionSets, - const XrActiveActionSet *actionSets) + const XrActiveActionSet *actionSets, + const XrActiveActionSetPrioritiesEXT *activePriorities) { struct oxr_action_set *act_set = NULL; struct oxr_action_set_attachment *act_set_attached = NULL; @@ -1877,7 +1905,7 @@ oxr_action_sync_data(struct oxr_logger *log, } oxr_action_attachment_update(log, sess, countActionSets, actionSets, act_attached, now, - subaction_paths); + subaction_paths, activePriorities); } } diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index 7c2a9c268..a32f9e3f9 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -506,7 +506,8 @@ XrResult oxr_action_sync_data(struct oxr_logger *log, struct oxr_session *sess, uint32_t countActionSets, - const XrActiveActionSet *actionSets); + const XrActiveActionSet *actionSets, + const XrActiveActionSetPrioritiesEXT *activePriorities); /*! * @public @memberof oxr_session