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