Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_session_action_context.h
Go to the documentation of this file.
1// Copyright 2018-2024, Collabora, Ltd.
2// Copyright 2023-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Holds per session action context.
7 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @ingroup oxr_main
9 */
10
11#pragma once
12
13#include "os/os_threading.h"
14
16#include "oxr_extension_support.h"
17#include "oxr_subaction.h"
19
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/*
27 *
28 * Helper macros
29 *
30 */
31
32/*!
33 * Helper macro to check if action sets are attached to a session.
34 *
35 * Returns XR_ERROR_ACTIONSET_NOT_ATTACHED if action sets have not been attached.
36 *
37 * @param SESS Session pointer
38 * @param LOG Logger pointer
39 * @ingroup oxr_main
40 */
41#define OXR_SESSION_CHECK_ATTACHED_AND_RET(SESS, LOG) \
42 do { \
43 if (!oxr_session_action_context_has_attached_act_sets(&(SESS)->action_context)) { \
44 return oxr_error(LOG, XR_ERROR_ACTIONSET_NOT_ATTACHED, \
45 "ActionSet(s) have not been attached to this session"); \
46 } \
47 } while (false)
48
49
50/*
51 *
52 * Structs
53 *
54 */
55
56/*!
57 * This holds all of the action state that belongs on the session level.
58 *
59 * Future extensions might enable multiple action contexts per session.
60 */
62{
63 /*
64 * Action Set fields
65 */
66
67 /*!
68 * A map of action set key to action set attachments.
69 *
70 * If non-null, this means action sets have been attached to this
71 * session, since this map points to elements of
72 * oxr_session_action_context::act_set_attachments
73 */
75
76 /*!
77 * An array of action set attachments that this session owns.
78 *
79 * If non-null, this means action sets have been attached to this
80 * session.
81 */
83
84 /*!
85 * Length of @ref oxr_session_action_context::act_set_attachments.
86 */
88
89
90 /*
91 * Interaction Profiles fields
92 */
93
94 /*!
95 * Clone of all suggested binding profiles at the point of action set/session attachment.
96 * @ref oxr_session_attach_action_sets
97 */
99
100 //! Cache of the last known system roles generation_id
102
103 //! Protects access to dynamic_roles_generation_id during sync actions
105
106 /*!
107 * Currently bound interaction profile.
108 * @{
109 */
110
111#define OXR_PATH_MEMBER(X) XrPath X;
112
114#undef OXR_PATH_MEMBER
115 /*!
116 * @}
117 */
118};
119
120
121/*
122 *
123 * Functions
124 *
125 */
126
127/*!
128 * Initialize the action context for a session.
129 *
130 * @public @memberof oxr_session_action_context
131 */
132XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult
133oxr_session_action_context_init(struct oxr_session_action_context *action_context);
134
135/*!
136 * Finalize and cleanup the action context for a session.
137 *
138 * @public @memberof oxr_session_action_context
139 */
140XRT_NONNULL_ALL void
141oxr_session_action_context_fini(struct oxr_session_action_context *action_context);
142
143/*!
144 * Check if action sets have been attached to the action context.
145 *
146 * @return true if action sets are attached, false otherwise
147 * @public @memberof oxr_session_action_context
148 */
149XRT_NONNULL_ALL bool
150oxr_session_action_context_has_attached_act_sets(const struct oxr_session_action_context *action_context);
151
152/*!
153 * Helper to find action set attachment.
154 *
155 * @return true if the action set was found, false otherwise
156 * @public @memberof oxr_session_action_context
157 */
158XRT_NONNULL_ALL bool
159oxr_session_action_context_find_set(struct oxr_session_action_context *action_context,
160 uint32_t act_set_key,
161 struct oxr_action_set_attachment **out_act_set_attached);
162
163
164#ifdef __cplusplus
165}
166#endif
Wrapper around OS threading native functions.
Forward declarations for OpenXR state tracker structs.
Holds interaction profile array related functions.
#define OXR_PATH_MEMBER(X)
Currently bound interaction profile.
Definition oxr_session_action_context.h:111
Provides a utility macro for dealing with subaction paths.
#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:28
A wrapper around a native mutex.
Definition os_threading.h:69
The data associated with the attachment of an Action Set (oxr_action_set) to as Session (oxr_session)...
Definition oxr_objects.h:1588
Manages an array of interaction profiles, does not have a init function but must be zero initialized ...
Definition oxr_interaction_profile_array.h:29
This holds all of the action state that belongs on the session level.
Definition oxr_session_action_context.h:62
struct os_mutex sync_actions_mutex
Protects access to dynamic_roles_generation_id during sync actions.
Definition oxr_session_action_context.h:104
struct oxr_interaction_profile_array profiles_on_attachment
Clone of all suggested binding profiles at the point of action set/session attachment.
Definition oxr_session_action_context.h:98
struct u_hashmap_int * act_sets_attachments_by_key
A map of action set key to action set attachments.
Definition oxr_session_action_context.h:74
uint64_t dynamic_roles_generation_id
Cache of the last known system roles generation_id.
Definition oxr_session_action_context.h:101
size_t action_set_attachment_count
Length of oxr_session_action_context::act_set_attachments.
Definition oxr_session_action_context.h:87
struct oxr_action_set_attachment * act_set_attachments
An array of action set attachments that this session owns.
Definition oxr_session_action_context.h:82
A simple uint64_t key to a void pointer hashmap.
Definition u_hashmap.cpp:24