Monado OpenXR Runtime
comp_layer_accum.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 Re-assemble a collection of composition layers submitted for a frame.
6 *
7 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
8 * @author Jakob Bornecrantz <jakob@collabora.com>
9 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
10 * @ingroup comp_util
11 */
12
13#pragma once
14
15#include "xrt/xrt_compositor.h"
16#include "xrt/xrt_limits.h"
17#include "xrt/xrt_results.h"
18#include <assert.h>
19#include <stdint.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25struct xrt_swapchain;
26
27/*!
28 * A single layer in a @ref comp_layer_accum.
29 *
30 * Independent of graphics API, swapchain implementation, etc.
31 *
32 * @ingroup comp_util
33 * @see comp_layer_accum
34 */
36{
37 /*!
38 * Up to two compositor swapchains referenced per view (color and depth) for a layer.
39 *
40 * Unused elements should be set to null.
41 */
42 struct xrt_swapchain *sc_array[XRT_MAX_VIEWS * 2];
43
44 /*!
45 * All basic (trivially-serializable) data associated with a layer.
46 */
48};
49
50
51/*!
52 * Get a (color) swapchain associated with a layer.
53 *
54 * @param cla self
55 * @param swapchain_index index of swapchain - typically this is 0 for most layers, the view index for projection.
56
57 * @public @memberof comp_layer
58 */
59struct xrt_swapchain *
60comp_layer_get_swapchain(const struct comp_layer *cl, uint32_t swapchain_index);
61
62
63/*!
64 * Get a depth swapchain associated with a (projection with depth) layer
65 *
66 * @param cla self
67 * @param swapchain_index index of **color** swapchain - typically this is the view index.
68 *
69 * @public @memberof comp_layer
70 */
71struct xrt_swapchain *
72comp_layer_get_depth_swapchain(const struct comp_layer *cl, uint32_t swapchain_index);
73
74
75
76/*!
77 * Collect a stack of layers - one frame's worth.
78 *
79 * Independent of graphics API, swapchain implementation, etc.
80 *
81 * Used to turn the step by step "one call per layer" compositor API back
82 * into a single structure per frame.
83 *
84 * @ingroup comp_util
85 * @see comp_layer
86 */
88{
89 //! The per frame data, supplied by `begin`.
91
92 //! All of the layers.
94
95 //! Number of submitted layers.
96 uint32_t layer_count;
97};
98
99/*!
100 * Reset all layer data and reset count to 0.
101 *
102 * Call at the beginning of a frame.
103 *
104 * @public @memberof comp_layer_accum
105 */
108
109/*!
110 * Accumulate swapchains and data for a projection layer for a frame.
111 *
112 * @public @memberof comp_layer_accum
113 */
116 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
117 const struct xrt_layer_data *data);
118
119/*!
120 * Accumulate swapchains and data for a projection layer (with depth image) for a frame.
121 *
122 * @public @memberof comp_layer_accum
123 */
126 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
127 struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS],
128 const struct xrt_layer_data *data);
129/*!
130 * Accumulate swapchain and data for a quad layer for a frame.
131 *
132 * @public @memberof comp_layer_accum
133 */
135comp_layer_accum_quad(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data);
136
137
138/*!
139 * Accumulate swapchain and data for a cube layer for a frame.
140 *
141 * @public @memberof comp_layer_accum
142 */
144comp_layer_accum_cube(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data);
145
146
147/*!
148 * Accumulate swapchain and data for a cylinder layer for a frame.
149 *
150 * @public @memberof comp_layer_accum
151 */
153comp_layer_accum_cylinder(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data);
154
155
156/*!
157 * Accumulate swapchain and data for an equirect(1) layer for a frame.
158 *
159 * @public @memberof comp_layer_accum
160 */
162comp_layer_accum_equirect1(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data);
163
164
165/*!
166 * Accumulate swapchain and data for an equirect2 layer for a frame.
167 *
168 * @public @memberof comp_layer_accum
169 */
171comp_layer_accum_equirect2(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data);
172
173
174/*!
175 * Get a (color) swapchain associated with a layer.
176 *
177 * @param cla self
178 * @param layer_index index of layer
179 * @param swapchain_index index of swapchain - typically this is 0 for most layers, the view index for projection.
180
181 * @public @memberof comp_layer_accum
182 */
183inline struct xrt_swapchain *
184comp_layer_accum_get_swapchain(const struct comp_layer_accum *cla, uint32_t layer_index, uint32_t swapchain_index)
185{
186 assert(layer_index < cla->layer_count);
187 return cla->layers[layer_index].sc_array[swapchain_index];
188}
189
190/*!
191 * Get a depth swapchain associated with a (projection with depth) layer
192 *
193 * @param cla self
194 * @param layer_index index of layer
195 * @param swapchain_index index of **color** swapchain - typically this is the view index.
196 *
197 * @public @memberof comp_layer_accum
198 */
199inline struct xrt_swapchain *
200comp_layer_accum_get_depth_swapchain(const struct comp_layer_accum *cla, uint32_t layer_index, uint32_t swapchain_index)
201{
202 assert(layer_index < cla->layer_count);
203 assert(cla->layers[layer_index].data.type == XRT_LAYER_PROJECTION_DEPTH);
204 return cla->layers[layer_index].sc_array[XRT_MAX_VIEWS + swapchain_index];
205}
206
207#ifdef __cplusplus
208}
209#endif
#define XRT_MAX_LAYERS
Max number of layers which can be handled at once.
Definition: xrt_limits.h:54
enum xrt_result xrt_result_t
Result type used across Monado.
Collect a stack of layers - one frame's worth.
Definition: comp_layer_accum.h:88
uint32_t layer_count
Number of submitted layers.
Definition: comp_layer_accum.h:96
xrt_result_t comp_layer_accum_cylinder(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Accumulate swapchain and data for a cylinder layer for a frame.
Definition: comp_layer_accum.c:114
struct xrt_layer_frame_data data
The per frame data, supplied by begin.
Definition: comp_layer_accum.h:90
xrt_result_t comp_layer_accum_equirect1(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Accumulate swapchain and data for an equirect(1) layer for a frame.
Definition: comp_layer_accum.c:120
xrt_result_t comp_layer_accum_begin(struct comp_layer_accum *cla, const struct xrt_layer_frame_data *data)
Reset all layer data and reset count to 0.
Definition: comp_layer_accum.c:50
xrt_result_t comp_layer_accum_projection_depth(struct comp_layer_accum *cla, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Accumulate swapchains and data for a projection layer (with depth image) for a frame.
Definition: comp_layer_accum.c:80
struct comp_layer layers[XRT_MAX_LAYERS]
All of the layers.
Definition: comp_layer_accum.h:93
xrt_result_t comp_layer_accum_quad(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Accumulate swapchain and data for a quad layer for a frame.
Definition: comp_layer_accum.c:102
xrt_result_t comp_layer_accum_equirect2(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Accumulate swapchain and data for an equirect2 layer for a frame.
Definition: comp_layer_accum.c:126
xrt_result_t comp_layer_accum_projection(struct comp_layer_accum *cla, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Accumulate swapchains and data for a projection layer for a frame.
Definition: comp_layer_accum.c:59
struct xrt_swapchain * comp_layer_accum_get_swapchain(const struct comp_layer_accum *cla, uint32_t layer_index, uint32_t swapchain_index)
Get a (color) swapchain associated with a layer.
Definition: comp_layer_accum.h:184
struct xrt_swapchain * comp_layer_accum_get_depth_swapchain(const struct comp_layer_accum *cla, uint32_t layer_index, uint32_t swapchain_index)
Get a depth swapchain associated with a (projection with depth) layer.
Definition: comp_layer_accum.h:200
xrt_result_t comp_layer_accum_cube(struct comp_layer_accum *cla, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Accumulate swapchain and data for a cube layer for a frame.
Definition: comp_layer_accum.c:108
A single layer in a comp_layer_accum.
Definition: comp_layer_accum.h:36
struct xrt_swapchain * comp_layer_get_depth_swapchain(const struct comp_layer *cl, uint32_t swapchain_index)
Get a depth swapchain associated with a (projection with depth) layer.
Definition: comp_layer_accum.c:42
struct xrt_swapchain * comp_layer_get_swapchain(const struct comp_layer *cl, uint32_t swapchain_index)
Get a (color) swapchain associated with a layer.
Definition: comp_layer_accum.c:35
struct xrt_layer_data data
All basic (trivially-serializable) data associated with a layer.
Definition: comp_layer_accum.h:47
struct xrt_swapchain * sc_array[XRT_MAX_VIEWS *2]
Up to two compositor swapchains referenced per view (color and depth) for a layer.
Definition: comp_layer_accum.h:42
All the pure data values associated with a composition layer.
Definition: xrt_compositor.h:394
enum xrt_layer_type type
Tag for compositor layer type.
Definition: xrt_compositor.h:398
Per frame data for the layer submission calls, used in xrt_compositor::layer_begin.
Definition: xrt_compositor.h:478
Common swapchain interface/base.
Definition: xrt_compositor.h:536
Header declaring XRT graphics interfaces.
Header for limits of the XRT interfaces.
Internal result type for XRT.