Monado OpenXR Runtime
Loading...
Searching...
No Matches
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 //! The supported view configurations
88 struct xrt_view_config view_configs[XRT_MAX_COMPOSITOR_VIEW_CONFIGS_COUNT];
89
90 //! Pacing helper to drive us forward.
92
93 struct
94 {
95 enum u_logging_level log_level;
96
97 //! Frame interval that we are using.
99 } settings;
100
101 // Kept here for convenience.
102 struct xrt_system_compositor_info sys_info;
103
104 //! @todo Insert your own required members here
105
106 struct
107 {
108 struct null_comp_frame waited;
109 struct null_comp_frame rendering;
111};
112
113
114/*
115 *
116 * Functions and helpers.
117 *
118 */
119
120/*!
121 * Convenience function to convert an xrt_compositor to a null_compositor.
122 * (Down-cast helper.)
123 *
124 * @private @memberof null_compositor
125 * @ingroup comp_null
126 */
127static inline struct null_compositor *
129{
130 return (struct null_compositor *)xc;
131}
132
133/*!
134 * Spew level logging.
135 *
136 * @relates null_compositor
137 * @ingroup comp_null
138 */
139#define NULL_TRACE(c, ...) U_LOG_IFL_T(c->settings.log_level, __VA_ARGS__);
140
141/*!
142 * Debug level logging.
143 *
144 * @relates null_compositor
145 */
146#define NULL_DEBUG(c, ...) U_LOG_IFL_D(c->settings.log_level, __VA_ARGS__);
147
148/*!
149 * Info level logging.
150 *
151 * @relates null_compositor
152 * @ingroup comp_null
153 */
154#define NULL_INFO(c, ...) U_LOG_IFL_I(c->settings.log_level, __VA_ARGS__);
155
156/*!
157 * Warn level logging.
158 *
159 * @relates null_compositor
160 * @ingroup comp_null
161 */
162#define NULL_WARN(c, ...) U_LOG_IFL_W(c->settings.log_level, __VA_ARGS__);
163
164/*!
165 * Error level logging.
166 *
167 * @relates null_compositor
168 * @ingroup comp_null
169 */
170#define NULL_ERROR(c, ...) U_LOG_IFL_E(c->settings.log_level, __VA_ARGS__);
171
172
173#ifdef __cplusplus
174}
175#endif
Helper implementation for native compositors.
u_logging_level
Logging level enum.
Definition u_logging.h:45
A simple compositor base that handles a lot of things for you.
Definition comp_base.h:69
Tracking frame state.
Definition null_compositor.h:64
Main compositor struct tying everything in the compositor together.
Definition null_compositor.h:81
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:98
struct u_pacing_compositor * upc
Pacing helper to drive us forward.
Definition null_compositor.h:91
struct null_compositor::@82 frame
struct xrt_view_config view_configs[XRT_MAX_COMPOSITOR_VIEW_CONFIGS_COUNT]
The supported view configurations.
Definition null_compositor.h:88
Compositor pacing helper interface.
Definition u_pacing.h:68
Common compositor client interface/base.
Definition xrt_compositor.h:1016
A single HMD or input device.
Definition xrt_device.h:310
Capabilities and information about the system compositor (and its wrapped native compositor,...
Definition xrt_compositor.h:2363
Definition xrt_compositor.h:2340
Basic logging functionality.
Shared pacing code.
Header for xrt_instance object.