Monado OpenXR Runtime
Loading...
Searching...
No Matches
ipc_client.h
Go to the documentation of this file.
1// Copyright 2020-2023, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Common client side code.
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_client
11 */
12
13#pragma once
14
15#include "xrt/xrt_compiler.h"
16#include "xrt/xrt_config_os.h"
17
18#include "util/u_threading.h"
19#include "util/u_logging.h"
21
22#include "shared/ipc_utils.h"
23#include "shared/ipc_protocol.h"
25
27
28#include <stdio.h>
29
30
31/*
32 *
33 * Logging
34 *
35 */
36
37#define IPC_TRACE(IPC_C, ...) U_LOG_IFL_T((IPC_C)->imc.log_level, __VA_ARGS__)
38#define IPC_DEBUG(IPC_C, ...) U_LOG_IFL_D((IPC_C)->imc.log_level, __VA_ARGS__)
39#define IPC_INFO(IPC_C, ...) U_LOG_IFL_I((IPC_C)->imc.log_level, __VA_ARGS__)
40#define IPC_WARN(IPC_C, ...) U_LOG_IFL_W((IPC_C)->imc.log_level, __VA_ARGS__)
41#define IPC_ERROR(IPC_C, ...) U_LOG_IFL_E((IPC_C)->imc.log_level, __VA_ARGS__)
42
43#define IPC_CHK_AND_RET(IPC_C, ...) U_LOG_CHK_AND_RET((IPC_C)->imc.log_level, __VA_ARGS__)
44#define IPC_CHK_WITH_GOTO(IPC_C, ...) U_LOG_CHK_WITH_GOTO((IPC_C)->imc.log_level, __VA_ARGS__)
45#define IPC_CHK_WITH_RET(IPC_C, ...) U_LOG_CHK_WITH_RET((IPC_C)->imc.log_level, __VA_ARGS__)
46#define IPC_CHK_ONLY_PRINT(IPC_C, ...) U_LOG_CHK_ONLY_PRINT((IPC_C)->imc.log_level, __VA_ARGS__)
47#define IPC_CHK_ALWAYS_RET(IPC_C, ...) U_LOG_CHK_ALWAYS_RET((IPC_C)->imc.log_level, __VA_ARGS__)
48
49
50/*
51 *
52 * Structs
53 *
54 */
55
57
58
59/*!
60 * Connection.
61 */
63{
64 struct ipc_message_channel imc;
65
66 struct ipc_shared_memory *ism;
67 xrt_shmem_handle_t ism_handle;
68
69 struct os_mutex mutex;
70
71#ifdef XRT_OS_ANDROID
72 struct ipc_client_android *ica;
73#endif // XRT_OS_ANDROID
74};
75
76/*!
77 * Client side implementation of the system devices struct.
78 */
80{
81 //! @public Base
83
84 //! Connection to service.
86
87 //! Tracking origin manager for on-demand fetching
89
90 struct xrt_reference feature_use[XRT_DEVICE_FEATURE_MAX_ENUM];
91};
92
93
94/*
95 *
96 * Internal functions.
97 *
98 */
99
100/*!
101 * Create an IPC client system compositor.
102 *
103 * It owns a special implementation of the @ref xrt_system_compositor interface.
104 *
105 * This actually creates an IPC client "native" compositor with deferred
106 * initialization. The @ref ipc_client_create_native_compositor function
107 * actually completes the deferred initialization of the compositor, effectively
108 * finishing creation of a compositor IPC proxy.
109 *
110 * @param ipc_c IPC connection
111 * @param xina Optional native image allocator for client-side allocation. Takes
112 * ownership if one is supplied.
113 * @param xdev Taken in but not used currently @todo remove this param?
114 * @param[out] out_xcs Pointer to receive the created xrt_system_compositor.
115 */
118 struct xrt_image_native_allocator *xina,
119 struct xrt_device *xdev,
120 struct xrt_system_compositor **out_xcs);
121
122/*!
123 * Create a native compositor from a system compositor, this is used instead
124 * of the normal xrt_system_compositor::create_native_compositor function
125 * because it doesn't support events being generated on the app side. This will
126 * also create the session on the service side.
127 *
128 * @param xsysc IPC created system compositor.
129 * @param xsi Session information struct.
130 * @param[out] out_xcn Pointer to receive the created xrt_compositor_native.
131 */
134 const struct xrt_session_info *xsi,
135 struct xrt_compositor_native **out_xcn);
136
137struct xrt_device *
138ipc_client_hmd_create(struct ipc_connection *ipc_c,
140 uint32_t device_id);
141
142struct xrt_device *
143ipc_client_device_create(struct ipc_connection *ipc_c,
145 uint32_t device_id);
146
147struct xrt_system *
148ipc_client_system_create(struct ipc_connection *ipc_c, struct xrt_system_compositor *xsysc);
149
150struct xrt_space_overseer *
151ipc_client_space_overseer_create(struct ipc_connection *ipc_c);
152
153uint32_t
154ipc_client_space_get_id(struct xrt_space *space);
155
157ipc_client_system_devices_create(struct ipc_connection *ipc_c, struct ipc_client_system_devices **out_icsd);
158
159struct xrt_session *
160ipc_client_session_create(struct ipc_connection *ipc_c);
161
162struct xrt_future *
163ipc_client_future_create(struct ipc_connection *ipc_c, uint32_t future_id);
Generic typedef for platform-specific shared memory handle.
enum xrt_result xrt_result_t
Result type used across Monado.
xrt_result_t ipc_client_create_native_compositor(struct xrt_system_compositor *xsysc, const struct xrt_session_info *xsi, struct xrt_compositor_native **out_xcn)
Create a native compositor from a system compositor, this is used instead of the normal xrt_system_co...
Definition ipc_client_compositor.c:1085
xrt_result_t ipc_client_create_system_compositor(struct ipc_connection *ipc_c, struct xrt_image_native_allocator *xina, struct xrt_device *xdev, struct xrt_system_compositor **out_xcs)
Create an IPC client system compositor.
Definition ipc_client_compositor.c:1116
IPC Client tracking origin management.
IPC message channel functions.
Common protocol definition.
IPC util helpers, for internal use only.
Definition ipc_client_android.cpp:27
Client side implementation of the system devices struct.
Definition ipc_client.h:80
struct ipc_connection * ipc_c
Connection to service.
Definition ipc_client.h:85
struct u_system_devices base
Base.
Definition ipc_client.h:82
struct ipc_client_tracking_origin_manager tracking_origin_manager
Tracking origin manager for on-demand fetching.
Definition ipc_client.h:88
Tracking origin manager for IPC client.
Definition ipc_client_tracking_origin.h:32
Connection.
Definition ipc_client.h:63
Wrapper for a socket and flags.
Definition ipc_message_channel.h:30
A big struct that contains all data that is shared to a client, no pointers allowed in this.
Definition ipc_protocol.h:249
A wrapper around a native mutex.
Definition os_threading.h:69
Helper struct to manage devices by implementing the xrt_system_devices.
Definition u_system_helpers.h:36
Main compositor server interface.
Definition xrt_compositor.h:2236
A single HMD or input device.
Definition xrt_device.h:310
A future is a concurrency primitive that provides a mechanism to access results of asynchronous opera...
Definition xrt_future.h:75
Allocator for system native images, in general you do not need to free the images as they will be con...
Definition xrt_compositor.h:2661
A base class for reference counted objects.
Definition xrt_defines.h:99
Session information, mostly overlay extension data.
Definition xrt_compositor.h:925
The XRT representation of XrSession, this object does not have all of the functionality of a session,...
Definition xrt_session.h:277
Object that oversees and manages spaces, one created for each XR system.
Definition xrt_space.h:97
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
The system compositor handles composition for a system.
Definition xrt_compositor.h:2448
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition xrt_system.h:63
Basic logging functionality.
Helpers for system objects like xrt_system_devices.
Slightly higher level thread safe helpers.
Header holding common defines.
Auto detect OS and certain features.