Monado OpenXR Runtime
oxr_objects.h
Go to the documentation of this file.
1 // Copyright 2018-2024, Collabora, Ltd.
2 // Copyright 2023, NVIDIA CORPORATION.
3 // SPDX-License-Identifier: BSL-1.0
4 /*!
5  * @file
6  * @brief The objects representing OpenXR handles, and prototypes for internal functions used in the state tracker.
7  * @author Jakob Bornecrantz <jakob@collabora.com>
8  * @author Korcan Hussein <korcan.hussein@collabora.com>
9  * @ingroup oxr_main
10  */
11 
12 #pragma once
13 
14 #include "xrt/xrt_space.h"
15 #include "xrt/xrt_limits.h"
16 #include "xrt/xrt_system.h"
17 #include "xrt/xrt_device.h"
18 #include "xrt/xrt_tracking.h"
19 #include "xrt/xrt_compositor.h"
22 #include "xrt/xrt_config_os.h"
23 #include "xrt/xrt_config_have.h"
24 
25 #include "os/os_threading.h"
26 
27 #include "util/u_index_fifo.h"
28 #include "util/u_hashset.h"
29 #include "util/u_hashmap.h"
30 #include "util/u_device.h"
31 
32 #include "oxr_extension_support.h"
33 #include "oxr_subaction.h"
34 #include "oxr_defines.h"
35 
36 #if defined(XRT_HAVE_D3D11) || defined(XRT_HAVE_D3D12)
37 #include <dxgi.h>
38 #include <d3dcommon.h>
39 #endif
40 
41 #ifdef XRT_FEATURE_RENDERDOC
42 #include "renderdoc_app.h"
43 #ifndef XRT_OS_WINDOWS
44 #include <dlfcn.h>
45 #endif // !XRT_OS_WINDOWS
46 #endif // XRT_FEATURE_RENDERDOC
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53 /*!
54  * @defgroup oxr OpenXR state tracker
55  *
56  * Client application facing code.
57  *
58  * @ingroup xrt
59  */
60 
61 /*!
62  * @brief Cast a pointer to an OpenXR handle in such a way as to avoid warnings.
63  *
64  * Avoids -Wpointer-to-int-cast by first casting to the same size int, then
65  * promoting to the 64-bit int, then casting to the handle type. That's a lot of
66  * no-ops on 64-bit, but a widening conversion on 32-bit.
67  *
68  * @ingroup oxr
69  */
70 #define XRT_CAST_PTR_TO_OXR_HANDLE(HANDLE_TYPE, PTR) ((HANDLE_TYPE)(uint64_t)(uintptr_t)(PTR))
71 
72 /*!
73  * @brief Cast an OpenXR handle to a pointer in such a way as to avoid warnings.
74  *
75  * Avoids -Wint-to-pointer-cast by first casting to a 64-bit int, then to a
76  * pointer-sized int, then to the desired pointer type. That's a lot of no-ops
77  * on 64-bit, but a narrowing (!) conversion on 32-bit.
78  *
79  * @ingroup oxr
80  */
81 #define XRT_CAST_OXR_HANDLE_TO_PTR(PTR_TYPE, HANDLE) ((PTR_TYPE)(uintptr_t)(uint64_t)(HANDLE))
82 
83 /*!
84  * @defgroup oxr_main OpenXR main code
85  *
86  * Gets called from @ref oxr_api functions and talks to devices and
87  * @ref comp using @ref xrt_iface.
88  *
89  * @ingroup oxr
90  * @{
91  */
92 
93 
94 /*
95  *
96  * Forward declare structs.
97  *
98  */
99 
100 struct xrt_instance;
101 struct oxr_logger;
102 struct oxr_extension_status;
103 struct oxr_instance;
104 struct oxr_system;
105 struct oxr_session;
106 struct oxr_event;
107 struct oxr_swapchain;
108 struct oxr_space;
109 struct oxr_action_set;
110 struct oxr_action;
111 struct oxr_debug_messenger;
112 struct oxr_handle_base;
113 struct oxr_subaction_paths;
114 struct oxr_action_attachment;
116 struct oxr_action_input;
117 struct oxr_action_output;
118 struct oxr_dpad_state;
119 struct oxr_binding;
121 struct oxr_action_set_ref;
122 struct oxr_action_ref;
123 struct oxr_hand_tracker;
125 
126 #define XRT_MAX_HANDLE_CHILDREN 256
127 #define OXR_MAX_BINDINGS_PER_ACTION 32
128 
129 struct time_state;
130 
131 /*!
132  * Function pointer type for a handle destruction function.
133  *
134  * @relates oxr_handle_base
135  */
136 typedef XrResult (*oxr_handle_destroyer)(struct oxr_logger *log, struct oxr_handle_base *hb);
137 
138 
139 
140 /*
141  *
142  * Helpers
143  *
144  */
145 
146 /*!
147  * Safely copy a xrt_pose to a XrPosef.
148  */
149 #define OXR_XRT_POSE_TO_XRPOSEF(FROM, TO) \
150  do { \
151  union { \
152  struct xrt_pose xrt; \
153  XrPosef oxr; \
154  } safe_copy = {FROM}; \
155  TO = safe_copy.oxr; \
156  } while (false)
157 
158 /*!
159  * Safely copy a xrt_fov to a XrFovf.
160  */
161 #define OXR_XRT_FOV_TO_XRFOVF(FROM, TO) \
162  do { \
163  union { \
164  struct xrt_fov xrt; \
165  XrFovf oxr; \
166  } safe_copy = {FROM}; \
167  TO = safe_copy.oxr; \
168  } while (false)
169 
170 
171 /*
172  *
173  * oxr_handle_base.c
174  *
175  */
176 
177 /*!
178  * Destroy the handle's object, as well as all child handles recursively.
179  *
180  * This should be how all handle-associated objects are destroyed.
181  *
182  * @public @memberof oxr_handle_base
183  */
184 XrResult
185 oxr_handle_destroy(struct oxr_logger *log, struct oxr_handle_base *hb);
186 
187 /*!
188  * Returns a human-readable label for a handle state.
189  *
190  * @relates oxr_handle_base
191  */
192 const char *
194 
195 /*!
196  *
197  * @name oxr_instance.c
198  * @{
199  *
200  */
201 
202 /*!
203  * To go back to a OpenXR object.
204  *
205  * @relates oxr_instance
206  */
207 static inline XrInstance
209 {
210  return XRT_CAST_PTR_TO_OXR_HANDLE(XrInstance, inst);
211 }
212 
213 /*!
214  * Creates a instance, does minimal validation of @p createInfo.
215  *
216  * @param[in] log Logger
217  * @param[in] createInfo OpenXR creation info.
218  * @param[in] extensions Parsed extension list to be enabled.
219  * @param[out] out_inst Pointer to pointer to a instance, returned instance.
220  *
221  * @public @static @memberof oxr_instance
222  */
223 XrResult
224 oxr_instance_create(struct oxr_logger *log,
225  const XrInstanceCreateInfo *createInfo,
226  const struct oxr_extension_status *extensions,
227  struct oxr_instance **out_inst);
228 
229 /*!
230  * @public @memberof oxr_instance
231  */
232 XrResult
233 oxr_instance_get_properties(struct oxr_logger *log,
234  struct oxr_instance *inst,
235  XrInstanceProperties *instanceProperties);
236 
237 #if XR_USE_TIMESPEC
238 
239 /*!
240  * @public @memberof oxr_instance
241  */
242 XrResult
243 oxr_instance_convert_time_to_timespec(struct oxr_logger *log,
244  struct oxr_instance *inst,
245  XrTime time,
246  struct timespec *timespecTime);
247 
248 /*!
249  * @public @memberof oxr_instance
250  */
251 XrResult
252 oxr_instance_convert_timespec_to_time(struct oxr_logger *log,
253  struct oxr_instance *inst,
254  const struct timespec *timespecTime,
255  XrTime *time);
256 #endif // XR_USE_TIMESPEC
257 
258 #ifdef XR_USE_PLATFORM_WIN32
259 
260 /*!
261  * @public @memberof oxr_instance
262  */
263 XrResult
264 oxr_instance_convert_time_to_win32perfcounter(struct oxr_logger *log,
265  struct oxr_instance *inst,
266  XrTime time,
267  LARGE_INTEGER *win32perfcounterTime);
268 
269 /*!
270  * @public @memberof oxr_instance
271  */
272 XrResult
273 oxr_instance_convert_win32perfcounter_to_time(struct oxr_logger *log,
274  struct oxr_instance *inst,
275  const LARGE_INTEGER *win32perfcounterTime,
276  XrTime *time);
277 
278 #endif // XR_USE_PLATFORM_WIN32
279 
280 /*!
281  * @}
282  */
283 
284 /*!
285  *
286  * @name oxr_path.c
287  * @{
288  *
289  */
290 
291 /*!
292  * Initialize the path system.
293  * @private @memberof oxr_instance
294  */
295 XrResult
296 oxr_path_init(struct oxr_logger *log, struct oxr_instance *inst);
297 
298 /*!
299  * @public @memberof oxr_instance
300  */
301 bool
302 oxr_path_is_valid(struct oxr_logger *log, struct oxr_instance *inst, XrPath path);
303 
304 /*!
305  * @public @memberof oxr_instance
306  */
307 void *
308 oxr_path_get_attached(struct oxr_logger *log, struct oxr_instance *inst, XrPath path);
309 
310 /*!
311  * Get the path for the given string if it exists, or create it if it does not.
312  *
313  * @public @memberof oxr_instance
314  */
315 XrResult
317  struct oxr_logger *log, struct oxr_instance *inst, const char *str, size_t length, XrPath *out_path);
318 
319 /*!
320  * Only get the path for the given string if it exists.
321  *
322  * @public @memberof oxr_instance
323  */
324 XrResult
325 oxr_path_only_get(struct oxr_logger *log, struct oxr_instance *inst, const char *str, size_t length, XrPath *out_path);
326 
327 /*!
328  * Get a pointer and length of the internal string.
329  *
330  * The pointer has the same life time as the instance. The length is the number
331  * of valid characters, not including the null termination character (but an
332  * extra null byte is always reserved at the end so can strings can be given
333  * to functions expecting null terminated strings).
334  *
335  * @public @memberof oxr_instance
336  */
337 XrResult
339  struct oxr_logger *log, const struct oxr_instance *inst, XrPath path, const char **out_str, size_t *out_length);
340 
341 /*!
342  * Destroy the path system and all paths that the instance has created.
343  *
344  * @private @memberof oxr_instance
345  */
346 void
347 oxr_path_destroy(struct oxr_logger *log, struct oxr_instance *inst);
348 
349 /*!
350  * @}
351  */
352 
353 /*!
354  * To go back to a OpenXR object.
355  *
356  * @relates oxr_action_set
357  */
358 static inline XrActionSet
360 {
361  return XRT_CAST_PTR_TO_OXR_HANDLE(XrActionSet, act_set);
362 }
363 
364 /*!
365  * To go back to a OpenXR object.
366  *
367  * @relates oxr_hand_tracker
368  */
369 static inline XrHandTrackerEXT
371 {
372  return XRT_CAST_PTR_TO_OXR_HANDLE(XrHandTrackerEXT, hand_tracker);
373 }
374 
375 /*!
376  * To go back to a OpenXR object.
377  *
378  * @relates oxr_action
379  */
380 static inline XrAction
382 {
383  return XRT_CAST_PTR_TO_OXR_HANDLE(XrAction, act);
384 }
385 
386 #ifdef OXR_HAVE_HTC_facial_tracking
387 /*!
388  * To go back to a OpenXR object.
389  *
390  * @relates oxr_facial_tracker_htc
391  */
392 static inline XrFacialTrackerHTC
393 oxr_facial_tracker_htc_to_openxr(struct oxr_facial_tracker_htc *face_tracker_htc)
394 {
395  return XRT_CAST_PTR_TO_OXR_HANDLE(XrFacialTrackerHTC, face_tracker_htc);
396 }
397 #endif
398 
399 /*!
400  *
401  * @name oxr_input.c
402  * @{
403  *
404  */
405 
406 /*!
407  * Helper function to classify subaction_paths.
408  *
409  * Sets all members of @p subaction_paths ( @ref oxr_subaction_paths ) as
410  * appropriate based on the subaction paths found in the list.
411  *
412  * If no paths are provided, @p subaction_paths->any will be true.
413  *
414  * @return false if an invalid subaction path is provided.
415  *
416  * @public @memberof oxr_instance
417  * @see oxr_subaction_paths
418  */
419 bool
421  const struct oxr_instance *inst,
422  uint32_t subaction_path_count,
423  const XrPath *subaction_paths,
424  struct oxr_subaction_paths *subaction_paths_out);
425 
426 /*!
427  * Find the pose input for the set of subaction_paths
428  *
429  * @public @memberof oxr_session
430  */
431 XrResult
433  uint32_t act_key,
434  const struct oxr_subaction_paths *subaction_paths_ptr,
435  struct oxr_action_input **out_input);
436 
437 /*!
438  * @public @memberof oxr_instance
439  */
440 XrResult
441 oxr_action_set_create(struct oxr_logger *log,
442  struct oxr_instance *inst,
443  const XrActionSetCreateInfo *createInfo,
444  struct oxr_action_set **out_act_set);
445 
446 /*!
447  * @public @memberof oxr_action
448  */
449 XrResult
450 oxr_action_create(struct oxr_logger *log,
451  struct oxr_action_set *act_set,
452  const XrActionCreateInfo *createInfo,
453  struct oxr_action **out_act);
454 
455 /*!
456  * @public @memberof oxr_session
457  * @see oxr_action_set
458  */
459 XrResult
461  struct oxr_session *sess,
462  const XrSessionActionSetsAttachInfo *bindInfo);
463 
464 
465 XrResult
466 oxr_session_update_action_bindings(struct oxr_logger *log, struct oxr_session *sess);
467 
468 /*!
469  * @public @memberof oxr_session
470  */
471 XrResult
472 oxr_action_sync_data(struct oxr_logger *log,
473  struct oxr_session *sess,
474  uint32_t countActionSets,
475  const XrActiveActionSet *actionSets);
476 
477 /*!
478  * @public @memberof oxr_session
479  */
480 XrResult
481 oxr_action_enumerate_bound_sources(struct oxr_logger *log,
482  struct oxr_session *sess,
483  uint32_t act_key,
484  uint32_t sourceCapacityInput,
485  uint32_t *sourceCountOutput,
486  XrPath *sources);
487 
488 /*!
489  * @public @memberof oxr_session
490  */
491 XrResult
492 oxr_action_get_boolean(struct oxr_logger *log,
493  struct oxr_session *sess,
494  uint32_t act_key,
495  struct oxr_subaction_paths subaction_paths,
496  XrActionStateBoolean *data);
497 
498 /*!
499  * @public @memberof oxr_session
500  */
501 XrResult
502 oxr_action_get_vector1f(struct oxr_logger *log,
503  struct oxr_session *sess,
504  uint32_t act_key,
505  struct oxr_subaction_paths subaction_paths,
506  XrActionStateFloat *data);
507 
508 /*!
509  * @public @memberof oxr_session
510  */
511 XrResult
512 oxr_action_get_vector2f(struct oxr_logger *log,
513  struct oxr_session *sess,
514  uint32_t act_key,
515  struct oxr_subaction_paths subaction_paths,
516  XrActionStateVector2f *data);
517 /*!
518  * @public @memberof oxr_session
519  */
520 XrResult
521 oxr_action_get_pose(struct oxr_logger *log,
522  struct oxr_session *sess,
523  uint32_t act_key,
524  struct oxr_subaction_paths subaction_paths,
525  XrActionStatePose *data);
526 /*!
527  * @public @memberof oxr_session
528  */
529 XrResult
530 oxr_action_apply_haptic_feedback(struct oxr_logger *log,
531  struct oxr_session *sess,
532  uint32_t act_key,
533  struct oxr_subaction_paths subaction_paths,
534  const XrHapticBaseHeader *hapticEvent);
535 /*!
536  * @public @memberof oxr_session
537  */
538 XrResult
539 oxr_action_stop_haptic_feedback(struct oxr_logger *log,
540  struct oxr_session *sess,
541  uint32_t act_key,
542  struct oxr_subaction_paths subaction_paths);
543 
544 /*!
545  * @public @memberof oxr_instance
546  */
547 XrResult
548 oxr_hand_tracker_create(struct oxr_logger *log,
549  struct oxr_session *sess,
550  const XrHandTrackerCreateInfoEXT *createInfo,
551  struct oxr_hand_tracker **out_hand_tracker);
552 
553 /*!
554  * @}
555  */
556 
557 /*!
558  *
559  * @name oxr_binding.c
560  * @{
561  *
562  */
563 
564 /*!
565  * Find the best matching profile for the given @ref xrt_device.
566  *
567  * @param log Logger.
568  * @param sess Session.
569  * @param xdev Can be null.
570  * @param[out] out_p Returned interaction profile.
571  *
572  * @public @memberof oxr_session
573  */
574 void
576  struct oxr_session *sess,
577  struct xrt_device *xdev,
578  struct oxr_interaction_profile **out_p);
579 
580 void
581 oxr_get_profile_for_device_name(struct oxr_logger *log,
582  struct oxr_session *sess,
583  enum xrt_device_name name,
584  struct oxr_interaction_profile **out_p);
585 
587 oxr_clone_profile(const struct oxr_interaction_profile *src_profile);
588 
589 /*!
590  * Free all memory allocated by the binding system.
591  *
592  * @public @memberof oxr_instance
593  */
594 void
595 oxr_binding_destroy_all(struct oxr_logger *log, struct oxr_instance *inst);
596 
597 /*!
598  * Free all memory allocated by the binding system.
599  *
600  * @public @memberof oxr_instance
601  */
602 void
603 oxr_session_binding_destroy_all(struct oxr_logger *log, struct oxr_session *sess);
604 
605 /*!
606  * Find all bindings that is the given action key is bound to.
607  * @public @memberof oxr_interaction_profile
608  */
609 void
611  struct oxr_interaction_profile *p,
612  uint32_t key,
613  size_t max_bounding_count,
614  struct oxr_binding **bindings,
615  size_t *out_binding_count);
616 
617 /*!
618  * @public @memberof oxr_instance
619  */
620 XrResult
621 oxr_action_suggest_interaction_profile_bindings(struct oxr_logger *log,
622  struct oxr_instance *inst,
623  const XrInteractionProfileSuggestedBinding *suggestedBindings,
624  struct oxr_dpad_state *state);
625 
626 /*!
627  * @public @memberof oxr_instance
628  */
629 XrResult
631  struct oxr_session *sess,
632  XrPath topLevelUserPath,
633  XrInteractionProfileState *interactionProfile);
634 
635 /*!
636  * @public @memberof oxr_session
637  */
638 XrResult
639 oxr_action_get_input_source_localized_name(struct oxr_logger *log,
640  struct oxr_session *sess,
641  const XrInputSourceLocalizedNameGetInfo *getInfo,
642  uint32_t bufferCapacityInput,
643  uint32_t *bufferCountOutput,
644  char *buffer);
645 
646 /*!
647  * @}
648  */
649 
650 
651 /*!
652  *
653  * @name oxr_dpad.c
654  * @{
655  *
656  */
657 
658 /*!
659  * Initialises a dpad state, has to be zero init before a call to this function.
660  *
661  * @public @memberof oxr_dpad_state_get
662  */
663 bool
664 oxr_dpad_state_init(struct oxr_dpad_state *state);
665 
666 /*!
667  * Look for a entry in the state for the given action set key,
668  * returns NULL if no entry has been made for that action set.
669  *
670  * @public @memberof oxr_dpad_state_get
671  */
672 struct oxr_dpad_entry *
673 oxr_dpad_state_get(struct oxr_dpad_state *state, uint64_t key);
674 
675 /*!
676  * Look for a entry in the state for the given action set key,
677  * allocates a new entry if none was found.
678  *
679  * @public @memberof oxr_dpad_state_get
680  */
681 struct oxr_dpad_entry *
682 oxr_dpad_state_get_or_add(struct oxr_dpad_state *state, uint64_t key);
683 
684 /*!
685  * Frees all state and entries attached to this dpad state.
686  *
687  * @public @memberof oxr_dpad_state_get
688  */
689 void
690 oxr_dpad_state_deinit(struct oxr_dpad_state *state);
691 
692 /*!
693  * Clones all oxr_dpad_state
694  * @param dst_dpad_state destination of cloning
695  * @param src_dpad_state source of cloning
696  * @public @memberof oxr_dpad_state_clone
697  */
698 bool
699 oxr_dpad_state_clone(struct oxr_dpad_state *dst_dpad_state, const struct oxr_dpad_state *src_dpad_state);
700 
701 
702 /*!
703  * @}
704  */
705 
706 
707 /*!
708  *
709  * @name oxr_session.c
710  * @{
711  *
712  */
713 
714 /*!
715  * To go back to a OpenXR object.
716  *
717  * @relates oxr_session
718  */
719 static inline XrSession
721 {
722  return XRT_CAST_PTR_TO_OXR_HANDLE(XrSession, sess);
723 }
724 
725 XrResult
726 oxr_session_create(struct oxr_logger *log,
727  struct oxr_system *sys,
728  const XrSessionCreateInfo *createInfo,
729  struct oxr_session **out_session);
730 
731 XrResult
732 oxr_session_enumerate_formats(struct oxr_logger *log,
733  struct oxr_session *sess,
734  uint32_t formatCapacityInput,
735  uint32_t *formatCountOutput,
736  int64_t *formats);
737 
738 /*!
739  * Change the state of the session, queues a event.
740  */
741 void
742 oxr_session_change_state(struct oxr_logger *log, struct oxr_session *sess, XrSessionState state, XrTime time);
743 
744 XrResult
745 oxr_session_begin(struct oxr_logger *log, struct oxr_session *sess, const XrSessionBeginInfo *beginInfo);
746 
747 XrResult
748 oxr_session_end(struct oxr_logger *log, struct oxr_session *sess);
749 
750 XrResult
751 oxr_session_request_exit(struct oxr_logger *log, struct oxr_session *sess);
752 
753 XRT_CHECK_RESULT XrResult
754 oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess);
755 
756 XrResult
757 oxr_session_locate_views(struct oxr_logger *log,
758  struct oxr_session *sess,
759  const XrViewLocateInfo *viewLocateInfo,
760  XrViewState *viewState,
761  uint32_t viewCapacityInput,
762  uint32_t *viewCountOutput,
763  XrView *views);
764 
765 XrResult
766 oxr_session_frame_wait(struct oxr_logger *log, struct oxr_session *sess, XrFrameState *frameState);
767 
768 XrResult
769 oxr_session_frame_begin(struct oxr_logger *log, struct oxr_session *sess);
770 
771 XrResult
772 oxr_session_frame_end(struct oxr_logger *log, struct oxr_session *sess, const XrFrameEndInfo *frameEndInfo);
773 
774 XrResult
775 oxr_session_hand_joints(struct oxr_logger *log,
776  struct oxr_hand_tracker *hand_tracker,
777  const XrHandJointsLocateInfoEXT *locateInfo,
778  XrHandJointLocationsEXT *locations);
779 
780 XrResult
781 oxr_session_apply_force_feedback(struct oxr_logger *log,
782  struct oxr_hand_tracker *hand_tracker,
783  const XrForceFeedbackCurlApplyLocationsMNDX *locations);
784 
785 #ifdef OXR_HAVE_KHR_android_thread_settings
786 XrResult
787 oxr_session_android_thread_settings(struct oxr_logger *log,
788  struct oxr_session *sess,
789  XrAndroidThreadTypeKHR threadType,
790  uint32_t threadId);
791 #endif // OXR_HAVE_KHR_android_thread_settings
792 
793 #ifdef OXR_HAVE_KHR_visibility_mask
794 XrResult
795 oxr_session_get_visibility_mask(struct oxr_logger *log,
796  struct oxr_session *session,
797  XrVisibilityMaskTypeKHR visibilityMaskType,
798  uint32_t viewIndex,
799  XrVisibilityMaskKHR *visibilityMask);
800 #endif // OXR_HAVE_KHR_visibility_mask
801 
802 #ifdef OXR_HAVE_EXT_performance_settings
803 XrResult
804 oxr_session_set_perf_level(struct oxr_logger *log,
805  struct oxr_session *sess,
806  XrPerfSettingsDomainEXT domain,
807  XrPerfSettingsLevelEXT level);
808 #endif // OXR_HAVE_EXT_performance_settings
809 
810 /*
811  *
812  * oxr_space.c
813  *
814  */
815 
816 /*!
817  * To go back to a OpenXR object.
818  */
819 static inline XrSpace
821 {
822  return XRT_CAST_PTR_TO_OXR_HANDLE(XrSpace, spc);
823 }
824 
825 XrResult
826 oxr_space_action_create(struct oxr_logger *log,
827  struct oxr_session *sess,
828  uint32_t key,
829  const XrActionSpaceCreateInfo *createInfo,
830  struct oxr_space **out_space);
831 
832 XrResult
833 oxr_space_reference_create(struct oxr_logger *log,
834  struct oxr_session *sess,
835  const XrReferenceSpaceCreateInfo *createInfo,
836  struct oxr_space **out_space);
837 
838 XrResult
840  struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location);
841 
842 /*!
843  * Locate the @ref xrt_device in the given base space, useful for implementing
844  * hand tracking location look ups and the like.
845  *
846  * @param log Logging struct.
847  * @param xdev Device to locate in the base space.
848  * @param baseSpc Base space where the device is to be located.
849  * @param[in] time Time in OpenXR domain.
850  * @param[out] out_relation Returns T_base_xdev, aka xdev in base space.
851  *
852  * @return Any errors, XR_SUCCESS, pose might not be valid on XR_SUCCESS.
853  */
854 XRT_CHECK_RESULT XrResult
856  struct xrt_device *xdev,
857  struct oxr_space *baseSpc,
858  XrTime time,
859  struct xrt_space_relation *out_relation);
860 
861 
862 /*
863  *
864  * oxr_swapchain.c
865  *
866  */
867 
868 /*!
869  * To go back to a OpenXR object.
870  */
871 static inline XrSwapchain
873 {
874  return XRT_CAST_PTR_TO_OXR_HANDLE(XrSwapchain, sc);
875 }
876 
877 
878 /*
879  *
880  * oxr_messenger.c
881  *
882  */
883 
884 /*!
885  * To go back to a OpenXR object.
886  */
887 static inline XrDebugUtilsMessengerEXT
889 {
890  return XRT_CAST_PTR_TO_OXR_HANDLE(XrDebugUtilsMessengerEXT, mssngr);
891 }
892 
893 XrResult
895  struct oxr_instance *inst,
896  const XrDebugUtilsMessengerCreateInfoEXT *,
897  struct oxr_debug_messenger **out_mssngr);
898 XrResult
899 oxr_destroy_messenger(struct oxr_logger *log, struct oxr_debug_messenger *mssngr);
900 
901 
902 /*
903  *
904  * oxr_system.c
905  *
906  */
907 
908 XrResult
909 oxr_system_select(struct oxr_logger *log,
910  struct oxr_system **systems,
911  uint32_t system_count,
912  XrFormFactor form_factor,
913  struct oxr_system **out_selected);
914 
915 XrResult
916 oxr_system_fill_in(struct oxr_logger *log,
917  struct oxr_instance *inst,
918  XrSystemId systemId,
919  uint32_t view_count,
920  struct oxr_system *sys);
921 
922 XrResult
923 oxr_system_verify_id(struct oxr_logger *log, const struct oxr_instance *inst, XrSystemId systemId);
924 
925 XrResult
926 oxr_system_get_by_id(struct oxr_logger *log,
927  struct oxr_instance *inst,
928  XrSystemId systemId,
929  struct oxr_system **system);
930 
931 XrResult
932 oxr_system_get_properties(struct oxr_logger *log, struct oxr_system *sys, XrSystemProperties *properties);
933 
934 XrResult
935 oxr_system_enumerate_view_confs(struct oxr_logger *log,
936  struct oxr_system *sys,
937  uint32_t viewConfigurationTypeCapacityInput,
938  uint32_t *viewConfigurationTypeCountOutput,
939  XrViewConfigurationType *viewConfigurationTypes);
940 
941 XrResult
943  struct oxr_system *sys,
944  XrViewConfigurationType viewConfigurationType,
945  uint32_t environmentBlendModeCapacityInput,
946  uint32_t *environmentBlendModeCountOutput,
947  XrEnvironmentBlendMode *environmentBlendModes);
948 
949 XrResult
950 oxr_system_get_view_conf_properties(struct oxr_logger *log,
951  struct oxr_system *sys,
952  XrViewConfigurationType viewConfigurationType,
953  XrViewConfigurationProperties *configurationProperties);
954 
955 XrResult
956 oxr_system_enumerate_view_conf_views(struct oxr_logger *log,
957  struct oxr_system *sys,
958  XrViewConfigurationType viewConfigurationType,
959  uint32_t viewCapacityInput,
960  uint32_t *viewCountOutput,
961  XrViewConfigurationView *views);
962 
963 bool
964 oxr_system_get_hand_tracking_support(struct oxr_logger *log, struct oxr_instance *inst);
965 
966 bool
967 oxr_system_get_eye_gaze_support(struct oxr_logger *log, struct oxr_instance *inst);
968 
969 bool
970 oxr_system_get_force_feedback_support(struct oxr_logger *log, struct oxr_instance *inst);
971 
972 void
973 oxr_system_get_face_tracking_htc_support(struct oxr_logger *log,
974  struct oxr_instance *inst,
975  bool *supports_eye,
976  bool *supports_lip);
977 
978 
979 /*
980  *
981  * oxr_event.cpp
982  *
983  */
984 
985 XrResult
986 oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
987  struct oxr_session *sess,
988  XrSessionState state,
989  XrTime time);
990 
991 XrResult
992 oxr_event_push_XrEventDataInteractionProfileChanged(struct oxr_logger *log, struct oxr_session *sess);
993 
994 XrResult
995 oxr_event_push_XrEventDataReferenceSpaceChangePending(struct oxr_logger *log,
996  struct oxr_session *sess,
997  XrReferenceSpaceType referenceSpaceType,
998  XrTime changeTime,
999  XrBool32 poseValid,
1000  const XrPosef *poseInPreviousSpace);
1001 
1002 #ifdef OXR_HAVE_FB_display_refresh_rate
1003 XrResult
1004 oxr_event_push_XrEventDataDisplayRefreshRateChangedFB(struct oxr_logger *log,
1005  struct oxr_session *sess,
1006  float fromDisplayRefreshRate,
1007  float toDisplayRefreshRate);
1008 #endif // OXR_HAVE_FB_display_refresh_rate
1009 
1010 #ifdef OXR_HAVE_EXTX_overlay
1011 XrResult
1012 oxr_event_push_XrEventDataMainSessionVisibilityChangedEXTX(struct oxr_logger *log,
1013  struct oxr_session *sess,
1014  bool visible);
1015 #endif // OXR_HAVE_EXTX_overlay
1016 
1017 #ifdef OXR_HAVE_EXT_performance_settings
1018 XrResult
1019 oxr_event_push_XrEventDataPerfSettingsEXTX(struct oxr_logger *log,
1020  struct oxr_session *sess,
1021  enum xrt_perf_domain domain,
1022  enum xrt_perf_sub_domain subDomain,
1023  enum xrt_perf_notify_level fromLevel,
1024  enum xrt_perf_notify_level toLevel);
1025 #endif // OXR_HAVE_EXT_performance_settings
1026 /*!
1027  * This clears all pending events refers to the given session.
1028  */
1029 XrResult
1030 oxr_event_remove_session_events(struct oxr_logger *log, struct oxr_session *sess);
1031 
1032 /*!
1033  * Will return one event if available, also drain the sessions event queues.
1034  */
1035 XrResult
1036 oxr_poll_event(struct oxr_logger *log, struct oxr_instance *inst, XrEventDataBuffer *eventData);
1037 
1038 
1039 /*
1040  *
1041  * oxr_xdev.c
1042  *
1043  */
1044 
1045 void
1046 oxr_xdev_destroy(struct xrt_device **xdev_ptr);
1047 
1048 void
1049 oxr_xdev_update(struct xrt_device *xdev);
1050 
1051 /*!
1052  * Return true if it finds an input of that name on this device.
1053  */
1054 bool
1055 oxr_xdev_find_input(struct xrt_device *xdev, enum xrt_input_name name, struct xrt_input **out_input);
1056 
1057 /*!
1058  * Return true if it finds an output of that name on this device.
1059  */
1060 bool
1061 oxr_xdev_find_output(struct xrt_device *xdev, enum xrt_output_name name, struct xrt_output **out_output);
1062 
1063 /*!
1064  * Returns the hand tracking value of the named input from the device.
1065  * Does NOT apply tracking origin offset to each joint.
1066  */
1067 void
1069  struct oxr_instance *inst,
1070  struct xrt_device *xdev,
1071  enum xrt_input_name name,
1072  XrTime at_time,
1073  struct xrt_hand_joint_set *out_value);
1074 
1075 
1076 /*
1077  *
1078  * OpenGL, located in various files.
1079  *
1080  */
1081 
1082 #ifdef XR_USE_GRAPHICS_API_OPENGL
1083 #ifdef XR_USE_PLATFORM_XLIB
1084 
1085 XrResult
1086 oxr_session_populate_gl_xlib(struct oxr_logger *log,
1087  struct oxr_system *sys,
1088  XrGraphicsBindingOpenGLXlibKHR const *next,
1089  struct oxr_session *sess);
1090 #endif // XR_USE_PLATFORM_XLIB
1091 
1092 #ifdef XR_USE_PLATFORM_WIN32
1093 XrResult
1094 oxr_session_populate_gl_win32(struct oxr_logger *log,
1095  struct oxr_system *sys,
1096  XrGraphicsBindingOpenGLWin32KHR const *next,
1097  struct oxr_session *sess);
1098 #endif // XR_USE_PLATFORM_WIN32
1099 #endif // XR_USE_GRAPHICS_API_OPENGL
1100 
1101 #if defined(XR_USE_GRAPHICS_API_OPENGL) || defined(XR_USE_GRAPHICS_API_OPENGL_ES)
1102 XrResult
1103 oxr_swapchain_gl_create(struct oxr_logger * /*log*/,
1104  struct oxr_session *sess,
1105  const XrSwapchainCreateInfo * /*createInfo*/,
1106  struct oxr_swapchain **out_swapchain);
1107 
1108 #endif // XR_USE_GRAPHICS_API_OPENGL || XR_USE_GRAPHICS_API_OPENGL_ES
1109 
1110 #if defined(XR_USE_GRAPHICS_API_OPENGL_ES)
1111 #if defined(XR_USE_PLATFORM_ANDROID)
1112 XrResult
1113 oxr_session_populate_gles_android(struct oxr_logger *log,
1114  struct oxr_system *sys,
1115  XrGraphicsBindingOpenGLESAndroidKHR const *next,
1116  struct oxr_session *sess);
1117 #endif // XR_USE_PLATFORM_ANDROID
1118 #endif // XR_USE_GRAPHICS_API_OPENGL_ES
1119 
1120 
1121 /*
1122  *
1123  * Vulkan, located in various files.
1124  *
1125  */
1126 
1127 #ifdef XR_USE_GRAPHICS_API_VULKAN
1128 
1129 XrResult
1130 oxr_vk_get_instance_exts(struct oxr_logger *log,
1131  struct oxr_system *sys,
1132  uint32_t namesCapacityInput,
1133  uint32_t *namesCountOutput,
1134  char *namesString);
1135 
1136 XrResult
1137 oxr_vk_get_device_exts(struct oxr_logger *log,
1138  struct oxr_system *sys,
1139  uint32_t namesCapacityInput,
1140  uint32_t *namesCountOutput,
1141  char *namesString);
1142 
1143 XrResult
1144 oxr_vk_get_requirements(struct oxr_logger *log,
1145  struct oxr_system *sys,
1146  XrGraphicsRequirementsVulkanKHR *graphicsRequirements);
1147 
1148 XrResult
1150  struct oxr_system *sys,
1151  const XrVulkanInstanceCreateInfoKHR *createInfo,
1152  VkInstance *vulkanInstance,
1153  VkResult *vulkanResult);
1154 
1155 XrResult
1157  struct oxr_system *sys,
1158  const XrVulkanDeviceCreateInfoKHR *createInfo,
1159  VkDevice *vulkanDevice,
1160  VkResult *vulkanResult);
1161 
1162 XrResult
1163 oxr_vk_get_physical_device(struct oxr_logger *log,
1164  struct oxr_instance *inst,
1165  struct oxr_system *sys,
1166  VkInstance vkInstance,
1167  PFN_vkGetInstanceProcAddr getProc,
1168  VkPhysicalDevice *vkPhysicalDevice);
1169 
1170 XrResult
1171 oxr_session_populate_vk(struct oxr_logger *log,
1172  struct oxr_system *sys,
1173  XrGraphicsBindingVulkanKHR const *next,
1174  struct oxr_session *sess);
1175 
1176 XrResult
1177 oxr_swapchain_vk_create(struct oxr_logger * /*log*/,
1178  struct oxr_session *sess,
1179  const XrSwapchainCreateInfo * /*createInfo*/,
1180  struct oxr_swapchain **out_swapchain);
1181 
1182 #endif
1183 
1184 
1185 /*
1186  *
1187  * EGL, located in various files.
1188  *
1189  */
1190 
1191 #ifdef XR_USE_PLATFORM_EGL
1192 
1193 XrResult
1194 oxr_session_populate_egl(struct oxr_logger *log,
1195  struct oxr_system *sys,
1196  XrGraphicsBindingEGLMNDX const *next,
1197  struct oxr_session *sess);
1198 
1199 #endif
1200 
1201 /*
1202  *
1203  * D3D version independent routines, located in oxr_d3d.cpp
1204  *
1205  */
1206 
1207 #if defined(XRT_HAVE_D3D11) || defined(XRT_HAVE_D3D12) || defined(XRT_DOXYGEN)
1208 /// Common GetRequirements call for D3D11 and D3D12
1209 XrResult
1211  struct oxr_system *sys,
1212  LUID *adapter_luid,
1213  D3D_FEATURE_LEVEL *min_feature_level);
1214 
1215 /// Verify the provided LUID matches the expected one in @p sys
1216 XrResult
1217 oxr_d3d_check_luid(struct oxr_logger *log, struct oxr_system *sys, LUID *adapter_luid);
1218 #endif
1219 
1220 /*
1221  *
1222  * D3D11, located in various files.
1223  *
1224  */
1225 
1226 #ifdef XR_USE_GRAPHICS_API_D3D11
1227 
1228 XrResult
1229 oxr_d3d11_get_requirements(struct oxr_logger *log,
1230  struct oxr_system *sys,
1231  XrGraphicsRequirementsD3D11KHR *graphicsRequirements);
1232 
1233 /**
1234  * @brief Check to ensure the device provided at session create matches the LUID we returned earlier.
1235  *
1236  * @return XR_SUCCESS if the device matches the LUID
1237  */
1238 XrResult
1239 oxr_d3d11_check_device(struct oxr_logger *log, struct oxr_system *sys, ID3D11Device *device);
1240 
1241 
1242 XrResult
1243 oxr_session_populate_d3d11(struct oxr_logger *log,
1244  struct oxr_system *sys,
1245  XrGraphicsBindingD3D11KHR const *next,
1246  struct oxr_session *sess);
1247 
1248 XrResult
1249 oxr_swapchain_d3d11_create(struct oxr_logger *,
1250  struct oxr_session *sess,
1251  const XrSwapchainCreateInfo *,
1252  struct oxr_swapchain **out_swapchain);
1253 
1254 #endif
1255 
1256 /*
1257  *
1258  * D3D12, located in various files.
1259  *
1260  */
1261 
1262 #ifdef XR_USE_GRAPHICS_API_D3D12
1263 
1264 XrResult
1265 oxr_d3d12_get_requirements(struct oxr_logger *log,
1266  struct oxr_system *sys,
1267  XrGraphicsRequirementsD3D12KHR *graphicsRequirements);
1268 
1269 /**
1270  * @brief Check to ensure the device provided at session create matches the LUID we returned earlier.
1271  *
1272  * @return XR_SUCCESS if the device matches the LUID
1273  */
1274 XrResult
1275 oxr_d3d12_check_device(struct oxr_logger *log, struct oxr_system *sys, ID3D12Device *device);
1276 
1277 
1278 XrResult
1279 oxr_session_populate_d3d12(struct oxr_logger *log,
1280  struct oxr_system *sys,
1281  XrGraphicsBindingD3D12KHR const *next,
1282  struct oxr_session *sess);
1283 
1284 XrResult
1285 oxr_swapchain_d3d12_create(struct oxr_logger *,
1286  struct oxr_session *sess,
1287  const XrSwapchainCreateInfo *,
1288  struct oxr_swapchain **out_swapchain);
1289 
1290 #endif
1291 
1292 /*
1293  *
1294  * Structs
1295  *
1296  */
1297 
1298 
1299 /*!
1300  * Used to hold diverse child handles and ensure orderly destruction.
1301  *
1302  * Each object referenced by an OpenXR handle should have one of these as its
1303  * first element, thus "extending" this class.
1304  */
1306 {
1307  //! Magic (per-handle-type) value for debugging.
1308  uint64_t debug;
1309 
1310  /*!
1311  * Pointer to this object's parent handle holder, if any.
1312  */
1314 
1315  /*!
1316  * Array of children, if any.
1317  */
1318  struct oxr_handle_base *children[XRT_MAX_HANDLE_CHILDREN];
1319 
1320  /*!
1321  * Current handle state.
1322  */
1323  enum oxr_handle_state state;
1324 
1325  /*!
1326  * Destroy the object this handle refers to.
1327  */
1329 };
1330 
1331 /*!
1332  * Single or multiple devices grouped together to form a system that sessions
1333  * can be created from. Might need to open devices to get all
1334  * properties from it, but shouldn't.
1335  *
1336  * Not strictly an object, but an atom.
1337  *
1338  * Valid only within a XrInstance (@ref oxr_instance)
1339  *
1340  * @obj{XrSystemId}
1341  */
1343 {
1344  struct oxr_instance *inst;
1345 
1346  //! The @ref xrt_iface level system.
1347  struct xrt_system *xsys;
1348 
1349  //! System devices used in all session types.
1351 
1352  //! Space overseer used in all session types.
1354 
1355  //! System compositor, used to create session compositors.
1357 
1358  XrSystemId systemId;
1359 
1360  //! Have the client application called the gfx api requirements func?
1362 
1363  XrFormFactor form_factor;
1364  XrViewConfigurationType view_config_type;
1365  XrViewConfigurationView views[2];
1366  uint32_t blend_mode_count;
1367  XrEnvironmentBlendMode blend_modes[3];
1368 
1369  XrReferenceSpaceType reference_spaces[5];
1370  uint32_t reference_space_count;
1371 
1372  //! Cache of the last known system roles, see @ref xrt_system_roles::generation_id
1374  struct os_mutex sync_actions_mutex;
1375 
1376  struct xrt_visibility_mask *visibility_mask[2];
1377 
1378 #ifdef XR_USE_GRAPHICS_API_VULKAN
1379  //! The instance/device we create when vulkan_enable2 is used
1381  //! The device returned with the last xrGetVulkanGraphicsDeviceKHR or xrGetVulkanGraphicsDevice2KHR call.
1382  //! XR_NULL_HANDLE if neither has been called.
1384 
1385  struct
1386  {
1387  // No better place to keep this state.
1388  bool external_fence_fd_enabled;
1389  bool external_semaphore_fd_enabled;
1390  bool timeline_semaphore_enabled;
1391  bool debug_utils_enabled;
1392  } vk;
1393 
1394 #endif
1395 
1396 #if defined(XR_USE_GRAPHICS_API_D3D11) || defined(XR_USE_GRAPHICS_API_D3D12)
1397  LUID suggested_d3d_luid;
1398  bool suggested_d3d_luid_valid;
1399 #endif
1400 };
1401 
1402 
1403 /*
1404  * Device roles helpers.
1405  */
1406 
1407 // static roles
1408 // clang-format off
1409 static inline struct xrt_device *get_role_head(struct oxr_system *sys) {return sys->xsysd->static_roles.head; }
1410 static inline struct xrt_device *get_role_eyes(struct oxr_system *sys) {return sys->xsysd->static_roles.eyes; }
1411 static inline struct xrt_device *get_role_face(struct oxr_system* sys) { return sys->xsysd->static_roles.face; }
1412 static inline struct xrt_device *get_role_hand_tracking_left(struct oxr_system* sys) { return sys->xsysd->static_roles.hand_tracking.left; }
1413 static inline struct xrt_device *get_role_hand_tracking_right(struct oxr_system* sys) { return sys->xsysd->static_roles.hand_tracking.right; }
1414 // clang-format on
1415 
1416 // dynamic roles
1417 #define MAKE_GET_DYN_ROLES_FN(ROLE) \
1418  static inline struct xrt_device *get_role_##ROLE(struct oxr_system *sys) \
1419  { \
1420  const bool is_locked = 0 == os_mutex_trylock(&sys->sync_actions_mutex); \
1421  const int32_t xdev_idx = sys->dynamic_roles_cache.ROLE; \
1422  if (is_locked) { \
1423  os_mutex_unlock(&sys->sync_actions_mutex); \
1424  } \
1425  if (xdev_idx < 0 || xdev_idx >= (int32_t)ARRAY_SIZE(sys->xsysd->xdevs)) \
1426  return NULL; \
1427  return sys->xsysd->xdevs[xdev_idx]; \
1428  }
1429 MAKE_GET_DYN_ROLES_FN(left)
1430 MAKE_GET_DYN_ROLES_FN(right)
1431 MAKE_GET_DYN_ROLES_FN(gamepad)
1432 #undef MAKE_GET_DYN_ROLES_FN
1433 
1434 #define GET_XDEV_BY_ROLE(SYS, ROLE) (get_role_##ROLE((SYS)))
1435 
1436 
1437 static inline enum xrt_device_name
1438 get_role_profile_head(struct oxr_system *sys)
1439 {
1440  return XRT_DEVICE_INVALID;
1441 }
1442 static inline enum xrt_device_name
1443 get_role_profile_eyes(struct oxr_system *sys)
1444 {
1445  return XRT_DEVICE_INVALID;
1446 }
1447 static inline enum xrt_device_name
1448 get_role_profile_face(struct oxr_system *sys)
1449 {
1450  return XRT_DEVICE_INVALID;
1451 }
1452 static inline enum xrt_device_name
1453 get_role_profile_hand_tracking_left(struct oxr_system *sys)
1454 {
1455  return XRT_DEVICE_INVALID;
1456 }
1457 static inline enum xrt_device_name
1458 get_role_profile_hand_tracking_right(struct oxr_system *sys)
1459 {
1460  return XRT_DEVICE_INVALID;
1461 }
1462 
1463 #define MAKE_GET_DYN_ROLE_PROFILE_FN(ROLE) \
1464  static inline enum xrt_device_name get_role_profile_##ROLE(struct oxr_system *sys) \
1465  { \
1466  const bool is_locked = 0 == os_mutex_trylock(&sys->sync_actions_mutex); \
1467  const enum xrt_device_name profile_name = sys->dynamic_roles_cache.ROLE##_profile; \
1468  if (is_locked) { \
1469  os_mutex_unlock(&sys->sync_actions_mutex); \
1470  } \
1471  return profile_name; \
1472  }
1473 MAKE_GET_DYN_ROLE_PROFILE_FN(left)
1474 MAKE_GET_DYN_ROLE_PROFILE_FN(right)
1475 MAKE_GET_DYN_ROLE_PROFILE_FN(gamepad)
1476 #undef MAKE_GET_DYN_ROLES_FN
1477 
1478 #define GET_PROFILE_NAME_BY_ROLE(SYS, ROLE) (get_role_profile_##ROLE((SYS)))
1479 
1480 /*
1481  * Extensions helpers.
1482  */
1483 
1484 #define MAKE_EXT_STATUS(mixed_case, all_caps) bool mixed_case;
1485 /*!
1486  * Structure tracking which extensions are enabled for a given instance.
1487  *
1488  * Names are systematic: the extension name with the XR_ prefix removed.
1489  */
1491 {
1493 };
1494 #undef MAKE_EXT_STATUS
1495 
1496 /*!
1497  * Main object that ties everything together.
1498  *
1499  * No parent type/handle: this is the root handle.
1500  *
1501  * @obj{XrInstance}
1502  * @extends oxr_handle_base
1503  */
1504 struct oxr_instance
1505 {
1506  //! Common structure for things referred to by OpenXR handles.
1507  struct oxr_handle_base handle;
1508 
1509  struct u_debug_gui *debug_ui;
1511  struct xrt_instance *xinst;
1512 
1513  //! Enabled extensions
1515 
1516  // Hardcoded single system.
1517  struct oxr_system system;
1518 
1519  struct time_state *timekeeping;
1520 
1521  struct
1522  {
1523  struct u_hashset *name_store;
1524  struct u_hashset *loc_store;
1525  } action_sets;
1526 
1527  //! Path store, for looking up paths.
1528  struct u_hashset *path_store;
1529  //! Mapping from ID to path.
1530  struct oxr_path **path_array;
1531  //! Total length of path array.
1532  size_t path_array_length;
1533  //! Number of paths in the array (0 is always null).
1534  size_t path_num;
1535 
1536  // Event queue.
1537  struct
1538  {
1539  struct os_mutex mutex;
1540  struct oxr_event *last;
1541  struct oxr_event *next;
1542  } event;
1543 
1544  //! Interaction profile bindings that have been suggested by the client.
1546  size_t profile_count;
1547 
1548  struct oxr_session *sessions;
1549 
1550  struct
1551  {
1552 
1553 #define SUBACTION_PATH_MEMBER(X) XrPath X;
1554  OXR_FOR_EACH_SUBACTION_PATH(SUBACTION_PATH_MEMBER)
1555 
1556 #undef SUBACTION_PATH_MEMBER
1557 
1558 
1559  XrPath khr_simple_controller;
1560  XrPath google_daydream_controller;
1561  XrPath htc_vive_controller;
1562  XrPath htc_vive_pro;
1563  XrPath microsoft_motion_controller;
1564  XrPath microsoft_xbox_controller;
1565  XrPath oculus_go_controller;
1566  XrPath oculus_touch_controller;
1567  XrPath valve_index_controller;
1568  XrPath hp_mixed_reality_controller;
1569  XrPath samsung_odyssey_controller;
1570  XrPath ml_ml2_controller;
1571  XrPath mndx_ball_on_a_stick_controller;
1572  XrPath msft_hand_interaction;
1573  XrPath ext_eye_gaze_interaction;
1574  XrPath ext_hand_interaction;
1575  XrPath oppo_mr_controller;
1576  } path_cache;
1577 
1578  struct
1579  {
1580  struct
1581  {
1582  struct
1583  {
1584  uint32_t major;
1585  uint32_t minor;
1586  uint32_t patch;
1587  const char *name; //< Engine name, not freed.
1588  } engine;
1589  } detected;
1590  } appinfo;
1591 
1592  struct
1593  {
1594  //! Unreal has a bug in the VulkanRHI backend.
1596  //! Unreal 4 has a bug calling xrEndSession; the function should just exit
1597  bool skip_end_session;
1598 
1599  /*!
1600  * Return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED instead of
1601  * XR_ERROR_VALIDATION_FAILURE in xrCreateReferenceSpace.
1602  */
1604  } quirks;
1605 
1606  //! Debug messengers
1607  struct oxr_debug_messenger *messengers[XRT_MAX_HANDLE_CHILDREN];
1608 
1609  bool lifecycle_verbose;
1610  bool debug_views;
1611  bool debug_spaces;
1612  bool debug_bindings;
1613 
1614 #ifdef XRT_FEATURE_RENDERDOC
1615  RENDERDOC_API_1_4_1 *rdoc_api;
1616 #endif
1617 };
1618 
1619 /*!
1620  * Object that client program interact with.
1621  *
1622  * Parent type/handle is @ref oxr_instance
1623  *
1624  * @obj{XrSession}
1625  * @extends oxr_handle_base
1626  */
1627 struct oxr_session
1629  //! Common structure for things referred to by OpenXR handles.
1630  struct oxr_handle_base handle;
1631  struct oxr_system *sys;
1632 
1633  //! What graphics type was this session created with.
1635 
1636  //! The @ref xrt_session backing this session.
1637  struct xrt_session *xs;
1638 
1639  //! Native compositor that is wrapped by client compositors.
1640  struct xrt_compositor_native *xcn;
1641 
1642  struct xrt_compositor *compositor;
1643 
1644  struct oxr_session *next;
1645 
1646  XrSessionState state;
1647  bool has_begun;
1648  /*!
1649  * There is a extra state between xrBeginSession has been called and
1650  * the first xrEndFrame has been called. These are to track this.
1651  */
1652  bool has_ended_once;
1653 
1654  bool compositor_visible;
1655  bool compositor_focused;
1656 
1657  // the number of xrWaitFrame calls that did not yet have a corresponding
1658  // xrEndFrame or xrBeginFrame (discarded frame) call
1659  int active_wait_frames;
1660  struct os_mutex active_wait_frames_lock;
1661 
1662  bool frame_started;
1663  bool exiting;
1664 
1665  struct
1666  {
1667  int64_t waited;
1668  int64_t begun;
1669  } frame_id;
1670 
1671  struct os_semaphore sem;
1672 
1673  /*!
1674  * Used to implement precise extra sleeping in wait frame.
1675  */
1676  struct os_precise_sleeper sleeper;
1677 
1678  /*!
1679  * An array of action set attachments that this session owns.
1680  *
1681  * If non-null, this means action sets have been attached to this
1682  * session.
1683  */
1685 
1686  /*!
1687  * Length of @ref oxr_session::act_set_attachments.
1688  */
1690 
1691  /*!
1692  * A map of action set key to action set attachments.
1693  *
1694  * If non-null, this means action sets have been attached to this
1695  * session, since this map points to elements of
1696  * oxr_session::act_set_attachments
1697  */
1699 
1700  /*!
1701  * A map of action key to action attachment.
1702  *
1703  * The action attachments are actually owned by the action set
1704  * attachments, but we own the action set attachments, so this is OK.
1705  *
1706  * If non-null, this means action sets have been attached to this
1707  * session, since this map points to @p oxr_action_attachment members of
1708  * @ref oxr_session::act_set_attachments elements.
1709  */
1711 
1712  /*!
1713  * Clone of all suggested binding profiles at the point of action set/session attachment.
1714  * @ref oxr_session_attach_action_sets
1715  */
1717  struct oxr_interaction_profile **profiles_on_attachment;
1718 
1719  /*!
1720  * Currently bound interaction profile.
1721  * @{
1722  */
1723 
1724 #define OXR_PATH_MEMBER(X) XrPath X;
1725 
1727 #undef OXR_PATH_MEMBER
1728  /*!
1729  * @}
1730  */
1732  /*!
1733  * IPD, to be expanded to a proper 3D relation.
1734  */
1735  float ipd_meters;
1737  /*!
1738  * Frame timing debug output.
1739  */
1740  bool frame_timing_spew;
1741 
1742  //! Extra sleep in wait frame.
1743  uint32_t frame_timing_wait_sleep_ms;
1745  /*!
1746  * To pipe swapchain creation to right code.
1747  */
1748  XrResult (*create_swapchain)(struct oxr_logger *,
1749  struct oxr_session *sess,
1750  const XrSwapchainCreateInfo *,
1751  struct oxr_swapchain **);
1752 
1753  /*! initial relation of head in "global" space.
1754  * Used as reference for local space. */
1756 
1757  bool has_lost;
1758 };
1759 
1760 /*!
1761  * Returns XR_SUCCESS or XR_SESSION_LOSS_PENDING as appropriate.
1762  *
1763  * @public @memberof oxr_session
1764  */
1765 static inline XrResult
1766 oxr_session_success_result(struct oxr_session *session)
1767 {
1768  switch (session->state) {
1769  case XR_SESSION_STATE_LOSS_PENDING: return XR_SESSION_LOSS_PENDING;
1770  default: return XR_SUCCESS;
1771  }
1772 }
1773 
1774 /*!
1775  * Returns XR_SUCCESS, XR_SESSION_LOSS_PENDING, or XR_SESSION_NOT_FOCUSED, as
1776  * appropriate.
1777  *
1778  * @public @memberof oxr_session
1779  */
1780 static inline XrResult
1782 {
1783  switch (session->state) {
1784  case XR_SESSION_STATE_LOSS_PENDING: return XR_SESSION_LOSS_PENDING;
1785  case XR_SESSION_STATE_FOCUSED: return XR_SUCCESS;
1786  default: return XR_SESSION_NOT_FOCUSED;
1787  }
1788 }
1789 
1790 #ifdef OXR_HAVE_FB_display_refresh_rate
1791 XrResult
1792 oxr_session_get_display_refresh_rate(struct oxr_logger *log, struct oxr_session *sess, float *displayRefreshRate);
1793 
1794 XrResult
1795 oxr_session_request_display_refresh_rate(struct oxr_logger *log, struct oxr_session *sess, float displayRefreshRate);
1796 #endif // OXR_HAVE_FB_display_refresh_rate
1797 
1798 /*!
1799  * dpad settings we need extracted from XrInteractionProfileDpadBindingEXT
1800  *
1801  * @ingroup oxr_input
1802  */
1803 struct oxr_dpad_settings
1804 {
1805  float forceThreshold;
1806  float forceThresholdReleased;
1807  float centerRegion;
1808  float wedgeAngle;
1809  bool isSticky;
1810 };
1812 /*!
1813  * dpad binding extracted from XrInteractionProfileDpadBindingEXT
1814  */
1816 {
1817  XrPath binding;
1818  struct oxr_dpad_settings settings;
1819 };
1820 
1821 /*!
1822  * A entry in the dpad state for one action set.
1823  *
1824  * @ingroup oxr_input
1825  */
1826 struct oxr_dpad_entry
1827 {
1828 #ifdef XR_EXT_dpad_binding
1829  struct oxr_dpad_binding_modification dpads[4];
1830  uint32_t dpad_count;
1831 #endif
1832 
1833  uint64_t key;
1834 };
1835 
1836 /*!
1837  * Holds dpad binding state for a single interaction profile.
1838  *
1839  * @ingroup oxr_input
1840  */
1841 struct oxr_dpad_state
1842 {
1843  struct u_hashmap_int *uhi;
1844 };
1846 /*!
1847  * dpad emulation settings from oxr_interaction_profile
1848  */
1849 struct oxr_dpad_emulation
1850 {
1851  enum oxr_subaction_path subaction_path;
1852  XrPath *paths;
1853  uint32_t path_count;
1854  enum xrt_input_name position;
1855  enum xrt_input_name activate; // Can be zero
1856 };
1858 /*!
1859  * A single interaction profile.
1860  */
1862 {
1863  XrPath path;
1864 
1865  //! Used to lookup @ref xrt_binding_profile for fallback.
1866  enum xrt_device_name xname;
1867 
1868  //! Name presented to the user.
1869  const char *localized_name;
1870 
1871  struct oxr_binding *bindings;
1872  size_t binding_count;
1873 
1874  struct oxr_dpad_emulation *dpads;
1875  size_t dpad_count;
1876 
1877  struct oxr_dpad_state dpad_state;
1878 };
1880 /*!
1881  * Interaction profile binding state.
1882  */
1883 struct oxr_binding
1884 {
1885  XrPath *paths;
1886  uint32_t path_count;
1887 
1888  //! Name presented to the user.
1889  const char *localized_name;
1890 
1891  enum oxr_subaction_path subaction_path;
1893  uint32_t key_count;
1894  uint32_t *keys;
1895  //! store which entry in paths was suggested, for each action key
1896  uint32_t *preferred_binding_path_index;
1897 
1898  enum xrt_input_name input;
1899  enum xrt_input_name dpad_activate;
1900 
1901  enum xrt_output_name output;
1902 };
1903 
1904 /*!
1905  * @defgroup oxr_input OpenXR input
1906  * @ingroup oxr_main
1907  *
1908  * @brief The action-set/action-based input subsystem of OpenXR.
1909  *
1910  *
1911  * Action sets are created as children of the Instance, but are primarily used
1912  * with one or more Sessions. They may be used with multiple sessions at a time,
1913  * so we can't just put the per-session information directly in the action set
1914  * or action. Instead, we have the `_attachment `structures, which mirror the
1915  * action sets and actions but are rooted under the Session:
1916  *
1917  * - For every action set attached to a session, that session owns a @ref
1918  * oxr_action_set_attachment.
1919  * - For each action in those attached action sets, the action set attachment
1920  * owns an @ref oxr_action_attachment.
1921  *
1922  * We go from the public handle to the `_attachment` structure by using a `key`
1923  * value and a hash map: specifically, we look up the
1924  * oxr_action_set::act_set_key and oxr_action::act_key in the session.
1925  *
1926  * ![](monado-input-class-relationships.drawio.svg)
1927  */
1928 
1929 /*!
1930  * A parsed equivalent of a list of sub-action paths.
1931  *
1932  * If @p any is true, then no paths were provided, which typically means any
1933  * input is acceptable.
1934  *
1935  * @ingroup oxr_main
1936  * @ingroup oxr_input
1937  */
1938 struct oxr_subaction_paths
1939 {
1940  bool any;
1941 #define OXR_SUBPATH_MEMBER(X) bool X;
1942  OXR_FOR_EACH_SUBACTION_PATH(OXR_SUBPATH_MEMBER)
1943 #undef OXR_SUBPATH_MEMBER
1944 };
1945 
1946 /*!
1947  * Helper function to determine if the set of paths in @p a is a subset of the
1948  * paths in @p b.
1949  *
1950  * @public @memberof oxr_subaction_paths
1951  */
1952 static inline bool
1954 {
1955 #define OXR_CHECK_SUBACTION_PATHS(X) \
1956  if (a->X && !b->X) { \
1957  return false; \
1958  }
1959  OXR_FOR_EACH_SUBACTION_PATH(OXR_CHECK_SUBACTION_PATHS)
1960 #undef OXR_CHECK_SUBACTION_PATHS
1961  return true;
1962 }
1963 
1964 /*!
1965  * The data associated with the attachment of an Action Set (@ref
1966  * oxr_action_set) to as Session (@ref oxr_session).
1967  *
1968  * This structure has no pointer to the @ref oxr_action_set that created it
1969  * because the application is allowed to destroy an action before the session,
1970  * which should change nothing except not allow the application to use the
1971  * corresponding data anymore.
1972  *
1973  * @ingroup oxr_input
1974  *
1975  * @see oxr_action_set
1976  */
1978 {
1979  //! Owning session.
1981 
1982  //! Action set refcounted data
1984 
1985  //! Unique key for the session hashmap.
1986  uint32_t act_set_key;
1987 
1988  //! Which sub-action paths are requested on the latest sync.
1990 
1991  //! An array of action attachments we own.
1993 
1994  /*!
1995  * Length of @ref oxr_action_set_attachment::act_attachments.
1996  */
1997  size_t action_attachment_count;
1998 };
1999 
2000 /*!
2001  * De-initialize an action set attachment and its action attachments.
2002  *
2003  * Frees the action attachments, but does not de-allocate the action set
2004  * attachment.
2005  *
2006  * @public @memberof oxr_action_set_attachment
2007  */
2008 void
2010 
2011 
2012 /*!
2013  * The state of a action input.
2014  *
2015  * @ingroup oxr_input
2016  *
2017  * @see oxr_action_attachment
2018  */
2019 struct oxr_action_state
2020 {
2021  /*!
2022  * The actual value - must interpret using action type
2023  */
2024  union xrt_input_value value;
2025 
2026  //! Is this active (bound and providing input)?
2027  bool active;
2028 
2029  // Was this changed.
2030  bool changed;
2031 
2032  //! When was this last changed.
2033  XrTime timestamp;
2034 };
2035 
2036 /*!
2037  * A input action pair of a @ref xrt_input and a @ref xrt_device, along with the
2038  * required transform.
2039  *
2040  * @ingroup oxr_input
2041  *
2042  * @see xrt_device
2043  * @see xrt_input
2044  */
2045 struct oxr_action_input
2046 {
2047  struct xrt_device *xdev; // Used for poses and transform is null.
2048  struct xrt_input *input; // Ditto
2049  enum xrt_input_name dpad_activate_name; // used to activate dpad emulation if present
2050  struct xrt_input *dpad_activate; // used to activate dpad emulation if present
2051  struct oxr_input_transform *transforms;
2052  size_t transform_count;
2053  XrPath bound_path;
2054 };
2055 
2056 /*!
2057  * A output action pair of a @ref xrt_output_name and a @ref xrt_device.
2058  *
2059  * @ingroup oxr_input
2060  *
2061  * @see xrt_device
2062  * @see xrt_output_name
2063  */
2064 struct oxr_action_output
2065 {
2066  struct xrt_device *xdev;
2067  enum xrt_output_name name;
2068  XrPath bound_path;
2069 };
2070 
2071 
2072 /*!
2073  * The set of inputs/outputs for a single sub-action path for an action.
2074  *
2075  * Each @ref oxr_action_attachment has one of these for every known sub-action
2076  * path in the spec. Many, or even most, will be "empty".
2077  *
2078  * A single action will either be input or output, not both.
2079  *
2080  * @ingroup oxr_input
2081  *
2082  * @see oxr_action_attachment
2083  */
2084 struct oxr_action_cache
2085 {
2086  struct oxr_action_state current;
2087 
2088  size_t input_count;
2089  struct oxr_action_input *inputs;
2090 
2091  int64_t stop_output_time;
2092  size_t output_count;
2093  struct oxr_action_output *outputs;
2094 };
2095 
2096 /*!
2097  * Data associated with an Action that has been attached to a Session.
2098  *
2099  * More information on the action vs action attachment and action set vs action
2100  * set attachment parallel is in the docs for @ref oxr_input
2101  *
2102  * @ingroup oxr_input
2103  *
2104  * @see oxr_action
2105  */
2107 {
2108  //! The owning action set attachment
2110 
2111  //! This action's refcounted data
2112  struct oxr_action_ref *act_ref;
2113 
2114  /*!
2115  * The corresponding session.
2116  *
2117  * This will always be valid: the session outlives this object because
2118  * it owns act_set_attached.
2119  */
2120  struct oxr_session *sess;
2121 
2122  //! Unique key for the session hashmap.
2123  uint32_t act_key;
2124 
2125 
2126  /*!
2127  * For pose actions any subaction paths are special treated, at bind
2128  * time we pick one subaction path and stick to it as long as the action
2129  * lives.
2130  */
2132 
2133  struct oxr_action_state any_state;
2134 
2135 #define OXR_CACHE_MEMBER(X) struct oxr_action_cache X;
2136  OXR_FOR_EACH_SUBACTION_PATH(OXR_CACHE_MEMBER)
2137 #undef OXR_CACHE_MEMBER
2138 };
2139 
2140 /*!
2141  * @}
2142  */
2143 
2144 
2145 static inline bool
2146 oxr_space_type_is_reference(enum oxr_space_type space_type)
2147 {
2148  switch (space_type) {
2149  case OXR_SPACE_TYPE_REFERENCE_VIEW:
2150  case OXR_SPACE_TYPE_REFERENCE_LOCAL:
2151  case OXR_SPACE_TYPE_REFERENCE_LOCAL_FLOOR:
2152  case OXR_SPACE_TYPE_REFERENCE_STAGE:
2153  case OXR_SPACE_TYPE_REFERENCE_UNBOUNDED_MSFT:
2154  case OXR_SPACE_TYPE_REFERENCE_COMBINED_EYE_VARJO:
2155  case OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML:
2156  // These are reference spaces.
2157  return true;
2158 
2159  case OXR_SPACE_TYPE_ACTION:
2160  // Not a reference space.
2161  return false;
2162  }
2163 
2164  // Handles invalid value.
2165  return false;
2166 }
2167 
2168 
2169 /*!
2170  * Can be one of several reference space types, or a space that is bound to an
2171  * action.
2172  *
2173  * Parent type/handle is @ref oxr_session
2174  *
2175  * @obj{XrSpace}
2176  * @extends oxr_handle_base
2177  */
2178 struct oxr_space
2179 {
2180  //! Common structure for things referred to by OpenXR handles.
2181  struct oxr_handle_base handle;
2182 
2183  //! Owner of this space.
2184  struct oxr_session *sess;
2185 
2186  //! Pose that was given during creation.
2187  struct xrt_pose pose;
2188 
2189  //! Action key from which action this space was created from.
2190  uint32_t act_key;
2191 
2192  //! What kind of space is this?
2195  //! Which sub action path is this?
2197 
2198  struct
2199  {
2200  struct xrt_space *xs;
2201  struct xrt_device *xdev;
2202  enum xrt_input_name name;
2203  } action;
2204 };
2205 
2206 /*!
2207  * A set of images used for rendering.
2208  *
2209  * Parent type/handle is @ref oxr_session
2210  *
2211  * @obj{XrSwapchain}
2212  * @extends oxr_handle_base
2213  */
2214 struct oxr_swapchain
2215 {
2216  //! Common structure for things referred to by OpenXR handles.
2217  struct oxr_handle_base handle;
2218 
2219  //! Owner of this swapchain.
2220  struct oxr_session *sess;
2221 
2222  //! Compositor swapchain.
2223  struct xrt_swapchain *swapchain;
2224 
2225  //! Swapchain size.
2226  uint32_t width, height;
2227 
2228  //! For 1 is 2D texture, greater then 1 2D array texture.
2229  uint32_t array_layer_count;
2230 
2231  //! The number of cubemap faces. 6 for cubemaps, 1 otherwise.
2232  uint32_t face_count;
2233 
2234  struct
2235  {
2236  enum oxr_image_state state;
2237  } images[XRT_MAX_SWAPCHAIN_IMAGES];
2238 
2239  struct
2240  {
2241  size_t num;
2242  struct u_index_fifo fifo;
2243  } acquired;
2244 
2245  struct
2246  {
2247  bool yes;
2248  int index;
2249  } inflight; // This is the image that the app is working on.
2250 
2251  struct
2252  {
2253  bool yes;
2254  int index;
2255  } released;
2256 
2257  // Is this a static swapchain, needed for acquire semantics.
2258  bool is_static;
2259 
2260 
2261  XrResult (*destroy)(struct oxr_logger *, struct oxr_swapchain *);
2262 
2263  XrResult (*enumerate_images)(struct oxr_logger *,
2264  struct oxr_swapchain *,
2265  uint32_t,
2266  XrSwapchainImageBaseHeader *);
2267 
2268  XrResult (*acquire_image)(struct oxr_logger *,
2269  struct oxr_swapchain *,
2270  const XrSwapchainImageAcquireInfo *,
2271  uint32_t *);
2272 
2273  XrResult (*wait_image)(struct oxr_logger *, struct oxr_swapchain *, const XrSwapchainImageWaitInfo *);
2274 
2275  XrResult (*release_image)(struct oxr_logger *, struct oxr_swapchain *, const XrSwapchainImageReleaseInfo *);
2276 };
2277 
2278 struct oxr_refcounted
2279 {
2280  struct xrt_reference base;
2281  //! Destruction callback
2282  void (*destroy)(struct oxr_refcounted *);
2283 };
2284 
2285 /*!
2286  * Increase the reference count of @p orc.
2287  */
2288 static inline void
2290 {
2291  xrt_reference_inc(&orc->base);
2292 }
2293 
2294 /*!
2295  * Decrease the reference count of @p orc, destroying it if it reaches 0.
2296  */
2297 static inline void
2299 {
2300  if (xrt_reference_dec_and_is_zero(&orc->base)) {
2301  orc->destroy(orc);
2302  }
2303 }
2304 
2305 /*!
2306  * The reference-counted data of an action set.
2307  *
2308  * One or more sessions may still need this data after the application destroys
2309  * its XrActionSet handle, so this data is refcounted.
2310  *
2311  * @ingroup oxr_input
2312  *
2313  * @see oxr_action_set
2314  * @extends oxr_refcounted
2315  */
2316 struct oxr_action_set_ref
2317 {
2318  struct oxr_refcounted base;
2319 
2320  //! Application supplied name of this action.
2321  char name[XR_MAX_ACTION_SET_NAME_SIZE];
2322 
2323  /*!
2324  * Has this action set even been attached to any session, marking it as
2325  * immutable.
2326  */
2327  bool ever_attached;
2328 
2329  //! Unique key for the session hashmap.
2330  uint32_t act_set_key;
2332  //! Application supplied action set priority.
2333  uint32_t priority;
2334 
2335  struct
2336  {
2337  struct u_hashset *name_store;
2338  struct u_hashset *loc_store;
2339  } actions;
2340 
2341  struct oxr_subaction_paths permitted_subaction_paths;
2342 };
2343 
2344 /*!
2345  * A group of actions.
2346  *
2347  * Parent type/handle is @ref oxr_instance
2348  *
2349  * Note, however, that an action set must be "attached" to a session
2350  * ( @ref oxr_session ) to be used and not just configured.
2351  * The corresponding data is in @ref oxr_action_set_attachment.
2352  *
2353  * @ingroup oxr_input
2354  *
2355  * @obj{XrActionSet}
2356  * @extends oxr_handle_base
2357  */
2358 struct oxr_action_set
2359 {
2360  //! Common structure for things referred to by OpenXR handles.
2361  struct oxr_handle_base handle;
2362 
2363  //! Owner of this action set.
2364  struct oxr_instance *inst;
2365 
2366  /*!
2367  * The data for this action set that must live as long as any session we
2368  * are attached to.
2369  */
2370  struct oxr_action_set_ref *data;
2372 
2373  /*!
2374  * Unique key for the session hashmap.
2375  *
2376  * Duplicated from oxr_action_set_ref::act_set_key for efficiency.
2377  */
2378  uint32_t act_set_key;
2379 
2380  //! The item in the name hashset.
2381  struct u_hashset_item *name_item;
2382 
2383  //! The item in the localized hashset.
2384  struct u_hashset_item *loc_item;
2385 };
2386 
2387 /*!
2388  * The reference-counted data of an action.
2389  *
2390  * One or more sessions may still need this data after the application destroys
2391  * its XrAction handle, so this data is refcounted.
2392  *
2393  * @ingroup oxr_input
2394  *
2395  * @see oxr_action
2396  * @extends oxr_refcounted
2397  */
2398 struct oxr_action_ref
2400  struct oxr_refcounted base;
2401 
2402  //! Application supplied name of this action.
2403  char name[XR_MAX_ACTION_NAME_SIZE];
2404 
2405  //! Unique key for the session hashmap.
2406  uint32_t act_key;
2407 
2408  //! Type this action was created with.
2409  XrActionType action_type;
2410 
2411  //! Which sub action paths that this action was created with.
2413 };
2414 
2415 /*!
2416  * A single action.
2417  *
2418  * Parent type/handle is @ref oxr_action_set
2419  *
2420  * For actual usage, an action is attached to a session: the corresponding data
2421  * is in @ref oxr_action_attachment
2422  *
2423  * @ingroup oxr_input
2424  *
2425  * @obj{XrAction}
2426  * @extends oxr_handle_base
2427  */
2428 struct oxr_action
2429 {
2430  //! Common structure for things referred to by OpenXR handles.
2432 
2433  //! Owner of this action.
2434  struct oxr_action_set *act_set;
2435 
2436  //! The data for this action that must live as long as any session we
2437  //! are attached to.
2439 
2440  /*!
2441  * Unique key for the session hashmap.
2442  *
2443  * Duplicated from oxr_action_ref::act_key for efficiency.
2444  */
2445  uint32_t act_key;
2446 
2447  //! The item in the name hashset.
2448  struct u_hashset_item *name_item;
2449 
2450  //! The item in the localized hashset.
2451  struct u_hashset_item *loc_item;
2452 };
2453 
2454 /*!
2455  * Debug object created by the client program.
2456  *
2457  * Parent type/handle is @ref oxr_instance
2458  *
2459  * @obj{XrDebugUtilsMessengerEXT}
2460  */
2461 struct oxr_debug_messenger
2462 {
2463  //! Common structure for things referred to by OpenXR handles.
2464  struct oxr_handle_base handle;
2465 
2466  //! Owner of this messenger.
2467  struct oxr_instance *inst;
2468 
2469  //! Severities to submit to this messenger
2470  XrDebugUtilsMessageSeverityFlagsEXT message_severities;
2471 
2472  //! Types to submit to this messenger
2473  XrDebugUtilsMessageTypeFlagsEXT message_types;
2474 
2475  //! Callback function
2476  PFN_xrDebugUtilsMessengerCallbackEXT user_callback;
2477 
2478  //! Opaque user data
2479  void *XR_MAY_ALIAS user_data;
2480 };
2481 
2482 /*!
2483  * A hand tracker.
2484  *
2485  * Parent type/handle is @ref oxr_instance
2486  *
2487  *
2488  * @obj{XrHandTrackerEXT}
2489  * @extends oxr_handle_base
2490  */
2491 struct oxr_hand_tracker
2492 {
2493  //! Common structure for things referred to by OpenXR handles.
2494  struct oxr_handle_base handle;
2495 
2496  //! Owner of this hand tracker.
2497  struct oxr_session *sess;
2498 
2499  //! xrt_device backing this hand tracker
2500  struct xrt_device *xdev;
2501 
2502  //! the input name associated with this hand tracker
2504 
2505  XrHandEXT hand;
2506  XrHandJointSetEXT hand_joint_set;
2507 };
2508 
2509 #ifdef OXR_HAVE_FB_passthrough
2510 
2511 struct oxr_passthrough
2512 {
2513  struct oxr_handle_base handle;
2514 
2515  struct oxr_session *sess;
2516 
2517  XrPassthroughFlagsFB flags;
2518 
2519  bool paused;
2520 };
2521 
2522 struct oxr_passthrough_layer
2523 {
2524  struct oxr_handle_base handle;
2525 
2526  struct oxr_session *sess;
2527 
2528  XrPassthroughFB passthrough;
2529 
2530  XrPassthroughFlagsFB flags;
2531 
2532  XrPassthroughLayerPurposeFB purpose;
2533 
2534  bool paused;
2535 
2536  XrPassthroughStyleFB style;
2537  XrPassthroughColorMapMonoToRgbaFB monoToRgba;
2538  XrPassthroughColorMapMonoToMonoFB monoToMono;
2539  XrPassthroughBrightnessContrastSaturationFB brightnessContrastSaturation;
2540 };
2541 
2542 XrResult
2543 oxr_passthrough_create(struct oxr_logger *log,
2544  struct oxr_session *sess,
2545  const XrPassthroughCreateInfoFB *createInfo,
2546  struct oxr_passthrough **out_passthrough);
2547 
2548 XrResult
2549 oxr_passthrough_layer_create(struct oxr_logger *log,
2550  struct oxr_session *sess,
2551  const XrPassthroughLayerCreateInfoFB *createInfo,
2552  struct oxr_passthrough_layer **out_layer);
2553 
2554 static inline XrPassthroughFB
2555 oxr_passthrough_to_openxr(struct oxr_passthrough *passthrough)
2556 {
2557  return XRT_CAST_PTR_TO_OXR_HANDLE(XrPassthroughFB, passthrough);
2558 }
2559 
2560 static inline XrPassthroughLayerFB
2561 oxr_passthrough_layer_to_openxr(struct oxr_passthrough_layer *passthroughLayer)
2562 {
2563  return XRT_CAST_PTR_TO_OXR_HANDLE(XrPassthroughLayerFB, passthroughLayer);
2564 }
2565 
2566 XrResult
2567 oxr_event_push_XrEventDataPassthroughStateChangedFB(struct oxr_logger *log,
2568  struct oxr_session *sess,
2569  XrPassthroughStateChangedFlagsFB flags);
2570 
2571 #endif // OXR_HAVE_FB_passthrough
2572 
2573 /*!
2574  * HTC specific Facial tracker.
2575  *
2576  * Parent type/handle is @ref oxr_instance
2577  *
2578  *
2579  * @obj{XrFacialTrackerHTC}
2580  * @extends oxr_handle_base
2581  */
2583 {
2584  //! Common structure for things referred to by OpenXR handles.
2585  struct oxr_handle_base handle;
2586 
2587  //! Owner of this face tracker.
2588  struct oxr_session *sess;
2589 
2590  //! xrt_device backing this face tracker
2591  struct xrt_device *xdev;
2592 
2593  //! Type of facial tracking, eyes or lips
2594  enum xrt_facial_tracking_type_htc facial_tracking_type;
2595 };
2596 
2597 /*!
2598  * @}
2599  */
2600 
2601 
2602 #ifdef __cplusplus
2603 }
2604 #endif
void oxr_action_set_attachment_teardown(struct oxr_action_set_attachment *act_set_attached)
De-initialize an action set attachment and its action attachments.
Definition: oxr_input.c:224
void oxr_binding_find_bindings_from_key(struct oxr_logger *log, struct oxr_interaction_profile *p, uint32_t key, size_t max_bounding_count, struct oxr_binding **bindings, size_t *out_binding_count)
Find all bindings that is the given action key is bound to.
Definition: oxr_binding.c:425
static void oxr_refcounted_unref(struct oxr_refcounted *orc)
Decrease the reference count of orc, destroying it if it reaches 0.
Definition: oxr_objects.h:2291
XrResult oxr_poll_event(struct oxr_logger *log, struct oxr_instance *inst, XrEventDataBuffer *eventData)
Will return one event if available, also drain the sessions event queues.
Definition: oxr_event.c:354
XrResult oxr_session_begin(struct oxr_logger *log, struct oxr_session *sess, const XrSessionBeginInfo *beginInfo)
Definition: oxr_session.c:206
static XrSwapchain oxr_swapchain_to_openxr(struct oxr_swapchain *sc)
To go back to a OpenXR object.
Definition: oxr_objects.h:872
oxr_image_state
Tracks the state of a image that belongs to a oxr_swapchain.
Definition: oxr_defines.h:87
XrResult oxr_path_get_or_create(struct oxr_logger *log, struct oxr_instance *inst, const char *str, size_t length, XrPath *out_path)
Get the path for the given string if it exists, or create it if it does not.
Definition: oxr_path.c:172
XrResult oxr_d3d_check_luid(struct oxr_logger *log, struct oxr_system *sys, LUID *adapter_luid)
Verify the provided LUID matches the expected one in sys.
Definition: oxr_d3d.cpp:80
XrResult oxr_system_enumerate_blend_modes(struct oxr_logger *log, struct oxr_system *sys, XrViewConfigurationType viewConfigurationType, uint32_t environmentBlendModeCapacityInput, uint32_t *environmentBlendModeCountOutput, XrEnvironmentBlendMode *environmentBlendModes)
Definition: oxr_system.c:403
XrResult oxr_handle_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
Destroy the handle's object, as well as all child handles recursively.
Definition: oxr_handle_base.c:197
XrResult oxr_event_remove_session_events(struct oxr_logger *log, struct oxr_session *sess)
This clears all pending events refers to the given session.
Definition: oxr_event.c:322
static XrResult oxr_session_success_result(struct oxr_session *session)
Returns XR_SUCCESS or XR_SESSION_LOSS_PENDING as appropriate.
Definition: oxr_objects.h:1762
XrResult oxr_action_get_pose_input(struct oxr_session *sess, uint32_t act_key, const struct oxr_subaction_paths *subaction_paths_ptr, struct oxr_action_input **out_input)
Find the pose input for the set of subaction_paths.
Definition: oxr_input.c:475
static XrResult oxr_session_success_focused_result(struct oxr_session *session)
Returns XR_SUCCESS, XR_SESSION_LOSS_PENDING, or XR_SESSION_NOT_FOCUSED, as appropriate.
Definition: oxr_objects.h:1777
XrResult oxr_path_only_get(struct oxr_logger *log, struct oxr_instance *inst, const char *str, size_t length, XrPath *out_path)
Only get the path for the given string if it exists.
Definition: oxr_path.c:199
void oxr_find_profile_for_device(struct oxr_logger *log, struct oxr_session *sess, struct xrt_device *xdev, struct oxr_interaction_profile **out_p)
Find the best matching profile for the given xrt_device.
Definition: oxr_binding.c:399
XrResult oxr_session_attach_action_sets(struct oxr_logger *log, struct oxr_session *sess, const XrSessionActionSetsAttachInfo *bindInfo)
Definition: oxr_input.c:1686
XRT_CHECK_RESULT XrResult oxr_space_locate_device(struct oxr_logger *log, struct xrt_device *xdev, struct oxr_space *baseSpc, XrTime time, struct xrt_space_relation *out_relation)
Locate the xrt_device in the given base space, useful for implementing hand tracking location look up...
Definition: oxr_space.c:335
static XrDebugUtilsMessengerEXT oxr_messenger_to_openxr(struct oxr_debug_messenger *mssngr)
To go back to a OpenXR object.
Definition: oxr_objects.h:888
XrResult oxr_space_locate(struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location)
Definition: oxr_space.c:202
XrResult oxr_session_frame_end(struct oxr_logger *log, struct oxr_session *sess, const XrFrameEndInfo *frameEndInfo)
Definition: oxr_session_frame_end.c:1638
static XrInstance oxr_instance_to_openxr(struct oxr_instance *inst)
To go back to a OpenXR object.
Definition: oxr_objects.h:208
static XrHandTrackerEXT oxr_hand_tracker_to_openxr(struct oxr_hand_tracker *hand_tracker)
To go back to a OpenXR object.
Definition: oxr_objects.h:370
static XrActionSet oxr_action_set_to_openxr(struct oxr_action_set *act_set)
To go back to a OpenXR object.
Definition: oxr_objects.h:359
bool oxr_classify_subaction_paths(struct oxr_logger *log, const struct oxr_instance *inst, uint32_t subaction_path_count, const XrPath *subaction_paths, struct oxr_subaction_paths *subaction_paths_out)
Helper function to classify subaction_paths.
Definition: oxr_input.c:431
static bool oxr_subaction_paths_is_subset_of(const struct oxr_subaction_paths *a, const struct oxr_subaction_paths *b)
Helper function to determine if the set of paths in a is a subset of the paths in b.
Definition: oxr_objects.h:1948
static XrSession oxr_session_to_openxr(struct oxr_session *sess)
To go back to a OpenXR object.
Definition: oxr_objects.h:720
oxr_session_graphics_ext
What graphics API was this session created with.
Definition: oxr_defines.h:117
static XrAction oxr_action_to_openxr(struct oxr_action *act)
To go back to a OpenXR object.
Definition: oxr_objects.h:381
XrResult oxr_d3d_get_requirements(struct oxr_logger *log, struct oxr_system *sys, LUID *adapter_luid, D3D_FEATURE_LEVEL *min_feature_level)
Common GetRequirements call for D3D11 and D3D12.
Definition: oxr_d3d.cpp:42
bool oxr_xdev_find_input(struct xrt_device *xdev, enum xrt_input_name name, struct xrt_input **out_input)
Return true if it finds an input of that name on this device.
Definition: oxr_xdev.c:45
oxr_space_type
Internal enum for the type of space, lets us reason about action spaces.
Definition: oxr_defines.h:99
XrResult oxr_vk_create_vulkan_instance(struct oxr_logger *log, struct oxr_system *sys, const XrVulkanInstanceCreateInfoKHR *createInfo, VkInstance *vulkanInstance, VkResult *vulkanResult)
Definition: oxr_vulkan.c:227
static void oxr_refcounted_ref(struct oxr_refcounted *orc)
Increase the reference count of orc.
Definition: oxr_objects.h:2282
void oxr_xdev_get_hand_tracking_at(struct oxr_logger *log, struct oxr_instance *inst, struct xrt_device *xdev, enum xrt_input_name name, XrTime at_time, struct xrt_hand_joint_set *out_value)
Returns the hand tracking value of the named input from the device.
Definition: oxr_xdev.c:82
void oxr_binding_destroy_all(struct oxr_logger *log, struct oxr_instance *inst)
Free all memory allocated by the binding system.
Definition: oxr_binding.c:580
XrResult oxr_session_request_exit(struct oxr_logger *log, struct oxr_session *sess)
Definition: oxr_session.c:300
XrResult(* oxr_handle_destroyer)(struct oxr_logger *log, struct oxr_handle_base *hb)
Function pointer type for a handle destruction function.
Definition: oxr_objects.h:136
void oxr_session_change_state(struct oxr_logger *log, struct oxr_session *sess, XrSessionState state, XrTime time)
Change the state of the session, queues a event.
Definition: oxr_session.c:163
XrResult oxr_system_fill_in(struct oxr_logger *log, struct oxr_instance *inst, XrSystemId systemId, uint32_t view_count, struct oxr_system *sys)
Definition: oxr_system.c:110
XrResult oxr_create_messenger(struct oxr_logger *, struct oxr_instance *inst, const XrDebugUtilsMessengerCreateInfoEXT *, struct oxr_debug_messenger **out_mssngr)
Definition: oxr_messenger.c:41
void oxr_session_binding_destroy_all(struct oxr_logger *log, struct oxr_session *sess)
Free all memory allocated by the binding system.
Definition: oxr_binding.c:588
XrResult oxr_instance_create(struct oxr_logger *log, const XrInstanceCreateInfo *createInfo, const struct oxr_extension_status *extensions, struct oxr_instance **out_inst)
Creates a instance, does minimal validation of createInfo.
Definition: oxr_instance.c:194
XrResult oxr_path_get_string(struct oxr_logger *log, const struct oxr_instance *inst, XrPath path, const char **out_str, size_t *out_length)
Get a pointer and length of the internal string.
Definition: oxr_path.c:216
XrResult oxr_session_frame_wait(struct oxr_logger *log, struct oxr_session *sess, XrFrameState *frameState)
Definition: oxr_session.c:668
oxr_handle_state
State of a handle base, to reduce likelihood of going "boom" on out-of-order destruction or other uns...
Definition: oxr_defines.h:41
static XrSpace oxr_space_to_openxr(struct oxr_space *spc)
To go back to a OpenXR object.
Definition: oxr_objects.h:820
oxr_subaction_path
Sub action paths.
Definition: oxr_defines.h:58
XrResult oxr_vk_create_vulkan_device(struct oxr_logger *log, struct oxr_system *sys, const XrVulkanDeviceCreateInfoKHR *createInfo, VkDevice *vulkanDevice, VkResult *vulkanResult)
Definition: oxr_vulkan.c:386
const char * oxr_handle_state_to_string(enum oxr_handle_state state)
Returns a human-readable label for a handle state.
Definition: oxr_handle_base.c:42
bool oxr_xdev_find_output(struct xrt_device *xdev, enum xrt_output_name name, struct xrt_output **out_output)
Return true if it finds an output of that name on this device.
Definition: oxr_xdev.c:64
#define XRT_CAST_PTR_TO_OXR_HANDLE(HANDLE_TYPE, PTR)
Cast a pointer to an OpenXR handle in such a way as to avoid warnings.
Definition: oxr_objects.h:70
static XRT_CHECK_RESULT bool xrt_reference_dec_and_is_zero(struct xrt_reference *xref)
Decrement the reference and return true if the value is now zero.
Definition: xrt_defines.h:1598
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition: xrt_limits.h:34
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition: xrt_defines.h:1134
static void xrt_reference_inc(struct xrt_reference *xref)
Increment the reference, probably want xrt_reference_inc_and_was_zero.
Definition: xrt_defines.h:1561
xrt_output_name
Name of a output with a baked in type.
Definition: xrt_defines.h:1388
Wrapper around OS threading native functions.
XrResult oxr_action_get_current_interaction_profile(struct oxr_logger *log, struct oxr_session *sess, XrPath topLevelUserPath, XrInteractionProfileState *interactionProfile)
Definition: oxr_binding.c:642
Shared internal defines and enums in the state tracker.
Macros for generating extension-related tables and code and inspecting Monado's extension support.
#define OXR_EXTENSION_SUPPORT_GENERATE(_)
Call this, passing a macro taking two parameters, to generate tables, code, etc.
Definition: oxr_extension_support.h:633
XrResult oxr_action_sync_data(struct oxr_logger *log, struct oxr_session *sess, uint32_t countActionSets, const XrActiveActionSet *actionSets)
Definition: oxr_input.c:1768
#define OXR_PATH_MEMBER(X)
Currently bound interaction profile.
Definition: oxr_objects.h:1721
Provides a utility macro for dealing with subaction paths.
#define OXR_FOR_EACH_SUBACTION_PATH(_)
Expansion macro (x-macro) that calls the macro you pass with the shorthand name of each subaction pat...
Definition: oxr_subaction.h:39
#define OXR_FOR_EACH_VALID_SUBACTION_PATH(_)
Expansion macro (x-macro) that calls the macro you pass with the shorthand name of each valid subacti...
Definition: oxr_subaction.h:23
Definition: m_space.cpp:87
A wrapper around a native mutex.
Definition: os_threading.h:55
Definition: os_time.h:208
A wrapper around a native semaphore.
Definition: os_threading.h:354
Data associated with an Action that has been attached to a Session.
Definition: oxr_objects.h:2101
struct oxr_subaction_paths any_pose_subaction_path
For pose actions any subaction paths are special treated, at bind time we pick one subaction path and...
Definition: oxr_objects.h:2125
struct oxr_action_ref * act_ref
This action's refcounted data.
Definition: oxr_objects.h:2106
struct oxr_action_set_attachment * act_set_attached
The owning action set attachment.
Definition: oxr_objects.h:2103
uint32_t act_key
Unique key for the session hashmap.
Definition: oxr_objects.h:2117
struct oxr_session * sess
The corresponding session.
Definition: oxr_objects.h:2114
The set of inputs/outputs for a single sub-action path for an action.
Definition: oxr_objects.h:2079
A input action pair of a xrt_input and a xrt_device, along with the required transform.
Definition: oxr_objects.h:2040
A output action pair of a xrt_output_name and a xrt_device.
Definition: oxr_objects.h:2059
The reference-counted data of an action.
Definition: oxr_objects.h:2392
char name[XR_MAX_ACTION_NAME_SIZE]
Application supplied name of this action.
Definition: oxr_objects.h:2396
struct oxr_subaction_paths subaction_paths
Which sub action paths that this action was created with.
Definition: oxr_objects.h:2405
XrActionType action_type
Type this action was created with.
Definition: oxr_objects.h:2402
uint32_t act_key
Unique key for the session hashmap.
Definition: oxr_objects.h:2399
The data associated with the attachment of an Action Set (oxr_action_set) to as Session (oxr_session)...
Definition: oxr_objects.h:1972
struct oxr_action_attachment * act_attachments
An array of action attachments we own.
Definition: oxr_objects.h:1986
struct oxr_session * sess
Owning session.
Definition: oxr_objects.h:1974
struct oxr_action_set_ref * act_set_ref
Action set refcounted data.
Definition: oxr_objects.h:1977
uint32_t act_set_key
Unique key for the session hashmap.
Definition: oxr_objects.h:1980
size_t action_attachment_count
Length of oxr_action_set_attachment::act_attachments.
Definition: oxr_objects.h:1991
struct oxr_subaction_paths requested_subaction_paths
Which sub-action paths are requested on the latest sync.
Definition: oxr_objects.h:1983
The reference-counted data of an action set.
Definition: oxr_objects.h:2310
uint32_t act_set_key
Unique key for the session hashmap.
Definition: oxr_objects.h:2323
char name[XR_MAX_ACTION_SET_NAME_SIZE]
Application supplied name of this action.
Definition: oxr_objects.h:2314
bool ever_attached
Has this action set even been attached to any session, marking it as immutable.
Definition: oxr_objects.h:2320
uint32_t priority
Application supplied action set priority.
Definition: oxr_objects.h:2326
A group of actions.
Definition: oxr_objects.h:2352
struct u_hashset_item * name_item
The item in the name hashset.
Definition: oxr_objects.h:2374
struct u_hashset_item * loc_item
The item in the localized hashset.
Definition: oxr_objects.h:2377
struct oxr_action_set_ref * data
The data for this action set that must live as long as any session we are attached to.
Definition: oxr_objects.h:2363
uint32_t act_set_key
Unique key for the session hashmap.
Definition: oxr_objects.h:2371
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2354
struct oxr_instance * inst
Owner of this action set.
Definition: oxr_objects.h:2357
The state of a action input.
Definition: oxr_objects.h:2014
bool active
Is this active (bound and providing input)?
Definition: oxr_objects.h:2021
XrTime timestamp
When was this last changed.
Definition: oxr_objects.h:2027
A single action.
Definition: oxr_objects.h:2422
struct oxr_action_set * act_set
Owner of this action.
Definition: oxr_objects.h:2427
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2424
struct u_hashset_item * loc_item
The item in the localized hashset.
Definition: oxr_objects.h:2444
uint32_t act_key
Unique key for the session hashmap.
Definition: oxr_objects.h:2438
struct u_hashset_item * name_item
The item in the name hashset.
Definition: oxr_objects.h:2441
struct oxr_action_ref * data
The data for this action that must live as long as any session we are attached to.
Definition: oxr_objects.h:2431
Interaction profile binding state.
Definition: oxr_objects.h:1880
uint32_t * preferred_binding_path_index
store which entry in paths was suggested, for each action key
Definition: oxr_objects.h:1892
const char * localized_name
Name presented to the user.
Definition: oxr_objects.h:1885
Debug object created by the client program.
Definition: oxr_objects.h:2455
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2457
XrDebugUtilsMessageTypeFlagsEXT message_types
Types to submit to this messenger.
Definition: oxr_objects.h:2466
PFN_xrDebugUtilsMessengerCallbackEXT user_callback
Callback function.
Definition: oxr_objects.h:2469
struct oxr_instance * inst
Owner of this messenger.
Definition: oxr_objects.h:2460
void *XR_MAY_ALIAS user_data
Opaque user data.
Definition: oxr_objects.h:2472
XrDebugUtilsMessageSeverityFlagsEXT message_severities
Severities to submit to this messenger.
Definition: oxr_objects.h:2463
dpad binding extracted from XrInteractionProfileDpadBindingEXT
Definition: oxr_objects.h:1812
dpad emulation settings from oxr_interaction_profile
Definition: oxr_objects.h:1846
A entry in the dpad state for one action set.
Definition: oxr_objects.h:1823
dpad settings we need extracted from XrInteractionProfileDpadBindingEXT
Definition: oxr_objects.h:1800
Holds dpad binding state for a single interaction profile.
Definition: oxr_objects.h:1838
Definition: oxr_event.c:30
Structure tracking which extensions are enabled for a given instance.
Definition: oxr_objects.h:1491
HTC specific Facial tracker.
Definition: oxr_objects.h:2576
struct oxr_session * sess
Owner of this face tracker.
Definition: oxr_objects.h:2581
struct xrt_device * xdev
xrt_device backing this face tracker
Definition: oxr_objects.h:2584
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2578
enum xrt_facial_tracking_type_htc facial_tracking_type
Type of facial tracking, eyes or lips.
Definition: oxr_objects.h:2587
A hand tracker.
Definition: oxr_objects.h:2485
enum xrt_input_name input_name
the input name associated with this hand tracker
Definition: oxr_objects.h:2496
struct xrt_device * xdev
xrt_device backing this hand tracker
Definition: oxr_objects.h:2493
struct oxr_session * sess
Owner of this hand tracker.
Definition: oxr_objects.h:2490
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2487
Used to hold diverse child handles and ensure orderly destruction.
Definition: oxr_objects.h:1306
struct oxr_handle_base * parent
Pointer to this object's parent handle holder, if any.
Definition: oxr_objects.h:1313
uint64_t debug
Magic (per-handle-type) value for debugging.
Definition: oxr_objects.h:1308
struct oxr_handle_base * children[256]
Array of children, if any.
Definition: oxr_objects.h:1318
enum oxr_handle_state state
Current handle state.
Definition: oxr_objects.h:1323
oxr_handle_destroyer destroy
Destroy the object this handle refers to.
Definition: oxr_objects.h:1328
Variant type for input transforms.
Definition: oxr_input_transform.h:144
Main object that ties everything together.
Definition: oxr_objects.h:1504
size_t path_num
Number of paths in the array (0 is always null).
Definition: oxr_objects.h:1533
bool disable_vulkan_format_depth_stencil
Unreal has a bug in the VulkanRHI backend.
Definition: oxr_objects.h:1592
bool skip_end_session
Unreal 4 has a bug calling xrEndSession; the function should just exit.
Definition: oxr_objects.h:1594
struct oxr_path ** path_array
Mapping from ID to path.
Definition: oxr_objects.h:1529
bool no_validation_error_in_create_ref_space
Return XR_ERROR_REFERENCE_SPACE_UNSUPPORTED instead of XR_ERROR_VALIDATION_FAILURE in xrCreateReferen...
Definition: oxr_objects.h:1600
size_t path_array_length
Total length of path array.
Definition: oxr_objects.h:1531
struct oxr_extension_status extensions
Enabled extensions.
Definition: oxr_objects.h:1513
struct oxr_debug_messenger * messengers[256]
Debug messengers.
Definition: oxr_objects.h:1604
struct u_hashset * path_store
Path store, for looking up paths.
Definition: oxr_objects.h:1527
struct oxr_interaction_profile ** profiles
Interaction profile bindings that have been suggested by the client.
Definition: oxr_objects.h:1544
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:1506
A single interaction profile.
Definition: oxr_objects.h:1858
enum xrt_device_name xname
Used to lookup xrt_binding_profile for fallback.
Definition: oxr_objects.h:1862
const char * localized_name
Name presented to the user.
Definition: oxr_objects.h:1865
Logger struct that lives on the stack, one for each call client call.
Definition: oxr_logger.h:40
Internal representation of a path, item follows this struct in memory and that in turn is followed by...
Definition: oxr_path.c:28
Definition: oxr_objects.h:2272
void(* destroy)(struct oxr_refcounted *)
Destruction callback.
Definition: oxr_objects.h:2275
Object that client program interact with.
Definition: oxr_objects.h:1625
struct u_hashmap_int * act_attachments_by_key
A map of action key to action attachment.
Definition: oxr_objects.h:1707
XrResult(* create_swapchain)(struct oxr_logger *, struct oxr_session *sess, const XrSwapchainCreateInfo *, struct oxr_swapchain **)
To pipe swapchain creation to right code.
Definition: oxr_objects.h:1744
struct xrt_compositor_native * xcn
Native compositor that is wrapped by client compositors.
Definition: oxr_objects.h:1637
struct xrt_space_relation local_space_pure_relation
initial relation of head in "global" space.
Definition: oxr_objects.h:1751
struct xrt_session * xs
The xrt_session backing this session.
Definition: oxr_objects.h:1634
struct oxr_action_set_attachment * act_set_attachments
An array of action set attachments that this session owns.
Definition: oxr_objects.h:1681
uint32_t frame_timing_wait_sleep_ms
Extra sleep in wait frame.
Definition: oxr_objects.h:1739
struct os_precise_sleeper sleeper
Used to implement precise extra sleeping in wait frame.
Definition: oxr_objects.h:1673
enum oxr_session_graphics_ext gfx_ext
What graphics type was this session created with.
Definition: oxr_objects.h:1631
size_t profiles_on_attachment_size
Clone of all suggested binding profiles at the point of action set/session attachment.
Definition: oxr_objects.h:1713
bool has_ended_once
There is a extra state between xrBeginSession has been called and the first xrEndFrame has been calle...
Definition: oxr_objects.h:1649
struct u_hashmap_int * act_sets_attachments_by_key
A map of action set key to action set attachments.
Definition: oxr_objects.h:1695
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:1627
float ipd_meters
IPD, to be expanded to a proper 3D relation.
Definition: oxr_objects.h:1731
size_t action_set_attachment_count
Length of oxr_session::act_set_attachments.
Definition: oxr_objects.h:1686
bool frame_timing_spew
Frame timing debug output.
Definition: oxr_objects.h:1736
Can be one of several reference space types, or a space that is bound to an action.
Definition: oxr_objects.h:2172
struct oxr_subaction_paths subaction_paths
Which sub action path is this?
Definition: oxr_objects.h:2189
enum oxr_space_type space_type
What kind of space is this?
Definition: oxr_objects.h:2186
uint32_t act_key
Action key from which action this space was created from.
Definition: oxr_objects.h:2183
struct xrt_pose pose
Pose that was given during creation.
Definition: oxr_objects.h:2180
struct oxr_session * sess
Owner of this space.
Definition: oxr_objects.h:2177
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2174
A parsed equivalent of a list of sub-action paths.
Definition: oxr_objects.h:1935
A set of images used for rendering.
Definition: oxr_objects.h:2208
struct oxr_session * sess
Owner of this swapchain.
Definition: oxr_objects.h:2213
uint32_t face_count
The number of cubemap faces. 6 for cubemaps, 1 otherwise.
Definition: oxr_objects.h:2225
struct xrt_swapchain * swapchain
Compositor swapchain.
Definition: oxr_objects.h:2216
struct oxr_handle_base handle
Common structure for things referred to by OpenXR handles.
Definition: oxr_objects.h:2210
uint32_t width
Swapchain size.
Definition: oxr_objects.h:2219
uint32_t array_layer_count
For 1 is 2D texture, greater then 1 2D array texture.
Definition: oxr_objects.h:2222
Single or multiple devices grouped together to form a system that sessions can be created from.
Definition: oxr_objects.h:1343
struct xrt_system * xsys
The XRT interfaces level system.
Definition: oxr_objects.h:1347
VkPhysicalDevice suggested_vulkan_physical_device
The device returned with the last xrGetVulkanGraphicsDeviceKHR or xrGetVulkanGraphicsDevice2KHR call.
Definition: oxr_objects.h:1383
struct xrt_system_devices * xsysd
System devices used in all session types.
Definition: oxr_objects.h:1350
struct xrt_space_overseer * xso
Space overseer used in all session types.
Definition: oxr_objects.h:1353
VkInstance vulkan_enable2_instance
The instance/device we create when vulkan_enable2 is used.
Definition: oxr_objects.h:1380
bool gotten_requirements
Have the client application called the gfx api requirements func?
Definition: oxr_objects.h:1361
struct xrt_system_compositor * xsysc
System compositor, used to create session compositors.
Definition: oxr_objects.h:1356
struct xrt_system_roles dynamic_roles_cache
Cache of the last known system roles, see xrt_system_roles::generation_id.
Definition: oxr_objects.h:1373
Time-keeping state structure.
Definition: u_time.cpp:30
A simple uint64_t key to a void pointer hashmap.
Definition: u_hashmap.cpp:24
A embeddable hashset item, note that the string directly follows the u_hashset_item.
Definition: u_hashset.h:37
Kind of bespoke hashset implementation, where the user is responsible for allocating and freeing the ...
Definition: u_hashset.cpp:26
Definition: u_index_fifo.h:21
Main compositor server interface.
Definition: xrt_compositor.h:2196
Common compositor client interface/base.
Definition: xrt_compositor.h:986
A single HMD or input device.
Definition: xrt_device.h:230
enum xrt_device_name name
Enum identifier of the device.
Definition: xrt_device.h:232
Joint set type used for hand tracking.
Definition: xrt_defines.h:1233
A single named input, that sits on a xrt_device.
Definition: xrt_device.h:161
This interface acts as a root object for Monado.
Definition: xrt_instance.h:67
A single named output, that sits on a xrt_device.
Definition: xrt_device.h:178
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
A base class for reference counted objects.
Definition: xrt_defines.h:96
The XRT representation of XrSession, this object does not have all of the functionality of a session,...
Definition: xrt_session.h:233
Object that oversees and manages spaces, one created for each XR system.
Definition: xrt_space.h:95
A relation with two spaces, includes velocity and acceleration.
Definition: xrt_defines.h:657
A space very similar to a OpenXR XrSpace but not a full one-to-one mapping, but used to power XrSpace...
Definition: xrt_space.h:30
Common swapchain interface/base.
Definition: xrt_compositor.h:536
The system compositor handles composition for a system.
Definition: xrt_compositor.h:2386
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition: xrt_system.h:218
struct xrt_system_devices::@235::@236 hand_tracking
Devices providing optical (or otherwise more directly measured than from controller estimation) hand ...
struct xrt_device * head
An observing pointer to the device serving as the "head" (and HMD).
Definition: xrt_system.h:247
struct xrt_device * face
An observing pointer to the device providing face tracking (optional).
Definition: xrt_system.h:259
struct xrt_device * eyes
An observing pointer to the device providing eye tracking (optional).
Definition: xrt_system.h:253
struct xrt_system_devices::@235 static_roles
Observing pointers for devices in some static (unchangeable) roles.
Data associating a device index (in xrt_system_devices::xdevs) with a given "role" for dynamic role s...
Definition: xrt_system.h:160
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition: xrt_system.h:61
Visibility mask helper, the indices and vertices are tightly packed after this struct.
Definition: xrt_visibility_mask.h:25
Misc helpers for device drivers.
Hashmap for integer values header.
Hashset struct header.
A FIFO for indices.
A union of all input types.
Definition: xrt_defines.h:1249
Header declaring XRT graphics interfaces.
Auto detect OS and certain features.
xrt_perf_notify_level
Performance level.
Definition: xrt_defines.h:1529
xrt_device_name
A enum that is used to name devices so that the state trackers can reason about the devices easier.
Definition: xrt_defines.h:712
xrt_perf_domain
Domain type.
Definition: xrt_defines.h:1502
Header defining an xrt display or controller device.
Header for limits of the XRT interfaces.
Include all of the openxr headers in one place.
Header defining xrt space and space overseer.
Header for system objects.
Header defining the tracking system integration in Monado.
Include all of the Vulkan headers in one place, and cope with any "messy" includes implied by it.