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_io_cache.h"
19#include "oxr_subaction.h"
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
30struct oxr_logger;
31
32
33/*
34 *
35 * Helper macros
36 *
37 */
38
39/*!
40 * Helper macro to check if action sets are attached to a session.
41 *
42 * Returns XR_ERROR_ACTIONSET_NOT_ATTACHED if action sets have not been attached.
43 *
44 * @param SESS Session pointer
45 * @param LOG Logger pointer
46 * @ingroup oxr_main
47 */
48#define OXR_SESSION_CHECK_ATTACHED_AND_RET(SESS, LOG) \
49 do { \
50 if (!oxr_session_action_context_has_attached_act_sets(&(SESS)->action_context)) { \
51 return oxr_error(LOG, XR_ERROR_ACTIONSET_NOT_ATTACHED, \
52 "ActionSet(s) have not been attached to this session"); \
53 } \
54 } while (false)
55
56
57/*
58 *
59 * Structs
60 *
61 */
62
63/*!
64 * This holds all of the action state that belongs on the session level.
65 *
66 * Future extensions might enable multiple action contexts per session.
67 */
69{
70 /*
71 * Action Set fields
72 */
73
74 /*!
75 * A map of action set key to action set attachments.
76 *
77 * If non-null, this means action sets have been attached to this
78 * session, since this map points to elements of
79 * oxr_session_action_context::act_set_attachments
80 */
82
83 /*!
84 * An array of action set attachments that this session owns.
85 *
86 * If non-null, this means action sets have been attached to this
87 * session.
88 */
90
91 /*!
92 * Length of @ref oxr_session_action_context::act_set_attachments.
93 */
95
96
97 /*
98 * Interaction Profiles fields
99 */
100
101 /*!
102 * Clone of suggested binding profiles at action set/session attachment, this
103 * is mandated by the OpenXR specification. It says that the suggested binding
104 * profiles should be snapshotted when action sets are attached to the session.
105 *
106 * @ref oxr_session_attach_action_sets
107 */
109
110 /*!
111 * Binding registry used to resolve this session action context.
112 */
114
115 //! Cache of the last known system roles generation_id
117
118 //! Protects access to dynamic_roles_generation_id during sync actions
120
121 struct oxr_priority_group_cache priority_group_cache;
122
123 struct oxr_io_cache io_cache;
124
125 /*!
126 * Currently bound interaction profile.
127 * @{
128 */
129
130#define OXR_PATH_MEMBER(X) XrPath X;
131
133#undef OXR_PATH_MEMBER
134 /*!
135 * @}
136 */
137};
138
139
140/*
141 *
142 * Functions
143 *
144 */
145
146/*!
147 * Initialize the action context for a session.
148 *
149 * @public @memberof oxr_session_action_context
150 */
151XRT_CHECK_RESULT XrResult
152oxr_session_action_context_init(struct oxr_session_action_context *action_context,
153 struct xrt_system_devices *xsysd,
154 struct xrt_space_overseer *xso);
155
156/*!
157 * Finalize and cleanup the action context for a session.
158 *
159 * Safe to call after a failed @ref oxr_session_action_context_init; only resources
160 * that init successfully created are torn down.
161 *
162 * @public @memberof oxr_session_action_context
163 */
164XRT_NONNULL_ALL void
165oxr_session_action_context_fini(struct oxr_session_action_context *action_context);
166
167/*!
168 * Check if action sets have been attached to the action context.
169 *
170 * @return true if action sets are attached, false otherwise
171 * @public @memberof oxr_session_action_context
172 */
173XRT_NONNULL_ALL bool
174oxr_session_action_context_has_attached_act_sets(const struct oxr_session_action_context *action_context);
175
176/*!
177 * Helper to find action set attachment.
178 *
179 * @return true if the action set was found, false otherwise
180 * @public @memberof oxr_session_action_context
181 */
182XRT_NONNULL_ALL bool
183oxr_session_action_context_find_set(struct oxr_session_action_context *action_context,
184 uint32_t act_set_key,
185 struct oxr_action_set_attachment **out_act_set_attached);
186
187
188#ifdef __cplusplus
189}
190#endif
Wrapper around OS threading native functions.
Forward declarations for OpenXR state tracker structs.
Per-session snapshot wrapper around xrt_io_cache.
Cache of per-session priority group state.
#define OXR_PATH_MEMBER(X)
Currently bound interaction profile.
Definition oxr_session_action_context.h:130
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
Holds suggested profile array related functions.
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:1511
Complete runtime binding registry for all action contexts of an XrInstance.
Definition oxr_binding_registry.h:35
Per session-action-context snapshot of all device inputs and outputs, wrapping an xrt_io_cache.
Definition oxr_io_cache.h:45
Logger struct that lives on the stack, one for each call client call.
Definition oxr_logger.h:44
Per-session cache of priority group states.
Definition oxr_priority_group_cache.h:48
This holds all of the action state that belongs on the session level.
Definition oxr_session_action_context.h:69
struct oxr_suggested_profile_array profiles_on_attachment
Clone of suggested binding profiles at action set/session attachment, this is mandated by the OpenXR ...
Definition oxr_session_action_context.h:108
struct oxr_binding_registry * binding_registry
Binding registry used to resolve this session action context.
Definition oxr_session_action_context.h:113
struct os_mutex sync_actions_mutex
Protects access to dynamic_roles_generation_id during sync actions.
Definition oxr_session_action_context.h:119
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:81
uint64_t dynamic_roles_generation_id
Cache of the last known system roles generation_id.
Definition oxr_session_action_context.h:116
size_t action_set_attachment_count
Length of oxr_session_action_context::act_set_attachments.
Definition oxr_session_action_context.h:94
struct oxr_action_set_attachment * act_set_attachments
An array of action set attachments that this session owns.
Definition oxr_session_action_context.h:89
Manages an array of suggested profiles, does not have a init function but must be zero initialized wh...
Definition oxr_suggested_profile_array.h:30
A simple uint64_t key to a void pointer hashmap.
Definition u_hashmap.cpp:24
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition xrt_system.h:218