Monado OpenXR Runtime
comp_base.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 Helper implementation for native compositors.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 * @ingroup comp_util
10 */
11
12#pragma once
13
14#include "util/comp_swapchain.h"
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/*!
23 * Additional per-frame parameters.
24 *
25 * Independent of graphics API, swapchain implementation, etc.
26 *
27 * @ingroup comp_util
28 */
30{
31 //! Special case one layer projection/projection-depth fast-path.
33
34 //! fov as reported by device for the current submit.
35 struct xrt_fov fovs[XRT_MAX_VIEWS];
36 //! absolute pose as reported by device for the current submit.
37 struct xrt_pose poses[XRT_MAX_VIEWS];
38};
39
40/*!
41 * A simple compositor base that handles a lot of things for you.
42 *
43 * Things it handles for you:
44 *
45 * - App swapchains
46 * - App fences
47 * - Vulkan bundle (needed for swapchains and fences)
48 * - Layer tracking, not @ref xrt_compositor::layer_commit
49 * - Wait function, not @ref xrt_compositor::predict_frame
50 *
51 * Functions it does not implement:
52 *
53 * - @ref xrt_compositor::begin_session
54 * - @ref xrt_compositor::end_session
55 * - @ref xrt_compositor::predict_frame
56 * - @ref xrt_compositor::mark_frame
57 * - @ref xrt_compositor::begin_frame
58 * - @ref xrt_compositor::discard_frame
59 * - @ref xrt_compositor::layer_commit
60 * - @ref xrt_compositor::destroy
61 *
62 * Partially implements @ref xrt_compositor_native, meant to serve as
63 * the base of a main compositor implementation.
64 *
65 * @implements xrt_compositor_native
66 * @ingroup comp_util
67 */
69{
70 //! Base native compositor.
72
73 //! Vulkan bundle of useful things, used by swapchain and fence.
74 struct vk_bundle vk;
75
76 //! For default @ref xrt_compositor::wait_frame.
78
79 //! Swapchain garbage collector, used by swapchain, child class needs to call.
81
82 //! Collect layers for a single frame.
84
85 //! Parameters for a single frame.
87};
88
89
90/*
91 *
92 * Helper functions.
93 *
94 */
95
96/*!
97 * Convenience function to convert an xrt_compositor to a comp_base.
98 *
99 * @private @memberof comp_base
100 */
101static inline struct comp_base *
102comp_base(struct xrt_compositor *xc)
103{
104 return (struct comp_base *)xc;
105}
106
107
108/*
109 *
110 * 'Exported' functions.
111 *
112 */
113
114/*!
115 * Inits all of the supported functions and structs, except @ref vk_bundle.
116 *
117 * The bundle needs to be initialised before any of the implemented functions
118 * are call, but is not required to be initialised before this function is
119 * called.
120 *
121 * @protected @memberof comp_base
122 */
123void
124comp_base_init(struct comp_base *cb);
125
126/*!
127 * De-initialises all structs, except @ref vk_bundle.
128 *
129 * The bundle needs to be de-initialised by the sub-class.
130 *
131 * @private @memberof comp_base
132 */
133void
134comp_base_fini(struct comp_base *cb);
135
136
137#ifdef __cplusplus
138}
139#endif
Re-assemble a collection of composition layers submitted for a frame.
Independent swapchain implementation.
A simple compositor base that handles a lot of things for you.
Definition: comp_base.h:69
struct vk_bundle vk
Vulkan bundle of useful things, used by swapchain and fence.
Definition: comp_base.h:74
struct os_precise_sleeper sleeper
For default xrt_compositor::wait_frame.
Definition: comp_base.h:77
struct xrt_compositor_native base
Base native compositor.
Definition: comp_base.h:71
struct comp_swapchain_shared cscs
Swapchain garbage collector, used by swapchain, child class needs to call.
Definition: comp_base.h:80
void comp_base_init(struct comp_base *cb)
Inits all of the supported functions and structs, except vk_bundle.
Definition: comp_base.c:216
struct comp_frame_params frame_params
Parameters for a single frame.
Definition: comp_base.h:86
struct comp_layer_accum layer_accum
Collect layers for a single frame.
Definition: comp_base.h:83
Additional per-frame parameters.
Definition: comp_base.h:30
struct xrt_pose poses[XRT_MAX_VIEWS]
absolute pose as reported by device for the current submit.
Definition: comp_base.h:37
struct xrt_fov fovs[XRT_MAX_VIEWS]
fov as reported by device for the current submit.
Definition: comp_base.h:35
bool one_projection_layer_fast_path
Special case one layer projection/projection-depth fast-path.
Definition: comp_base.h:32
Collect a stack of layers - one frame's worth.
Definition: comp_layer_accum.h:88
Shared resource(s) and garbage collector for swapchains.
Definition: comp_swapchain.h:44
Definition: os_time.h:208
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition: vk_helpers.h:50
Main compositor server interface.
Definition: xrt_compositor.h:2224
Common compositor client interface/base.
Definition: xrt_compositor.h:988
Describes a projection matrix fov.
Definition: xrt_defines.h:486
A pose composed of a position and orientation.
Definition: xrt_defines.h:465