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