Monado OpenXR Runtime
comp_render.h
Go to the documentation of this file.
1// Copyright 2019-2024, Collabora, Ltd.
2// Copyright 2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Compositor render implementation.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
9 * @ingroup comp_util
10 */
11
12#pragma once
13
14#include "xrt/xrt_defines.h"
15#include "xrt/xrt_vulkan_includes.h" // IWYU pragma: keep
16
18#include "util/u_misc.h"
19
20#include <assert.h>
21
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27struct comp_layer;
28struct render_compute;
29struct render_gfx;
31
32
33/*!
34 * @defgroup comp_render
35 * @brief Renders, aka "layer squashers" and distortion application.
36 *
37 * Two parallel implementations of the render module exist:
38 *
39 * - one uses graphics shaders (aka GFX, @ref comp_render_gfx, @ref comp_render_gfx.c)
40 * - the other uses compute shaders (aka CS, @ref comp_render_cs, @ref comp_render_cs.c)
41 *
42 * Their abilities are effectively equivalent, although the graphics version disregards depth
43 * data, while the compute shader does use it somewhat.
44 *
45 * @note In general this module requires that swapchains in your supplied @ref comp_layer layers
46 * implement @ref comp_swapchain in addition to just @ref xrt_swapchain.
47 */
48
49/*
50 *
51 * Input data struct.
52 *
53 */
54
55/*!
56 * @name Input data structs
57 * @{
58 */
59
60/*!
61 * The input data needed for a single view, shared between both GFX and CS
62 * paths.
63 *
64 * To fully render a single view two "rendering" might be needed, the
65 * first being the layer squashing, and the second is the distortion step. The
66 * target for the layer squashing is referred to as "layer" or "scratch" and
67 * prefixed with `layer` if needs be. The other final step is referred to as
68 * "distortion target" or just "target", and is prefixed with `target`.
69 *
70 * @ingroup comp_render
71 */
73{
74 //! New world pose of this view.
76
77 //! New eye pose of this view.
79
80 /*!
81 * New fov of this view, used for the layer scratch image. Needs to
82 * match distortion parameters if distortion is used.
83 */
84 struct xrt_fov fov;
85
86 /*!
87 * Go from UV to tanangle for both the target and layer image since
88 * they share the same fov, this needs to match @p fov.
89 */
91
92 struct
93 {
94 /*!
95 * The layer image for this view (aka scratch image),
96 * used for barrier operations.
97 */
98 VkImage image;
99
100 /*!
101 * Pre-view layer target viewport_data (where in the image we
102 * should render the view).
103 */
105
106 struct
107 {
108 //! Per-view layer target resources.
110 } gfx;
111
112 struct
113 {
114 /*!
115 * View into layer image (aka scratch image), for used
116 * as a storage tagert of the CS (write) path.
117 */
118 VkImageView storage_view;
119 } cs;
120 } squash; // When used as a destination.
121
122 struct
123 {
124 /*!
125 * When sampling from the layer image (aka scratch image), how
126 * should we transform it to get to the pixels correctly.
127 *
128 * Ignored when doing a fast path and reading directly from
129 * the app projection layer.
130 */
132
133 /*!
134 * View into layer image (aka scratch image) when sampling the
135 * image, used for both GFX (read) and CS (read) paths.
136 *
137 * Ignored when doing a fast path and reading directly from
138 * the app projection layer.
139 */
140 VkImageView sample_view;
141
142 } squash_as_src; // The input to the target/distortion shaders.
143
144 struct
145 {
146 // Distortion target viewport data (aka target).
148
149 struct
150 {
151 //! Distortion target vertex rotation information.
153 } gfx;
154 } target; // When used as a destination.
155};
156
157/*!
158 * The input data needed for a complete layer squashing distortion rendering
159 * to a target. This struct is shared between GFX and CS paths.
160 *
161 * @ingroup comp_render
162 */
164{
165 struct comp_render_view_data views[XRT_MAX_VIEWS];
166
167 /*!
168 * The number of squash views currently in this dispatch data.
169 */
171
172
173 //! Fast path can be disabled for mirroing so needs to be an argument.
175
176 //! Very often true, can be disabled for debugging.
178
179 struct
180 {
181 //! Has this struct been setup to use the target.
183
184 /*!
185 * The number of target views currently, when calling dispatch
186 * this has to be either zero or the same number as
187 * squash_view_count, see also the target.initialized field.
188 */
189 uint32_t view_count;
190
191 //! Members used only by GFX @ref comp_render_gfx
192 struct
193 {
194 //! The resources needed for the target.
197
198 //! Members used only by CS @ref comp_render_cs
199 struct
200 {
201 //! Target image for distortion, used for barrier.
202 VkImage image;
203
204 //! Target image view for distortion.
205 VkImageView storage_view;
206 } cs;
207 } target;
208};
209
210/*!
211 * Initialize structure for use without the target step.
212 *
213 * @param[out] data Common render dispatch data. Will be zeroed and initialized.
214 * @param fast_path Whether we will use the "fast path" avoiding layer squashing.
215 * @param do_timewarp Whether timewarp (reprojection) will be performed.
216 */
217static inline void
218comp_render_initial_init(struct comp_render_dispatch_data *data, bool fast_path, bool do_timewarp)
219{
220 U_ZERO(data);
221
222 data->fast_path = fast_path;
223 data->do_timewarp = do_timewarp;
224}
225
226/*!
227 * Shared implementation setting up common view params between GFX and CS.
228 *
229 * Private implementation method, do not use outside of more-specific add_view calls!
230 *
231 * @param data Common render dispatch data, will be updated
232 * @param world_pose New world pose of this view.
233 * Populates @ref comp_render_view_data::world_pose
234 * @param eye_pose New eye pose of this view
235 * Populates @ref comp_render_view_data::eye_pose
236 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::target_pre_transform
237 * Populates @ref comp_render_view_data::fov
238 * @param squash_image Scratch image for this view
239 * Populates @ref comp_render_view_data::squash::image
240 * @param squash_viewport_data Where in the image to render the view
241 * Populates @ref comp_render_view_data::squash::viewport_data
242 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
243 * Populates @ref comp_render_view_data::squash_as_src::sample_view
244 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
245 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
246 * @param target_viewport_data Distortion target viewport data (aka target)
247 * Populates @ref comp_render_view_data::target::viewport_data
248
249 * @return Pointer to the @ref comp_render_view_data we have been populating, for additional setup.
250 */
251static inline struct comp_render_view_data *
253 const struct xrt_pose *world_pose,
254 const struct xrt_pose *eye_pose,
255 const struct xrt_fov *fov,
256 VkImage squash_image,
257 const struct render_viewport_data *squash_viewport_data)
258{
259 uint32_t i = data->squash_view_count++;
260
261 assert(i < ARRAY_SIZE(data->views));
262
263 struct comp_render_view_data *view = &data->views[i];
264
266
267 // Common
268 view->world_pose = *world_pose;
269 view->eye_pose = *eye_pose;
270 view->fov = *fov;
271
272 // When writing into the squash (aka scratch) image.
273 view->squash.image = squash_image;
274 view->squash.viewport_data = *squash_viewport_data;
275
276 return view;
277}
278
279static inline struct comp_render_view_data *
280comp_render_dispatch_add_target_view(struct comp_render_dispatch_data *data,
281 VkImageView squash_as_src_sample_view,
282 const struct xrt_normalized_rect *squash_as_src_norm_rect,
283 const struct render_viewport_data *target_viewport_data)
284{
285 uint32_t i = data->target.view_count++;
286
287 assert(i < data->squash_view_count);
288 assert(i < ARRAY_SIZE(data->views));
289
290 struct comp_render_view_data *view = &data->views[i];
291
292 // When using the squash (aka scratch) image as a source.
293 view->squash_as_src.sample_view = squash_as_src_sample_view;
294 view->squash_as_src.norm_rect = *squash_as_src_norm_rect;
295
296 // When writing into the target.
297 view->target.viewport_data = *target_viewport_data;
298
299 return view;
300}
301
302/*! @} */
303
304/*
305 *
306 * Gfx functions.
307 *
308 */
309
310/*!
311 *
312 * @defgroup comp_render_gfx
313 *
314 * GFX renderer control and dispatch - uses graphics shaders.
315 *
316 * Depends on the common @ref comp_render_dispatch_data, as well as the resources
317 * @ref render_gfx_target_resources (often called `rtr`), and @ref render_gfx.
318 *
319 * @ingroup comp_render
320 * @{
321 */
322
323/*!
324 * Initialize structure for use of the GFX renderer.
325 *
326 * @param[in,out] data Common render dispatch data.
327 * @param target_rtr GFX-specific resources for the entire framebuffer. Must be populated before call.
328 */
329static inline void
331{
332 // Error tracking.
333 data->target.initialized = true;
334
335 // When writing into the target.
336 data->target.gfx.rtr = target_rtr;
337}
338
339/*!
340 * Add view to the common data, as required by the GFX renderer.
341 *
342 * @param[in,out] data Common render dispatch data, will be updated
343 * @param world_pose New world pose of this view.
344 * Populates @ref comp_render_view_data::world_pose
345 * @param eye_pose New eye pose of this view
346 * Populates @ref comp_render_view_data::eye_pose
347 * @param fov Assigned to fov in the view data, and used to
348 * compute @ref comp_render_view_data::pre_transform - also
349 * populates @ref comp_render_view_data::fov
350 * @param layer_image Scratch image for this view
351 * Populates @ref comp_render_view_data::squash::image
352 * @param later_rtr Will be associated with this view. GFX-specific
353 * @param layer_viewport_data Where in the image to render the view
354 * Populates @ref comp_render_view_data::squash::viewport_data
355 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
356 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
357 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
358 * Populates @ref comp_render_view_data::squash_as_src::sample_view
359 * @param target_vertex_rot
360 * Populates @ref comp_render_view_data::target.gfx.vertex_rot
361 * @param target_viewport_data Distortion target viewport data (aka target)
362 * Populates @ref comp_render_view_data::target.viewport_data
363 */
364static inline void
366 const struct xrt_pose *world_pose,
367 const struct xrt_pose *eye_pose,
368 const struct xrt_fov *fov,
369 VkImage squash_image,
370 struct render_gfx_target_resources *squash_rtr,
371 const struct render_viewport_data *layer_viewport_data)
372{
374 data, //
375 world_pose, //
376 eye_pose, //
377 fov, //
378 squash_image, //
379 layer_viewport_data); //
380
381 // When writing into the squash (aka scratch) image.
382 view->squash.gfx.rtr = squash_rtr;
383}
384
385static inline void
386comp_render_gfx_add_target_view(struct comp_render_dispatch_data *data,
387 VkImageView squash_as_src_sample_view,
388 const struct xrt_normalized_rect *squash_as_src_norm_rect,
389 const struct xrt_matrix_2x2 *target_vertex_rot,
390 const struct render_viewport_data *target_viewport_data)
391{
392 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
393 data, //
394 squash_as_src_sample_view, //
395 squash_as_src_norm_rect, //
396 target_viewport_data); //
397
398 // When writing into the target.
399 view->target.gfx.vertex_rot = *target_vertex_rot;
400}
401
402/*!
403 * Dispatch the (graphics pipeline) layer squasher, on any number of views.
404 *
405 * All source layer images needs to be in the correct image layout, no barrier
406 * is inserted for them. The target images are barriered from undefined to general
407 * so they can be written to, then to the layout defined by @p transition_to.
408 *
409 * Expected layouts:
410 *
411 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
412 * - Target images: Any
413 *
414 * After call layouts:
415 *
416 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
417 * - Target images: @p transition_to
418 *
419 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
420 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
421 *
422 * @param render Graphics renderer object
423 * @param[in] layers Layers to render, see note.
424 * @param[in] layer_count Number of elements in @p layers array.
425 * @param[in] d Common render dispatch data
426 * @param[in] transition_to Desired image layout for target images
427 */
428void
430 const struct comp_layer *layers,
431 uint32_t layer_count,
432 const struct comp_render_dispatch_data *d,
433 VkImageLayout transition_to);
434
435/*!
436 * Writes the needed commands to the @ref render_gfx to do a full composition with distortion.
437 *
438 * Takes a set of layers, new device poses, scratch
439 * images with associated @ref render_gfx_target_resources and writes the needed
440 * commands to the @ref render_gfx to do a full composition with distortion.
441 * The scratch images are optionally used to squash layers should it not be
442 * possible to do a @p comp_render_dispatch_data::fast_path. Will use the render
443 * passes of the targets which set the layout.
444 *
445 * The render passes of @p comp_render_dispatch_data::views::rtr must be created
446 * with a final_layout of `VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL` or there will
447 * be validation errors.
448 *
449 * Expected layouts:
450 *
451 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
452 * - Scratch images: Any (as per the @ref render_gfx_render_pass)
453 * - Target image: Any (as per the @ref render_gfx_render_pass)
454 *
455 * After call layouts:
456 *
457 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
458 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
459 * - Target image: What the render pass of @p rtr specifies.
460 *
461 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
462 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
463 *
464 * @param render GFX render object
465 * @param[in] layers Layers to render, see note.
466 * @param[in] layer_count Number of elements in @p layers array.
467 * @param[in] d Common render dispatch data
468 */
469void
471 const struct comp_layer *layers,
472 const uint32_t layer_count,
473 const struct comp_render_dispatch_data *d);
474
475/* end of comp_render_gfx group */
476
477/*! @} */
478
479
480/*
481 *
482 * CS functions.
483 *
484 */
485
486/*!
487 *
488 * @defgroup comp_render_cs
489 *
490 * CS renderer control and dispatch - uses compute shaders
491 *
492 * Depends on @ref render_compute
493 *
494 * @ingroup comp_render
495 * @{
496 */
497
498/*!
499 * Add the target info, as required by the CS renderer.
500 *
501 * @param[in,out] data Common render dispatch data.
502 * @param target_image Image to render into
503 * @param target_storage_view Corresponding image view
504 */
505static inline void
506comp_render_cs_add_target(struct comp_render_dispatch_data *data, VkImage target_image, VkImageView target_storage_view)
507{
508 // Error tracking.
509 data->target.initialized = true;
510
511 // When writing into the target.
512 data->target.cs.image = target_image;
513 data->target.cs.storage_view = target_storage_view;
514}
515
516/*!
517 * Add view to the common data, as required by the CS renderer.
518 *
519 * @param[in,out] data Common render dispatch data, will be updated
520 * @param world_pose New world pose of this view.
521 * Populates @ref comp_render_view_data::world_pose
522 * @param eye_pose New eye pose of this view
523 * Populates @ref comp_render_view_data::eye_pose
524 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::pre_transform.
525 * Populates @ref comp_render_view_data::fov
526 * @param squash_image Scratch image for this view
527 * Populates @ref comp_render_view_data::squash::image
528 * @param squash_storage_view Image view into the scratch image for storage, CS specific
529 * @param squash_viewport_data Where in the image to render the view
530 * Populates @ref comp_render_view_data::squash::viewport_data
531 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
532 * Populates @ref comp_render_view_data::squash_as_src::sample_view
533 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
534 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
535 * @param target_viewport_data Distortion target viewport data (aka target)
536 * Populates @ref comp_render_view_data::target::viewport_data
537 */
538static inline void
540 const struct xrt_pose *world_pose,
541 const struct xrt_pose *eye_pose,
542 const struct xrt_fov *fov,
543 VkImage squash_image,
544 VkImageView squash_storage_view,
545 const struct render_viewport_data *squash_viewport_data)
546{
548 data, //
549 world_pose, //
550 eye_pose, //
551 fov, //
552 squash_image, //
553 squash_viewport_data); //
554
555 // When writing into the squash (aka scratch) image.
556 view->squash.cs.storage_view = squash_storage_view;
557}
558
559static inline void
560comp_render_cs_add_target_view(struct comp_render_dispatch_data *data,
561 VkImageView squash_as_src_sample_view,
562 const struct xrt_normalized_rect *squash_as_src_norm_rect,
563 const struct render_viewport_data *target_viewport_data)
564{
565 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
566 data, //
567 squash_as_src_sample_view, //
568 squash_as_src_norm_rect, //
569 target_viewport_data); //
570 (void)view;
571}
572
573/*!
574 * Dispatch the layer squasher for a single view.
575 *
576 * All source layer images and target image needs to be in the correct image
577 * layout, no barrier is inserted at all. The @p view_index argument is needed
578 * to grab a pre-allocated UBO from the @ref render_resources and to correctly
579 * select left/right data from various layers.
580 *
581 * Expected layouts:
582 *
583 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
584 * - Target images: `VK_IMAGE_LAYOUT_GENERAL`
585 *
586 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
587 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
588 *
589 * @param render Compute renderer object
590 * @param view_index Index of the view
591 * @param layers Layers to render, see note.
592 * @param layer_count Number of elements in @p layers array.
593 * @param pre_transform
594 * @param world_pose
595 * @param eye_pose
596 * @param target_image
597 * @param target_image_view
598 * @param target_view
599 * @param do_timewarp
600 */
601void
603 uint32_t view_index,
604 const struct comp_layer *layers,
605 const uint32_t layer_count,
607 const struct xrt_pose *world_pose,
608 const struct xrt_pose *eye_pose,
609 const VkImage target_image,
610 const VkImageView target_image_view,
611 const struct render_viewport_data *target_view,
612 bool do_timewarp);
613
614/*!
615 * Dispatch the layer squasher, on any number of views.
616 *
617 * All source layer images needs to be in the correct image layout, no barrier
618 * is inserted for them. The target images are barriered from undefined to general
619 * so they can be written to, then to the layout defined by @p transition_to.
620 *
621 * Expected layouts:
622 *
623 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
624 * - Target images: Any
625 *
626 * After call layouts:
627 *
628 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
629 * - Target images: @p transition_to
630 *
631 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
632 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
633 *
634 * @param render Compute renderer object
635 * @param[in] layers Layers to render, see note.
636 * @param[in] layer_count Number of elements in @p layers array.
637 * @param[in] d Common render dispatch data
638 * @param[in] transition_to Desired image layout for target images
639 */
640void
642 const struct comp_layer *layers,
643 const uint32_t layer_count,
644 const struct comp_render_dispatch_data *d,
645 VkImageLayout transition_to);
646
647/*!
648 * Write commands to @p render to do a full composition with distortion.
649 *
650 * Helper function that takes a set of layers, new device poses, a scratch
651 * images and writes the needed commands to the @ref render_compute to do a full
652 * composition with distortion. The scratch images are optionally used to squash
653 * layers should it not be possible to do a fast_path. Will insert barriers to
654 * change the scratch images and target images to the needed layout.
655 *
656 *
657 * Expected layouts:
658 *
659 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
660 * - Scratch images: Any
661 * - Target image: Any
662 *
663 * After call layouts:
664 *
665 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
666 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
667 * - Target image: `VK_IMAGE_LAYOUT_PRESENT_SRC_KHR`
668 *
669 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
670 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
671 *
672 * @param render Compute renderer object
673 * @param[in] layers Layers to render, see note.
674 * @param[in] layer_count Number of elements in @p layers array.
675 * @param[in] d Common render dispatch data
676 *
677 */
678void
680 const struct comp_layer *layers,
681 const uint32_t layer_count,
682 const struct comp_render_dispatch_data *d);
683
684/* end of comp_render_cs group */
685/*! @} */
686
687#ifdef __cplusplus
688}
689#endif
static struct comp_render_view_data * comp_render_dispatch_add_squash_view(struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const struct xrt_fov *fov, VkImage squash_image, const struct render_viewport_data *squash_viewport_data)
Shared implementation setting up common view params between GFX and CS.
Definition: comp_render.h:252
static void comp_render_initial_init(struct comp_render_dispatch_data *data, bool fast_path, bool do_timewarp)
Initialize structure for use without the target step.
Definition: comp_render.h:218
#define U_ZERO(PTR)
Zeroes the correct amount of memory based on the type pointed-to by the argument.
Definition: u_misc.h:68
void comp_render_cs_layers(struct render_compute *render, const struct comp_layer *layers, const uint32_t layer_count, const struct comp_render_dispatch_data *d, VkImageLayout transition_to)
Dispatch the layer squasher, on any number of views.
Definition: comp_render_cs.c:670
static void comp_render_cs_add_target(struct comp_render_dispatch_data *data, VkImage target_image, VkImageView target_storage_view)
Add the target info, as required by the CS renderer.
Definition: comp_render.h:506
void comp_render_cs_dispatch(struct render_compute *render, const struct comp_layer *layers, const uint32_t layer_count, const struct comp_render_dispatch_data *d)
Write commands to render to do a full composition with distortion.
Definition: comp_render_cs.c:717
static void comp_render_cs_add_squash_view(struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const struct xrt_fov *fov, VkImage squash_image, VkImageView squash_storage_view, const struct render_viewport_data *squash_viewport_data)
Add view to the common data, as required by the CS renderer.
Definition: comp_render.h:539
void comp_render_cs_layer(struct render_compute *render, uint32_t view_index, const struct comp_layer *layers, const uint32_t layer_count, const struct xrt_normalized_rect *pre_transform, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const VkImage target_image, const VkImageView target_image_view, const struct render_viewport_data *target_view, bool do_timewarp)
Dispatch the layer squasher for a single view.
Definition: comp_render_cs.c:499
void comp_render_gfx_dispatch(struct render_gfx *render, const struct comp_layer *layers, const uint32_t layer_count, const struct comp_render_dispatch_data *d)
Writes the needed commands to the render_gfx to do a full composition with distortion.
Definition: comp_render_gfx.c:884
void comp_render_gfx_layers(struct render_gfx *render, const struct comp_layer *layers, uint32_t layer_count, const struct comp_render_dispatch_data *d, VkImageLayout transition_to)
Dispatch the (graphics pipeline) layer squasher, on any number of views.
Definition: comp_render_gfx.c:678
static void comp_render_gfx_add_target(struct comp_render_dispatch_data *data, struct render_gfx_target_resources *target_rtr)
Initialize structure for use of the GFX renderer.
Definition: comp_render.h:330
static void comp_render_gfx_add_squash_view(struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose, const struct xrt_pose *eye_pose, const struct xrt_fov *fov, VkImage squash_image, struct render_gfx_target_resources *squash_rtr, const struct render_viewport_data *layer_viewport_data)
Add view to the common data, as required by the GFX renderer.
Definition: comp_render.h:365
void render_calc_uv_to_tangent_lengths_rect(const struct xrt_fov *fov, struct xrt_normalized_rect *out_rect)
This function constructs a transformation in the form of a normalized rect that lets you go from a UV...
Definition: render_util.c:127
The NEW compositor rendering code header.
A single layer in a comp_layer_accum.
Definition: comp_layer_accum.h:36
The input data needed for a complete layer squashing distortion rendering to a target.
Definition: comp_render.h:164
VkImageView storage_view
Target image view for distortion.
Definition: comp_render.h:205
uint32_t view_count
The number of target views currently, when calling dispatch this has to be either zero or the same nu...
Definition: comp_render.h:189
struct render_gfx_target_resources * rtr
The resources needed for the target.
Definition: comp_render.h:195
bool initialized
Has this struct been setup to use the target.
Definition: comp_render.h:182
bool do_timewarp
Very often true, can be disabled for debugging.
Definition: comp_render.h:177
struct comp_render_dispatch_data::@112::@113 gfx
Members used only by GFX Comp_render_gfx.
VkImage image
Target image for distortion, used for barrier.
Definition: comp_render.h:202
uint32_t squash_view_count
The number of squash views currently in this dispatch data.
Definition: comp_render.h:170
bool fast_path
Fast path can be disabled for mirroing so needs to be an argument.
Definition: comp_render.h:174
struct comp_render_dispatch_data::@112::@114 cs
Members used only by CS Comp_render_cs.
The input data needed for a single view, shared between both GFX and CS paths.
Definition: comp_render.h:73
VkImageView storage_view
View into layer image (aka scratch image), for used as a storage tagert of the CS (write) path.
Definition: comp_render.h:118
struct xrt_fov fov
New fov of this view, used for the layer scratch image.
Definition: comp_render.h:84
struct xrt_normalized_rect norm_rect
When sampling from the layer image (aka scratch image), how should we transform it to get to the pixe...
Definition: comp_render.h:131
struct xrt_matrix_2x2 vertex_rot
Distortion target vertex rotation information.
Definition: comp_render.h:152
VkImageView sample_view
View into layer image (aka scratch image) when sampling the image, used for both GFX (read) and CS (r...
Definition: comp_render.h:140
struct xrt_pose world_pose
New world pose of this view.
Definition: comp_render.h:75
struct render_gfx_target_resources * rtr
Per-view layer target resources.
Definition: comp_render.h:109
struct xrt_pose eye_pose
New eye pose of this view.
Definition: comp_render.h:78
VkImage image
The layer image for this view (aka scratch image), used for barrier operations.
Definition: comp_render.h:98
struct render_viewport_data viewport_data
Pre-view layer target viewport_data (where in the image we should render the view).
Definition: comp_render.h:104
struct xrt_normalized_rect pre_transform
Go from UV to tanangle for both the target and layer image since they share the same fov,...
Definition: comp_render.h:90
The semi-low level resources and operations required to squash layers and/or apply distortion for a s...
Definition: render_interface.h:1166
Each rendering (render_gfx) render to one or more targets (render_gfx_target_resources),...
Definition: render_interface.h:785
The low-level resources and operations to perform layer squashing and/or mesh distortion for a single...
Definition: render_interface.h:848
The pure data information about a view that the renderer is rendering to.
Definition: render_interface.h:687
Describes a projection matrix fov.
Definition: xrt_defines.h:483
A tightly packed 2x2 matrix of floats.
Definition: xrt_defines.h:510
Normalized image rectangle, coordinates and size in 0 .
Definition: xrt_defines.h:451
A pose composed of a position and orientation.
Definition: xrt_defines.h:463
Very small misc utils.
#define ARRAY_SIZE(a)
Array size helper.
Definition: xrt_compiler.h:56
Common defines and enums for XRT.
Include all of the Vulkan headers in one place, and cope with any "messy" includes implied by it.