Monado OpenXR Runtime
null_compositor.h
Go to the documentation of this file.
1// Copyright 2019-2024, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Internal header for null compositor.
6 *
7 * Originally based on src/xrt/compositor/main/comp_compositor.h
8 *
9 * @author Jakob Bornecrantz <jakob@collabora.com>
10 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
11 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
12 * @ingroup comp_null
13 */
14
15#pragma once
16
17#include "xrt/xrt_instance.h"
18
19#include "util/u_logging.h"
20#include "util/u_pacing.h"
21
22#include "util/comp_base.h"
23
24#include <stdint.h>
25
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31struct xrt_device;
33
34/*!
35 * @defgroup comp_null Null compositor
36 * @ingroup xrt
37 * @brief A non-rendering alternate for the main compositor that still can
38 * support applications fully.
39 *
40 * Monado's design is highly modular, including allowing alternate compositors to
41 * be used. If you are looking to write an additional or alternate compositor to
42 * the one in `src/xrt/compositor/main`, this code is your starting point. It is
43 * the basic implementation of @ref xrt_compositor_native extracted from there,
44 * renamed, and with most implementations removed. Compare with similarly-named
45 * files there to see what was removed, and what helper functionality has been
46 * factored out and may be reusable. For example, you may be able to use @ref
47 * comp_renderer, @ref comp_resources, @ref comp_shaders, and @ref comp_target,
48 * among others.
49 */
50
51
52/*
53 *
54 * Structs, enums and defines.
55 *
56 */
57
58/*!
59 * Tracking frame state.
60 *
61 * @ingroup comp_null
62 */
64{
65 int64_t id;
66 uint64_t predicted_display_time_ns;
67 uint64_t desired_present_time_ns;
68 uint64_t present_slop_ns;
69};
70
71/*!
72 * Main compositor struct tying everything in the compositor together.
73 *
74 * This ultimately implements @ref xrt_compositor_native but does so by
75 * extending @ref comp_base, similar to how @ref comp_compositor works.
76 *
77 * @extends comp_base
78 * @ingroup comp_null
79 */
81{
82 struct comp_base base;
83
84 //! The device we are displaying to.
86
87 //! Pacing helper to drive us forward.
89
90 struct
91 {
92 enum u_logging_level log_level;
93
94 //! Frame interval that we are using.
96 } settings;
97
98 // Kept here for convenience.
99 struct xrt_system_compositor_info sys_info;
100
101 //! @todo Insert your own required members here
102
103 struct
104 {
105 struct null_comp_frame waited;
106 struct null_comp_frame rendering;
108};
109
110
111/*
112 *
113 * Functions and helpers.
114 *
115 */
116
117/*!
118 * Convenience function to convert an xrt_compositor to a null_compositor.
119 * (Down-cast helper.)
120 *
121 * @private @memberof null_compositor
122 * @ingroup comp_null
123 */
124static inline struct null_compositor *
126{
127 return (struct null_compositor *)xc;
128}
129
130/*!
131 * Spew level logging.
132 *
133 * @relates null_compositor
134 * @ingroup comp_null
135 */
136#define NULL_TRACE(c, ...) U_LOG_IFL_T(c->settings.log_level, __VA_ARGS__);
137
138/*!
139 * Debug level logging.
140 *
141 * @relates null_compositor
142 */
143#define NULL_DEBUG(c, ...) U_LOG_IFL_D(c->settings.log_level, __VA_ARGS__);
144
145/*!
146 * Info level logging.
147 *
148 * @relates null_compositor
149 * @ingroup comp_null
150 */
151#define NULL_INFO(c, ...) U_LOG_IFL_I(c->settings.log_level, __VA_ARGS__);
152
153/*!
154 * Warn level logging.
155 *
156 * @relates null_compositor
157 * @ingroup comp_null
158 */
159#define NULL_WARN(c, ...) U_LOG_IFL_W(c->settings.log_level, __VA_ARGS__);
160
161/*!
162 * Error level logging.
163 *
164 * @relates null_compositor
165 * @ingroup comp_null
166 */
167#define NULL_ERROR(c, ...) U_LOG_IFL_E(c->settings.log_level, __VA_ARGS__);
168
169
170#ifdef __cplusplus
171}
172#endif
Helper implementation for native compositors.
u_logging_level
Logging level enum.
Definition: u_logging.h:40
A simple compositor base that handles a lot of things for you.
Definition: comp_base.h:69
struct xrt_compositor_native base
Base native compositor.
Definition: comp_base.h:71
Tracking frame state.
Definition: null_compositor.h:64
Main compositor struct tying everything in the compositor together.
Definition: null_compositor.h:81
struct null_compositor::@85 frame
struct xrt_device * xdev
The device we are displaying to.
Definition: null_compositor.h:85
uint64_t frame_interval_ns
Frame interval that we are using.
Definition: null_compositor.h:95
struct u_pacing_compositor * upc
Pacing helper to drive us forward.
Definition: null_compositor.h:88
Compositor pacing helper interface.
Definition: u_pacing.h:68
Common compositor client interface/base.
Definition: xrt_compositor.h:988
A single HMD or input device.
Definition: xrt_device.h:241
Capabilities and information about the system compositor (and its wrapped native compositor,...
Definition: xrt_compositor.h:2295
Basic logging functionality.
Shared pacing code.
Header for xrt_instance object.