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 its IPC ID, must only be called from the per client
77 * thread as this function accesses the client state's memory.
78 *
79 * The IPC ID is a per-client-connection index into @c ics->objects.xtracks used
80 * in IPC messages, it is not @ref xrt_tracking_origin::id.
81 *
82 * @param ics The client state instance.
83 * @param ipc_id The tracking origin IPC ID.
84 * @param out_xtrack Will be filled with the tracking origin object on success.
85 * @return XRT_SUCCESS on success, some other result on failure.
86 *
87 * @ingroup ipc_server
88 */
91 uint32_t ipc_id,
92 struct xrt_tracking_origin **out_xtrack);
93
94/*!
95 * Get or allocate the IPC ID for a given tracking origin object, must only be
96 * called from the per client thread as this function accesses the client
97 * state's memory.
98 *
99 * @param ics The client state instance.
100 * @param xtrack The tracking origin object.
101 * @param out_ipc_id Will be filled with the tracking origin IPC ID on success.
102 * @return XRT_SUCCESS on success, some other result on failure.
103 *
104 * @ingroup ipc_server
105 */
108 struct xrt_tracking_origin *xtrack,
109 uint32_t *out_ipc_id);
110
111
112/*
113 *
114 * Space functions.
115 *
116 */
117
118/*!
119 * Get a space by ID, must only be called from the per client thread.
120 *
121 * @ingroup ipc_server
122 */
125 uint32_t id,
126 struct xrt_space **out_xspc);
127
128/*!
129 * Track a space and return its ID. Grabs and stores a reference if newly
130 * tracked.
131 *
132 * @ingroup ipc_server
133 */
135ipc_server_objects_get_xspc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_space *xspc, uint32_t *out_id);
136
137/*!
138 * Destroy a tracked space.
139 *
140 * @ingroup ipc_server
141 */
143ipc_server_objects_destroy_xspc(volatile struct ipc_client_state *ics, uint32_t id);
144
145
146/*
147 *
148 * Body tracker functions.
149 *
150 */
151
152/*!
153 * Get a body tracker by ID, must only be called from the per client thread.
154 *
155 * @ingroup ipc_server
156 */
159 uint32_t id,
160 struct xrt_body_tracker **out_xbt);
161
162/*!
163 * Track a newly created body tracker and return its ID. Takes ownership of
164 * @p xbt until explicit destroy or client disconnect.
165 *
166 * @ingroup ipc_server
167 */
170 struct xrt_body_tracker *xbt,
171 uint32_t *out_id);
172
173/*!
174 * Destroy a tracked body tracker.
175 *
176 * @ingroup ipc_server
177 */
179ipc_server_objects_destroy_xbt(volatile struct ipc_client_state *ics, uint32_t id);
180
181
182/*
183 *
184 * Hand tracker functions.
185 *
186 */
187
188/*!
189 * Get a hand tracker by ID, must only be called from the per client thread.
190 *
191 * @ingroup ipc_server
192 */
195 uint32_t id,
196 struct xrt_hand_tracker **out_xht);
197
198/*!
199 * Track a newly created hand tracker and return its ID. Takes ownership of
200 * @p xht until explicit destroy or client disconnect.
201 *
202 * @ingroup ipc_server
203 */
206 struct xrt_hand_tracker *xht,
207 uint32_t *out_id);
208
209/*!
210 * Destroy a tracked hand tracker.
211 *
212 * @ingroup ipc_server
213 */
215ipc_server_objects_destroy_xht(volatile struct ipc_client_state *ics, uint32_t id);
216
217
218/*
219 *
220 * App policy functions.
221 *
222 */
223
225ipc_server_objects_get_xainst_and_validate(volatile struct ipc_client_state *ics,
226 uint32_t id,
227 struct xrt_app_instance **out_xainst);
228
230ipc_server_objects_get_xainst_id_or_add(volatile struct ipc_client_state *ics,
231 struct xrt_app_instance *xainst,
232 uint32_t *out_id);
233
235ipc_server_objects_destroy_xainst(volatile struct ipc_client_state *ics, uint32_t id);
236
238ipc_server_objects_get_xasys_and_validate(volatile struct ipc_client_state *ics,
239 uint32_t id,
240 struct xrt_app_system **out_xasys);
241
243ipc_server_objects_get_xasys_id_or_add(volatile struct ipc_client_state *ics,
244 struct xrt_app_system *xasys,
245 uint32_t *out_id);
246
248ipc_server_objects_destroy_xasys(volatile struct ipc_client_state *ics, uint32_t id);
249
250
251/*
252 *
253 * Input/output cache functions.
254 *
255 */
256
257/*!
258 * Get an input/output cache by ID, must only be called from the per client thread.
259 *
260 * @ingroup ipc_server
261 */
264 uint32_t id,
265 struct xrt_io_cache **out_xic);
266
267/*!
268 * Track a newly created input/output cache and return its ID. Takes ownership of
269 * @p xic until explicit destroy or client disconnect.
270 *
271 * @ingroup ipc_server
272 */
274ipc_server_objects_get_xic_id_or_add(volatile struct ipc_client_state *ics, struct xrt_io_cache *xic, uint32_t *out_id);
275
276/*!
277 * Destroy a tracked input/output cache.
278 *
279 * @ingroup ipc_server
280 */
282ipc_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:490
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:207
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:158
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:274
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:511
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:299
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:179
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:529
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:320
xrt_result_t ipc_server_objects_get_xtrack_and_validate(volatile struct ipc_client_state *ics, uint32_t ipc_id, struct xrt_tracking_origin **out_xtrack)
Get a tracking origin by its IPC ID, must only be called from the per client thread as this function ...
Definition ipc_server_objects.c:101
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:233
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:254
xrt_result_t ipc_server_objects_get_xtrack_ipc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_tracking_origin *xtrack, uint32_t *out_ipc_id)
Get or allocate the IPC ID for a given tracking origin object, must only be called from the per clien...
Definition ipc_server_objects.c:122
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:340
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:345
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:115
Internal result type for XRT.