Monado OpenXR Runtime
Loading...
Searching...
No Matches
ipc_server_objects.h
Go to the documentation of this file.
1// Copyright 2025-2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Tracking objects to IDs.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup ipc_server
8 */
9
10#pragma once
11
12#include "xrt/xrt_results.h"
13
14struct xrt_space;
15struct xrt_body_tracker;
16struct xrt_hand_tracker;
17struct xrt_io_cache;
18struct ipc_client_state;
19
20
21/*
22 *
23 * Device functions.
24 *
25 */
26
27/*!
28 * Get a device by its per-client-connection slot index.
29 *
30 * The @p id is a @c uint32_t index into @c ics->objects.xdevs used for IPC
31 * message lookups. It is not @ref xrt_device::id.
32 *
33 * Must only be called from the per client thread as this function accesses the
34 * client state's memory.
35 *
36 * @param ics The client state instance.
37 * @param id The per-client slot index.
38 * @param out_xdev Will be filled with the device object on success.
39 * @return XRT_SUCCESS on success, some other result on failure.
40 *
41 * @ingroup ipc_server
42 */
45 uint32_t id,
46 struct xrt_device **out_xdev);
47
48/*!
49 * Get or allocate a per-client-connection slot index for a device object.
50 *
51 * The returned @c uint32_t is used in IPC messages to look up @p xdev on the
52 * server. It is not @ref xrt_device::id, which is assigned at device creation
53 * and synchronized to clients via @ref ipc_device_info.
54 *
55 * Must only be called from the per client thread as this function accesses the
56 * client state's memory.
57 *
58 * @param ics The client state instance.
59 * @param xdev The device object.
60 * @param out_id Will be filled with the slot index on success.
61 * @return XRT_SUCCESS on success, some other result on failure.
62 *
63 * @ingroup ipc_server
64 */
66ipc_server_objects_get_xdev_id_or_add(volatile struct ipc_client_state *ics, struct xrt_device *xdev, uint32_t *out_id);
67
68
69/*
70 *
71 * Tracking origin functions.
72 *
73 */
74
75/*!
76 * Get a tracking origin by ID, must only be called from the per client
77 * thread as this function accesses the client state's memory.
78 *
79 * @param ics The client state instance.
80 * @param id The tracking origin ID.
81 * @param out_xtrack Will be filled with the tracking origin object on success.
82 * @return XRT_SUCCESS on success, some other result on failure.
83 *
84 * @ingroup ipc_server
85 */
88 uint32_t id,
89 struct xrt_tracking_origin **out_xtrack);
90
91/*!
92 * Get a tracking origin ID for a given tracking origin object, must only be
93 * called from the per client thread as this function accesses the client
94 * state's memory.
95 *
96 * @param ics The client state instance.
97 * @param xtrack The tracking origin object.
98 * @param out_id Will be filled with the tracking origin ID on success.
99 * @return XRT_SUCCESS on success, some other result on failure.
100 *
101 * @ingroup ipc_server
102 */
105 struct xrt_tracking_origin *xtrack,
106 uint32_t *out_id);
107
108
109/*
110 *
111 * Space functions.
112 *
113 */
114
115/*!
116 * Get a space by ID, must only be called from the per client thread.
117 *
118 * @ingroup ipc_server
119 */
122 uint32_t id,
123 struct xrt_space **out_xspc);
124
125/*!
126 * Track a space and return its ID. Grabs and stores a reference if newly
127 * tracked.
128 *
129 * @ingroup ipc_server
130 */
132ipc_server_objects_get_xspc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_space *xspc, uint32_t *out_id);
133
134/*!
135 * Destroy a tracked space.
136 *
137 * @ingroup ipc_server
138 */
140ipc_server_objects_destroy_xspc(volatile struct ipc_client_state *ics, uint32_t id);
141
142
143/*
144 *
145 * Body tracker functions.
146 *
147 */
148
149/*!
150 * Get a body tracker by ID, must only be called from the per client thread.
151 *
152 * @ingroup ipc_server
153 */
156 uint32_t id,
157 struct xrt_body_tracker **out_xbt);
158
159/*!
160 * Track a newly created body tracker and return its ID. Takes ownership of
161 * @p xbt until explicit destroy or client disconnect.
162 *
163 * @ingroup ipc_server
164 */
167 struct xrt_body_tracker *xbt,
168 uint32_t *out_id);
169
170/*!
171 * Destroy a tracked body tracker.
172 *
173 * @ingroup ipc_server
174 */
176ipc_server_objects_destroy_xbt(volatile struct ipc_client_state *ics, uint32_t id);
177
178
179/*
180 *
181 * Hand tracker functions.
182 *
183 */
184
185/*!
186 * Get a hand tracker by ID, must only be called from the per client thread.
187 *
188 * @ingroup ipc_server
189 */
192 uint32_t id,
193 struct xrt_hand_tracker **out_xht);
194
195/*!
196 * Track a newly created hand tracker and return its ID. Takes ownership of
197 * @p xht until explicit destroy or client disconnect.
198 *
199 * @ingroup ipc_server
200 */
203 struct xrt_hand_tracker *xht,
204 uint32_t *out_id);
205
206/*!
207 * Destroy a tracked hand tracker.
208 *
209 * @ingroup ipc_server
210 */
212ipc_server_objects_destroy_xht(volatile struct ipc_client_state *ics, uint32_t id);
213
214
215/*
216 *
217 * App policy functions.
218 *
219 */
220
222ipc_server_objects_get_xainst_and_validate(volatile struct ipc_client_state *ics,
223 uint32_t id,
224 struct xrt_app_instance **out_xainst);
225
227ipc_server_objects_get_xainst_id_or_add(volatile struct ipc_client_state *ics,
228 struct xrt_app_instance *xainst,
229 uint32_t *out_id);
230
232ipc_server_objects_destroy_xainst(volatile struct ipc_client_state *ics, uint32_t id);
233
235ipc_server_objects_get_xasys_and_validate(volatile struct ipc_client_state *ics,
236 uint32_t id,
237 struct xrt_app_system **out_xasys);
238
240ipc_server_objects_get_xasys_id_or_add(volatile struct ipc_client_state *ics,
241 struct xrt_app_system *xasys,
242 uint32_t *out_id);
243
245ipc_server_objects_destroy_xasys(volatile struct ipc_client_state *ics, uint32_t id);
246
247
248/*
249 *
250 * Input/output cache functions.
251 *
252 */
253
254/*!
255 * Get an input/output cache by ID, must only be called from the per client thread.
256 *
257 * @ingroup ipc_server
258 */
261 uint32_t id,
262 struct xrt_io_cache **out_xic);
263
264/*!
265 * Track a newly created input/output cache and return its ID. Takes ownership of
266 * @p xic until explicit destroy or client disconnect.
267 *
268 * @ingroup ipc_server
269 */
271ipc_server_objects_get_xic_id_or_add(volatile struct ipc_client_state *ics, struct xrt_io_cache *xic, uint32_t *out_id);
272
273/*!
274 * Destroy a tracked input/output cache.
275 *
276 * @ingroup ipc_server
277 */
279ipc_server_objects_destroy_xic(volatile struct ipc_client_state *ics, uint32_t id);
xrt_result_t ipc_server_objects_get_xic_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_io_cache **out_xic)
Get an input/output cache by ID, must only be called from the per client thread.
Definition ipc_server_objects.c:489
xrt_result_t ipc_server_objects_destroy_xspc(volatile struct ipc_client_state *ics, uint32_t id)
Destroy a tracked space.
Definition ipc_server_objects.c:206
xrt_result_t ipc_server_objects_get_xspc_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_space **out_xspc)
Get a space by ID, must only be called from the per client thread.
Definition ipc_server_objects.c:157
xrt_result_t ipc_server_objects_destroy_xbt(volatile struct ipc_client_state *ics, uint32_t id)
Destroy a tracked body tracker.
Definition ipc_server_objects.c:273
xrt_result_t ipc_server_objects_get_xic_id_or_add(volatile struct ipc_client_state *ics, struct xrt_io_cache *xic, uint32_t *out_id)
Track a newly created input/output cache and return its ID.
Definition ipc_server_objects.c:510
xrt_result_t ipc_server_objects_get_xdev_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_device **out_xdev)
Get a device by its per-client-connection slot index.
Definition ipc_server_objects.c:32
xrt_result_t ipc_server_objects_get_xht_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_hand_tracker **out_xht)
Get a hand tracker by ID, must only be called from the per client thread.
Definition ipc_server_objects.c:298
xrt_result_t ipc_server_objects_get_xspc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_space *xspc, uint32_t *out_id)
Track a space and return its ID.
Definition ipc_server_objects.c:178
xrt_result_t ipc_server_objects_destroy_xic(volatile struct ipc_client_state *ics, uint32_t id)
Destroy a tracked input/output cache.
Definition ipc_server_objects.c:528
xrt_result_t ipc_server_objects_get_xht_id_or_add(volatile struct ipc_client_state *ics, struct xrt_hand_tracker *xht, uint32_t *out_id)
Track a newly created hand tracker and return its ID.
Definition ipc_server_objects.c:319
xrt_result_t ipc_server_objects_get_xdev_id_or_add(volatile struct ipc_client_state *ics, struct xrt_device *xdev, uint32_t *out_id)
Get or allocate a per-client-connection slot index for a device object.
Definition ipc_server_objects.c:53
xrt_result_t ipc_server_objects_get_xbt_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_body_tracker **out_xbt)
Get a body tracker by ID, must only be called from the per client thread.
Definition ipc_server_objects.c:232
xrt_result_t ipc_server_objects_get_xtrack_and_validate(volatile struct ipc_client_state *ics, uint32_t id, struct xrt_tracking_origin **out_xtrack)
Get a tracking origin by ID, must only be called from the per client thread as this function accesses...
Definition ipc_server_objects.c:100
xrt_result_t ipc_server_objects_get_xbt_id_or_add(volatile struct ipc_client_state *ics, struct xrt_body_tracker *xbt, uint32_t *out_id)
Track a newly created body tracker and return its ID.
Definition ipc_server_objects.c:253
xrt_result_t ipc_server_objects_destroy_xht(volatile struct ipc_client_state *ics, uint32_t id)
Destroy a tracked hand tracker.
Definition ipc_server_objects.c:339
xrt_result_t ipc_server_objects_get_xtrack_id_or_add(volatile struct ipc_client_state *ics, struct xrt_tracking_origin *xtrack, uint32_t *out_id)
Get a tracking origin ID for a given tracking origin object, must only be called from the per client ...
Definition ipc_server_objects.c:121
enum xrt_result xrt_result_t
Result type used across Monado.
Holds the state for a single client.
Definition ipc_server.h:102
struct xrt_app_system * xasys[(4 *4)]
Array of app systems owned by this client.
Definition ipc_server.h:147
This interface acts as a way to store per-application policy for xrt_instance.
Definition xrt_app_policy.h:36
This interface acts as a way to store per-application policy for xrt_system.
Definition xrt_app_policy.h:194
A body tracker, owns the policy for selecting which device and body-tracking source back a single Ope...
Definition xrt_body_tracker.h:102
A single HMD or input device.
Definition xrt_device.h:328
A hand tracker that owns device/source selection policy.
Definition xrt_hand_tracker.h:76
A cache of flattened device inputs and outputs.
Definition xrt_io_cache.h:116
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:32
A tracking system or device origin.
Definition xrt_tracking.h:87
Internal result type for XRT.