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 ipc_client_state;
18
19
20/*
21 *
22 * Device functions.
23 *
24 */
25
26/*!
27 * Get a device by its per-client-connection slot index.
28 *
29 * The @p id is a @c uint32_t index into @c ics->objects.xdevs used for IPC
30 * message lookups. It is not @ref xrt_device::id.
31 *
32 * Must only be called from the per client thread as this function accesses the
33 * client state's memory.
34 *
35 * @param ics The client state instance.
36 * @param id The per-client slot index.
37 * @param out_xdev Will be filled with the device object on success.
38 * @return XRT_SUCCESS on success, some other result on failure.
39 *
40 * @ingroup ipc_server
41 */
44 uint32_t id,
45 struct xrt_device **out_xdev);
46
47/*!
48 * Get or allocate a per-client-connection slot index for a device object.
49 *
50 * The returned @c uint32_t is used in IPC messages to look up @p xdev on the
51 * server. It is not @ref xrt_device::id, which is assigned at device creation
52 * and synchronized to clients via @ref ipc_device_info.
53 *
54 * Must only be called from the per client thread as this function accesses the
55 * client state's memory.
56 *
57 * @param ics The client state instance.
58 * @param xdev The device object.
59 * @param out_id Will be filled with the slot index on success.
60 * @return XRT_SUCCESS on success, some other result on failure.
61 *
62 * @ingroup ipc_server
63 */
65ipc_server_objects_get_xdev_id_or_add(volatile struct ipc_client_state *ics, struct xrt_device *xdev, uint32_t *out_id);
66
67
68/*
69 *
70 * Tracking origin functions.
71 *
72 */
73
74/*!
75 * Get a tracking origin by ID, must only be called from the per client
76 * thread as this function accesses the client state's memory.
77 *
78 * @param ics The client state instance.
79 * @param id The tracking origin ID.
80 * @param out_xtrack Will be filled with the tracking origin object on success.
81 * @return XRT_SUCCESS on success, some other result on failure.
82 *
83 * @ingroup ipc_server
84 */
87 uint32_t id,
88 struct xrt_tracking_origin **out_xtrack);
89
90/*!
91 * Get a tracking origin ID for a given tracking origin object, must only be
92 * called from the per client thread as this function accesses the client
93 * state's memory.
94 *
95 * @param ics The client state instance.
96 * @param xtrack The tracking origin object.
97 * @param out_id Will be filled with the tracking origin ID on success.
98 * @return XRT_SUCCESS on success, some other result on failure.
99 *
100 * @ingroup ipc_server
101 */
104 struct xrt_tracking_origin *xtrack,
105 uint32_t *out_id);
106
107
108/*
109 *
110 * Space functions.
111 *
112 */
113
114/*!
115 * Get a space by ID, must only be called from the per client thread.
116 *
117 * @ingroup ipc_server
118 */
121 uint32_t id,
122 struct xrt_space **out_xspc);
123
124/*!
125 * Track a space and return its ID. Grabs and stores a reference if newly
126 * tracked.
127 *
128 * @ingroup ipc_server
129 */
131ipc_server_objects_get_xspc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_space *xspc, uint32_t *out_id);
132
133/*!
134 * Destroy a tracked space.
135 *
136 * @ingroup ipc_server
137 */
139ipc_server_objects_destroy_xspc(volatile struct ipc_client_state *ics, uint32_t id);
140
141
142/*
143 *
144 * Body tracker functions.
145 *
146 */
147
148/*!
149 * Get a body tracker by ID, must only be called from the per client thread.
150 *
151 * @ingroup ipc_server
152 */
155 uint32_t id,
156 struct xrt_body_tracker **out_xbt);
157
158/*!
159 * Track a newly created body tracker and return its ID. Takes ownership of
160 * @p xbt until explicit destroy or client disconnect.
161 *
162 * @ingroup ipc_server
163 */
166 struct xrt_body_tracker *xbt,
167 uint32_t *out_id);
168
169/*!
170 * Destroy a tracked body tracker.
171 *
172 * @ingroup ipc_server
173 */
175ipc_server_objects_destroy_xbt(volatile struct ipc_client_state *ics, uint32_t id);
176
177
178/*
179 *
180 * Hand tracker functions.
181 *
182 */
183
184/*!
185 * Get a hand tracker by ID, must only be called from the per client thread.
186 *
187 * @ingroup ipc_server
188 */
191 uint32_t id,
192 struct xrt_hand_tracker **out_xht);
193
194/*!
195 * Track a newly created hand tracker and return its ID. Takes ownership of
196 * @p xht until explicit destroy or client disconnect.
197 *
198 * @ingroup ipc_server
199 */
202 struct xrt_hand_tracker *xht,
203 uint32_t *out_id);
204
205/*!
206 * Destroy a tracked hand tracker.
207 *
208 * @ingroup ipc_server
209 */
211ipc_server_objects_destroy_xht(volatile struct ipc_client_state *ics, uint32_t id);
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:205
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:156
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:272
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:31
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:297
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:177
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:318
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:52
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:231
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:99
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:252
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:338
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:120
enum xrt_result xrt_result_t
Result type used across Monado.
Holds the state for a single client.
Definition ipc_server.h:98
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:340
A hand tracker that owns device/source selection policy.
Definition xrt_hand_tracker.h:76
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:78
Internal result type for XRT.