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_hand_tracker;
16struct ipc_client_state;
17
18
19/*
20 *
21 * Device functions.
22 *
23 */
24
25/*!
26 * Get a device by its per-client-connection slot index.
27 *
28 * The @p id is a @c uint32_t index into @c ics->objects.xdevs used for IPC
29 * message lookups. It is not @ref xrt_device::id.
30 *
31 * Must only be called from the per client thread as this function accesses the
32 * client state's memory.
33 *
34 * @param ics The client state instance.
35 * @param id The per-client slot index.
36 * @param out_xdev Will be filled with the device object on success.
37 * @return XRT_SUCCESS on success, some other result on failure.
38 *
39 * @ingroup ipc_server
40 */
43 uint32_t id,
44 struct xrt_device **out_xdev);
45
46/*!
47 * Get or allocate a per-client-connection slot index for a device object.
48 *
49 * The returned @c uint32_t is used in IPC messages to look up @p xdev on the
50 * server. It is not @ref xrt_device::id, which is assigned at device creation
51 * and synchronized to clients via @ref ipc_device_info.
52 *
53 * Must only be called from the per client thread as this function accesses the
54 * client state's memory.
55 *
56 * @param ics The client state instance.
57 * @param xdev The device object.
58 * @param out_id Will be filled with the slot index on success.
59 * @return XRT_SUCCESS on success, some other result on failure.
60 *
61 * @ingroup ipc_server
62 */
64ipc_server_objects_get_xdev_id_or_add(volatile struct ipc_client_state *ics, struct xrt_device *xdev, uint32_t *out_id);
65
66
67/*
68 *
69 * Tracking origin functions.
70 *
71 */
72
73/*!
74 * Get a tracking origin by ID, must only be called from the per client
75 * thread as this function accesses the client state's memory.
76 *
77 * @param ics The client state instance.
78 * @param id The tracking origin ID.
79 * @param out_xtrack Will be filled with the tracking origin object on success.
80 * @return XRT_SUCCESS on success, some other result on failure.
81 *
82 * @ingroup ipc_server
83 */
86 uint32_t id,
87 struct xrt_tracking_origin **out_xtrack);
88
89/*!
90 * Get a tracking origin ID for a given tracking origin object, must only be
91 * called from the per client thread as this function accesses the client
92 * state's memory.
93 *
94 * @param ics The client state instance.
95 * @param xtrack The tracking origin object.
96 * @param out_id Will be filled with the tracking origin ID on success.
97 * @return XRT_SUCCESS on success, some other result on failure.
98 *
99 * @ingroup ipc_server
100 */
103 struct xrt_tracking_origin *xtrack,
104 uint32_t *out_id);
105
106
107/*
108 *
109 * Space functions.
110 *
111 */
112
113/*!
114 * Get a space by ID, must only be called from the per client thread.
115 *
116 * @ingroup ipc_server
117 */
120 uint32_t id,
121 struct xrt_space **out_xspc);
122
123/*!
124 * Track a space and return its ID. Grabs and stores a reference if newly
125 * tracked.
126 *
127 * @ingroup ipc_server
128 */
130ipc_server_objects_get_xspc_id_or_add(volatile struct ipc_client_state *ics, struct xrt_space *xspc, uint32_t *out_id);
131
132/*!
133 * Destroy a tracked space.
134 *
135 * @ingroup ipc_server
136 */
138ipc_server_objects_destroy_xspc(volatile struct ipc_client_state *ics, uint32_t id);
139
140
141/*
142 *
143 * Hand tracker functions.
144 *
145 */
146
147/*!
148 * Get a hand tracker by ID, must only be called from the per client thread.
149 *
150 * @ingroup ipc_server
151 */
154 uint32_t id,
155 struct xrt_hand_tracker **out_xht);
156
157/*!
158 * Track a newly created hand tracker and return its ID. Takes ownership of
159 * @p xht until explicit destroy or client disconnect.
160 *
161 * @ingroup ipc_server
162 */
165 struct xrt_hand_tracker *xht,
166 uint32_t *out_id);
167
168/*!
169 * Destroy a tracked hand tracker.
170 *
171 * @ingroup ipc_server
172 */
174ipc_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:204
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:155
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:30
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:230
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:176
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:251
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:51
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:98
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:271
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:119
enum xrt_result xrt_result_t
Result type used across Monado.
Holds the state for a single client.
Definition ipc_server.h:96
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.