Monado OpenXR Runtime
Loading...
Searching...
No Matches
ipc_protocol.h
Go to the documentation of this file.
1// Copyright 2020-2024 Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Common protocol definition.
7 * @author Pete Black <pblack@collabora.com>
8 * @author Jakob Bornecrantz <jakob@collabora.com>
9 * @author Korcan Hussein <korcan.hussein@collabora.com>
10 * @ingroup ipc_shared
11 */
12
13#pragma once
14
15#include "xrt/xrt_limits.h"
16#include "xrt/xrt_compiler.h"
17#include "xrt/xrt_compositor.h"
18#include "xrt/xrt_results.h"
19#include "xrt/xrt_defines.h"
20#include "xrt/xrt_future.h"
21#include "xrt/xrt_system.h"
22#include "xrt/xrt_session.h"
23#include "xrt/xrt_instance.h"
24#include "xrt/xrt_compositor.h"
25#include "xrt/xrt_device.h"
26#include "xrt/xrt_space.h"
27#include "xrt/xrt_tracking.h"
28#include "xrt/xrt_config_build.h"
29
30#include <assert.h>
31#include <sys/types.h>
32
33
34#define IPC_CRED_SIZE 1 // auth not implemented
35#define IPC_BUF_SIZE 2048 // must be >= largest message length in bytes
36#define IPC_MAX_VIEWS 8 // max views we will return configs for
37#define IPC_MAX_FORMATS 32 // max formats our server-side compositor supports
38#define IPC_MAX_DEVICES 8 // max number of devices we will map using shared mem
39#define IPC_MAX_LAYERS XRT_MAX_LAYERS
40#define IPC_MAX_SLOTS 128
41#define IPC_MAX_CLIENTS 32
42#define IPC_MAX_RAW_VIEWS 32 // Max views that we can get, artificial limit.
43#define IPC_EVENT_QUEUE_SIZE 32
44
45
46// example: v21.0.0-560-g586d33b5
47#define IPC_VERSION_NAME_LEN 64
48
49#if defined(XRT_OS_WINDOWS) && !defined(XRT_ENV_MINGW)
50typedef int pid_t;
51#endif
52
53/*
54 *
55 * Shared memory structs.
56 *
57 */
58
59/*!
60 * Information about a device in the device list.
61 *
62 * @ingroup ipc
63 */
65{
66 //! Tracking origin ID
67 uint32_t id;
68};
69
70/*!
71 * A list of the current tracking origins.
72 *
73 * @ingroup ipc
74 */
76{
77 //! Number of tracking origins.
78 uint32_t origin_count;
79
80 //! Compact list of tracking origins.
82};
83
84/*!
85 * A tracking in the shared memory area.
86 *
87 * @ingroup ipc
88 */
90{
91 //! For debugging.
92 char name[XRT_TRACKING_NAME_LEN];
93
94 //! What can the state tracker expect from this tracking system.
96
97 //! Initial offset of the tracking origin.
99};
100
101/*!
102 * Information about a device in the device list.
103 *
104 * @ingroup ipc
105 */
107{
108 //! Device ID
109 uint32_t id;
110
111 //! Device type
113};
114
115/*!
116 * List of devices available on the server.
117 *
118 * @ingroup ipc
119 */
121{
122 //! Number of devices
123 uint32_t device_count;
124
125 //! Device entries
127};
128
129/*!
130 * Device information sent over IPC.
131 *
132 * Followed by varlen data containing:
133 * - An array of input_count * enum xrt_input_name
134 * - An array of output_count * enum xrt_output_name
135 * - An array of binding_profile_count * struct ipc_binding_profile_info
136 * - An array of total_input_pair_count * struct xrt_binding_input_pair
137 * - An array of total_output_pair_count * struct xrt_binding_output_pair
138 *
139 * @ingroup ipc
140 */
142{
143 //! Enum identifier of the device.
145 enum xrt_device_type device_type;
146
147 //! Which tracking system origin is this device attached to.
149
150 //! A string describing the device.
151 char str[XRT_DEVICE_NAME_LEN];
152
153 //! A unique identifier. Persistent across configurations, if possible.
154 char serial[XRT_DEVICE_NAME_LEN];
155
156 //! Number of binding profiles in varlen data.
158
159 //! Total number of input pairs in varlen data (across all binding profiles).
161
162 //! Total number of output pairs in varlen data (across all binding profiles).
164
165 //! Number of inputs.
166 uint32_t input_count;
167
168 //! Number of outputs.
169 uint32_t output_count;
170
171 //! The supported fields.
173};
174
175/*!
176 * A binding in the shared memory area.
177 *
178 * @ingroup ipc
179 */
181{
182 enum xrt_device_name name;
183
184 //! Offset into the array of pairs where this input bindings starts.
186 //! Number of inputs.
187 uint32_t input_count;
188
189 //! Offset into the array of pairs where this output bindings starts.
191 //! Number of outputs.
192 uint32_t output_count;
193};
194
195/*!
196 * Data for a single composition layer.
197 *
198 * Similar in function to @ref comp_layer
199 *
200 * @ingroup ipc
201 */
203{
204 //! @todo what is this used for?
205 uint32_t xdev_id;
206
207 /*!
208 * Up to two indices of swapchains to use.
209 *
210 * How many are actually used depends on the value of @p data.type
211 */
212 uint32_t swapchain_ids[XRT_MAX_VIEWS * 2];
213
214 /*!
215 * All basic (trivially-serializable) data associated with a layer,
216 * aside from which swapchain(s) are used.
217 */
219};
220
221/*!
222 * Render state for a single client, including all layers.
223 *
224 * @ingroup ipc
225 */
227{
228 struct xrt_layer_frame_data data;
229 uint32_t layer_count;
230 struct ipc_layer_entry layers[IPC_MAX_LAYERS];
231};
232
233/*!
234 * A big struct that contains all data that is shared to a client, no pointers
235 * allowed in this. To get the inputs of a device you go:
236 *
237 * ```C++
238 * struct xrt_input *
239 * helper(struct ipc_shared_memory *ism, uint32_t device_id, uint32_t input)
240 * {
241 * uint32_t index = ism->isdevs[device_id]->first_input_index + input;
242 * return &ism->inputs[index];
243 * }
244 * ```
245 *
246 * @ingroup ipc
247 */
249{
250 /*!
251 * The git revision of the service, used by clients to detect version mismatches.
252 */
253 char u_git_tag[IPC_VERSION_NAME_LEN];
254
255 /*!
256 * Various roles for the devices.
257 */
258 struct
259 {
260 int32_t head;
261 int32_t eyes;
262 int32_t face;
263 int32_t body;
264
265 struct
266 {
267 struct
268 {
269 int32_t left;
270 int32_t right;
271 } unobstructed;
272
273 struct
274 {
275 int32_t left;
276 int32_t right;
277 } conforming;
278 } hand_tracking;
280
281 struct
282 {
283 struct
284 {
285 /*!
286 * Pixel properties of this display, not in absolute
287 * screen coordinates that the compositor sees. So
288 * before any rotation is applied by xrt_view::rot.
289 *
290 * The xrt_view::display::w_pixels &
291 * xrt_view::display::h_pixels become the recommended
292 * image size for this view.
293 *
294 * @todo doesn't account for overfill for timewarp or
295 * distortion?
296 */
297 struct
298 {
299 uint32_t w_pixels;
300 uint32_t h_pixels;
302 } views[2];
303 // view count
304 uint32_t view_count;
305 enum xrt_blend_mode blend_modes[XRT_MAX_DEVICE_BLEND_MODES];
306 uint32_t blend_mode_count;
307 } hmd;
308
309 struct ipc_layer_slot slots[IPC_MAX_SLOTS];
310
311 uint64_t startup_timestamp;
312 struct xrt_plane_detector_begin_info_ext plane_begin_info_ext;
313};
314
315/*!
316 * Initial info from a client when it connects.
317 */
319{
320 pid_t pid;
321 struct xrt_application_info info;
322};
323
325{
326 uint32_t ids[IPC_MAX_CLIENTS];
327 uint32_t id_count;
328};
329
330/*!
331 * Which types of IO to block for a client.
332 *
333 * @ingroup ipc
334 */
336{
337 bool block_poses;
338 bool block_hand_tracking;
339 bool block_inputs;
340 bool block_outputs;
341};
342
343/*!
344 * State for a connected application.
345 *
346 * @ingroup ipc
347 */
349{
350 // Stable and unique ID of the client, only unique within this instance.
351 uint32_t id;
352
353 bool primary_application;
354 bool session_active;
355 bool session_visible;
356 bool session_focused;
357 bool session_overlay;
358 struct ipc_client_io_blocks io_blocks;
359 uint32_t z_order;
360 pid_t pid;
361 struct xrt_application_info info;
362};
363
364
365/*!
366 * Arguments for creating swapchains from native images.
367 */
369{
370 uint32_t sizes[XRT_MAX_SWAPCHAIN_IMAGES];
371};
372
373/*!
374 * Arguments for xrt_device::get_view_poses with two views.
375 */
377{
378 struct xrt_fov fovs[XRT_MAX_VIEWS];
379 struct xrt_pose poses[XRT_MAX_VIEWS];
380 struct xrt_space_relation head_relation;
381};
382
384{
385 uint32_t num_samples;
386 float sample_rate;
387 bool append;
388};
xrt_blend_mode
Blend mode that the device supports, exact mirror of XrEnvironmentBlendMode.
Definition xrt_defines.h:112
#define XRT_SYSTEM_MAX_DEVICES
Maximum number of devices simultaneously usable by an implementation of xrt_system_devices.
Definition xrt_limits.h:26
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition xrt_limits.h:53
xrt_tracking_type
What kind of tracking system is this.
Definition xrt_tracking.h:46
xrt_device_type
How an xrt_device can be used.
Definition xrt_defines.h:812
State for a connected application.
Definition ipc_protocol.h:349
Arguments for creating swapchains from native images.
Definition ipc_protocol.h:369
A binding in the shared memory area.
Definition ipc_protocol.h:181
uint32_t first_output_index
Offset into the array of pairs where this output bindings starts.
Definition ipc_protocol.h:190
uint32_t output_count
Number of outputs.
Definition ipc_protocol.h:192
uint32_t first_input_index
Offset into the array of pairs where this input bindings starts.
Definition ipc_protocol.h:185
uint32_t input_count
Number of inputs.
Definition ipc_protocol.h:187
Initial info from a client when it connects.
Definition ipc_protocol.h:319
Which types of IO to block for a client.
Definition ipc_protocol.h:336
Definition ipc_protocol.h:325
Device information sent over IPC.
Definition ipc_protocol.h:142
char str[XRT_DEVICE_NAME_LEN]
A string describing the device.
Definition ipc_protocol.h:151
uint32_t total_output_pair_count
Total number of output pairs in varlen data (across all binding profiles).
Definition ipc_protocol.h:163
enum xrt_device_name name
Enum identifier of the device.
Definition ipc_protocol.h:144
uint32_t total_input_pair_count
Total number of input pairs in varlen data (across all binding profiles).
Definition ipc_protocol.h:160
uint32_t binding_profile_count
Number of binding profiles in varlen data.
Definition ipc_protocol.h:157
char serial[XRT_DEVICE_NAME_LEN]
A unique identifier. Persistent across configurations, if possible.
Definition ipc_protocol.h:154
uint32_t tracking_origin_id
Which tracking system origin is this device attached to.
Definition ipc_protocol.h:148
struct xrt_device_supported supported
The supported fields.
Definition ipc_protocol.h:172
uint32_t input_count
Number of inputs.
Definition ipc_protocol.h:166
uint32_t output_count
Number of outputs.
Definition ipc_protocol.h:169
Information about a device in the device list.
Definition ipc_protocol.h:107
uint32_t id
Device ID.
Definition ipc_protocol.h:109
enum xrt_device_type device_type
Device type.
Definition ipc_protocol.h:112
List of devices available on the server.
Definition ipc_protocol.h:121
struct ipc_device_list_entry devices[XRT_SYSTEM_MAX_DEVICES]
Device entries.
Definition ipc_protocol.h:126
uint32_t device_count
Number of devices.
Definition ipc_protocol.h:123
Arguments for xrt_device::get_view_poses with two views.
Definition ipc_protocol.h:377
Data for a single composition layer.
Definition ipc_protocol.h:203
struct xrt_layer_data data
All basic (trivially-serializable) data associated with a layer, aside from which swapchain(s) are us...
Definition ipc_protocol.h:218
uint32_t swapchain_ids[XRT_MAX_VIEWS *2]
Up to two indices of swapchains to use.
Definition ipc_protocol.h:212
uint32_t xdev_id
Definition ipc_protocol.h:205
Render state for a single client, including all layers.
Definition ipc_protocol.h:227
Definition ipc_protocol.h:384
A big struct that contains all data that is shared to a client, no pointers allowed in this.
Definition ipc_protocol.h:249
struct ipc_shared_memory::@269 roles
Various roles for the devices.
struct ipc_shared_memory::@270::@274::@275 display
Pixel properties of this display, not in absolute screen coordinates that the compositor sees.
char u_git_tag[64]
The git revision of the service, used by clients to detect version mismatches.
Definition ipc_protocol.h:253
A tracking in the shared memory area.
Definition ipc_protocol.h:90
enum xrt_tracking_type type
What can the state tracker expect from this tracking system.
Definition ipc_protocol.h:95
char name[XRT_TRACKING_NAME_LEN]
For debugging.
Definition ipc_protocol.h:92
struct xrt_pose offset
Initial offset of the tracking origin.
Definition ipc_protocol.h:98
Information about a device in the device list.
Definition ipc_protocol.h:65
uint32_t id
Tracking origin ID.
Definition ipc_protocol.h:67
A list of the current tracking origins.
Definition ipc_protocol.h:76
uint32_t origin_count
Number of tracking origins.
Definition ipc_protocol.h:78
struct ipc_tracking_origin_list_entry origins[XRT_SYSTEM_MAX_DEVICES]
Compact list of tracking origins.
Definition ipc_protocol.h:81
Non-process-specific information provided by the application at instance create time.
Definition xrt_instance.h:73
Static data of supported features of the xrt_device this struct sits on.
Definition xrt_device.h:280
Describes a projection matrix fov.
Definition xrt_defines.h:499
All the pure data values associated with a composition layer.
Definition xrt_compositor.h:395
Per frame data for the layer submission calls, used in xrt_compositor::layer_begin.
Definition xrt_compositor.h:481
A query for a plane.
Definition xrt_plane_detector.h:97
A pose composed of a position and orientation.
Definition xrt_defines.h:479
A relation with two spaces, includes velocity and acceleration.
Definition xrt_defines.h:670
Header holding common defines.
Header declaring XRT graphics interfaces.
Common defines and enums for XRT.
xrt_device_name
A enum that is used to name devices so that the state trackers can reason about the devices easier.
Definition xrt_defines.h:724
Header defining an xrt display or controller device.
Interface for creating futures.
Header for xrt_instance object.
Header for limits of the XRT interfaces.
Internal result type for XRT.
Header for session object.
Header defining xrt space and space overseer.
Header for system objects.
Header defining the tracking system integration in Monado.