Monado OpenXR Runtime
Loading...
Searching...
No Matches
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 at the beginng of scanout.
76
77 //! New world pose of this view at the end of scanout.
79
80 //! New eye pose of this view.
82
83 /*!
84 * New fov of this view, used for the layer scratch image. Needs to
85 * match distortion parameters if distortion is used.
86 */
87 struct xrt_fov fov;
88
89 /*!
90 * Go from UV to tanangle for both the target and layer image since
91 * they share the same fov, this needs to match @p fov.
92 */
94
95 struct
96 {
97 /*!
98 * The layer image for this view (aka scratch image),
99 * used for barrier operations.
100 */
101 VkImage image;
102
103 /*!
104 * Pre-view layer target viewport_data (where in the image we
105 * should render the view).
106 */
108
109 struct
110 {
111 //! Per-view layer target resources.
113 } gfx;
114
115 struct
116 {
117 /*!
118 * View into layer image (aka scratch image), for used
119 * as a storage tagert of the CS (write) path.
120 */
121 VkImageView storage_view;
122 } cs;
123 } squash; // When used as a destination.
124
125 struct
126 {
127 /*!
128 * When sampling from the layer image (aka scratch image), how
129 * should we transform it to get to the pixels correctly.
130 *
131 * Ignored when doing a fast path and reading directly from
132 * the app projection layer.
133 */
135
136 /*!
137 * View into layer image (aka scratch image) when sampling the
138 * image, used for both GFX (read) and CS (read) paths.
139 *
140 * Ignored when doing a fast path and reading directly from
141 * the app projection layer.
142 */
143 VkImageView sample_view;
144
145 } squash_as_src; // The input to the target/distortion shaders.
146
147 struct
148 {
149 // Distortion target viewport data (aka target).
151
152 /*!
153 * Distortion target scissor data (aka target).
154 *
155 * Typically the scissor rect will be equal to @ref viewport_data.
156 */
158
159 struct
160 {
161 //! Distortion target vertex rotation information.
163 } gfx;
164 } target; // When used as a destination.
165};
166
167/*!
168 * The input data needed for a complete layer squashing distortion rendering
169 * to a target. This struct is shared between GFX and CS paths.
170 *
171 * @ingroup comp_render
172 */
174{
175 struct comp_render_view_data views[XRT_MAX_VIEWS];
176
177 /*!
178 * The number of squash views currently in this dispatch data.
179 */
181
182
183 //! Fast path can be disabled for mirroing so needs to be an argument.
185
186 //! Very often true, can be disabled for debugging.
188
189 struct
190 {
191 //! Has this struct been setup to use the target.
193
194 /*!
195 * The number of target views currently, when calling dispatch
196 * this has to be either zero or the same number as
197 * squash_view_count, see also the target.initialized field.
198 */
199 uint32_t view_count;
200
201 //! Members used only by GFX @ref comp_render_gfx
202 struct
203 {
204 //! The resources needed for the target.
207
208 //! Members used only by CS @ref comp_render_cs
209 struct
210 {
211 //! Target image for distortion, used for barrier.
212 VkImage image;
213
214 //! Target image view for distortion.
215 VkImageView storage_view;
216
217 //! Target image layout for distortion, the final layout to transition to.
218 VkImageLayout final_layout;
219 } cs;
220 } target;
221};
222
223/*!
224 * Initialize structure for use without the target step.
225 *
226 * @param[out] data Common render dispatch data. Will be zeroed and initialized.
227 * @param fast_path Whether we will use the "fast path" avoiding layer squashing.
228 * @param do_timewarp Whether timewarp (reprojection) will be performed.
229 */
230static inline void
231comp_render_initial_init(struct comp_render_dispatch_data *data, bool fast_path, bool do_timewarp)
232{
233 U_ZERO(data);
234
235 data->fast_path = fast_path;
236 data->do_timewarp = do_timewarp;
237}
238
239/*!
240 * Shared implementation setting up common view params between GFX and CS.
241 *
242 * Private implementation method, do not use outside of more-specific add_view calls!
243 *
244 * @param data Common render dispatch data, will be updated
245 * @param world_pose New world pose of this view.
246 * Populates @ref comp_render_view_data::world_pose
247 * @param eye_pose New eye pose of this view
248 * Populates @ref comp_render_view_data::eye_pose
249 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::target_pre_transform
250 * Populates @ref comp_render_view_data::fov
251 * @param squash_image Scratch image for this view
252 * Populates @ref comp_render_view_data::squash::image
253 * @param squash_viewport_data Where in the image to render the view
254 * Populates @ref comp_render_view_data::squash::viewport_data
255 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
256 * Populates @ref comp_render_view_data::squash_as_src::sample_view
257 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
258 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
259 * @param target_viewport_data Distortion target viewport data (aka target)
260 * Populates @ref comp_render_view_data::target::viewport_data
261
262 * @return Pointer to the @ref comp_render_view_data we have been populating, for additional setup.
263 */
264static inline struct comp_render_view_data *
267 const struct xrt_pose *world_pose_scanout_end,
268 const struct xrt_pose *eye_pose,
269 const struct xrt_fov *fov,
270 VkImage squash_image,
271 const struct render_viewport_data *squash_viewport_data)
272{
273 uint32_t i = data->squash_view_count++;
274
275 assert(i < ARRAY_SIZE(data->views));
276
277 struct comp_render_view_data *view = &data->views[i];
278
280
281 // Common
284 view->eye_pose = *eye_pose;
285 view->fov = *fov;
286
287 // When writing into the squash (aka scratch) image.
288 view->squash.image = squash_image;
289 view->squash.viewport_data = *squash_viewport_data;
290
291 return view;
292}
293
294static inline struct comp_render_view_data *
295comp_render_dispatch_add_target_view(struct comp_render_dispatch_data *data,
296 VkImageView squash_as_src_sample_view,
297 const struct xrt_normalized_rect *squash_as_src_norm_rect,
298 const struct render_viewport_data *target_viewport_data,
299 const render_scissor_data_t *target_scissor_data)
300{
301 uint32_t i = data->target.view_count++;
302
303 assert(i < data->squash_view_count);
304 assert(i < ARRAY_SIZE(data->views));
305
306 struct comp_render_view_data *view = &data->views[i];
307
308 // When using the squash (aka scratch) image as a source.
309 view->squash_as_src.sample_view = squash_as_src_sample_view;
310 view->squash_as_src.norm_rect = *squash_as_src_norm_rect;
311
312 // When writing into the target.
313 view->target.viewport_data = *target_viewport_data;
314 view->target.scissor_data = *target_scissor_data;
315
316 return view;
317}
318
319/*! @} */
320
321/*
322 *
323 * Gfx functions.
324 *
325 */
326
327/*!
328 *
329 * @defgroup comp_render_gfx
330 *
331 * GFX renderer control and dispatch - uses graphics shaders.
332 *
333 * Depends on the common @ref comp_render_dispatch_data, as well as the resources
334 * @ref render_gfx_target_resources (often called `rtr`), and @ref render_gfx.
335 *
336 * @ingroup comp_render
337 * @{
338 */
339
340/*!
341 * Initialize structure for use of the GFX renderer.
342 *
343 * @param[in,out] data Common render dispatch data.
344 * @param target_rtr GFX-specific resources for the entire framebuffer. Must be populated before call.
345 */
346static inline void
348{
349 // Error tracking.
350 data->target.initialized = true;
351
352 // When writing into the target.
353 data->target.gfx.rtr = target_rtr;
354}
355
356/*!
357 * Add view to the common data, as required by the GFX renderer.
358 *
359 * @param[in,out] data Common render dispatch data, will be updated
360 * @param world_pose New world pose of this view.
361 * Populates @ref comp_render_view_data::world_pose
362 * @param eye_pose New eye pose of this view
363 * Populates @ref comp_render_view_data::eye_pose
364 * @param fov Assigned to fov in the view data, and used to
365 * compute @ref comp_render_view_data::pre_transform - also
366 * populates @ref comp_render_view_data::fov
367 * @param layer_image Scratch image for this view
368 * Populates @ref comp_render_view_data::squash::image
369 * @param later_rtr Will be associated with this view. GFX-specific
370 * @param layer_viewport_data Where in the image to render the view
371 * Populates @ref comp_render_view_data::squash::viewport_data
372 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
373 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
374 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
375 * Populates @ref comp_render_view_data::squash_as_src::sample_view
376 * @param target_vertex_rot
377 * Populates @ref comp_render_view_data::target.gfx.vertex_rot
378 * @param target_viewport_data Distortion target viewport data (aka target)
379 * Populates @ref comp_render_view_data::target.viewport_data
380 */
381static inline void
384 const struct xrt_pose *world_pose_scanout_end,
385 const struct xrt_pose *eye_pose,
386 const struct xrt_fov *fov,
387 VkImage squash_image,
388 struct render_gfx_target_resources *squash_rtr,
389 const struct render_viewport_data *layer_viewport_data)
390{
392 data, //
395 eye_pose, //
396 fov, //
397 squash_image, //
398 layer_viewport_data); //
399
400 // When writing into the squash (aka scratch) image.
401 view->squash.gfx.rtr = squash_rtr;
402}
403
404static inline void
405comp_render_gfx_add_target_view(struct comp_render_dispatch_data *data,
406 VkImageView squash_as_src_sample_view,
407 const struct xrt_normalized_rect *squash_as_src_norm_rect,
408 const struct xrt_matrix_2x2 *target_vertex_rot,
409 const struct render_viewport_data *target_viewport_data,
410 const render_scissor_data_t *target_scissor_data)
411{
412 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
413 data, //
414 squash_as_src_sample_view, //
415 squash_as_src_norm_rect, //
416 target_viewport_data, //
417 target_scissor_data); //
418
419 // When writing into the target.
420 view->target.gfx.vertex_rot = *target_vertex_rot;
421}
422
423/*!
424 * Dispatch the (graphics pipeline) layer squasher, on any number of views.
425 *
426 * All source layer images needs to be in the correct image layout, no barrier
427 * is inserted for them. The target images are barriered from undefined to general
428 * so they can be written to, then to the layout defined by @p transition_to.
429 *
430 * Expected layouts:
431 *
432 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
433 * - Target images: Any
434 *
435 * After call layouts:
436 *
437 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
438 * - Target images: @p transition_to
439 *
440 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
441 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
442 *
443 * @param render Graphics renderer object
444 * @param[in] layers Layers to render, see note.
445 * @param[in] layer_count Number of elements in @p layers array.
446 * @param[in] d Common render dispatch data
447 * @param[in] transition_to Desired image layout for target images
448 */
449void
451 const struct comp_layer *layers,
452 uint32_t layer_count,
453 const struct comp_render_dispatch_data *d,
454 VkImageLayout transition_to);
455
456/*!
457 * Writes the needed commands to the @ref render_gfx to do a full composition with distortion.
458 *
459 * Takes a set of layers, new device poses, scratch
460 * images with associated @ref render_gfx_target_resources and writes the needed
461 * commands to the @ref render_gfx to do a full composition with distortion.
462 * The scratch images are optionally used to squash layers should it not be
463 * possible to do a @p comp_render_dispatch_data::fast_path. Will use the render
464 * passes of the targets which set the layout.
465 *
466 * The render passes of @p comp_render_dispatch_data::views::rtr must be created
467 * with a final_layout of `VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL` or there will
468 * be validation errors.
469 *
470 * Expected layouts:
471 *
472 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
473 * - Scratch images: Any (as per the @ref render_gfx_render_pass)
474 * - Target image: Any (as per the @ref render_gfx_render_pass)
475 *
476 * After call layouts:
477 *
478 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
479 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
480 * - Target image: What the render pass of @p rtr specifies.
481 *
482 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
483 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
484 *
485 * @param render GFX render object
486 * @param[in] layers Layers to render, see note.
487 * @param[in] layer_count Number of elements in @p layers array.
488 * @param[in] d Common render dispatch data
489 */
490void
492 const struct comp_layer *layers,
493 const uint32_t layer_count,
494 const struct comp_render_dispatch_data *d);
495
496/* end of comp_render_gfx group */
497
498/*! @} */
499
500
501/*
502 *
503 * CS functions.
504 *
505 */
506
507/*!
508 *
509 * @defgroup comp_render_cs
510 *
511 * CS renderer control and dispatch - uses compute shaders
512 *
513 * Depends on @ref render_compute
514 *
515 * @ingroup comp_render
516 * @{
517 */
518
519/*!
520 * Add the target info, as required by the CS renderer.
521 *
522 * @param[in,out] data Common render dispatch data.
523 * @param target_image Image to render into
524 * @param target_storage_view Corresponding image view
525 */
526static inline void
528 VkImage target_image,
529 VkImageView target_storage_view,
530 VkImageLayout target_final_layout)
531{
532 // Error tracking.
533 data->target.initialized = true;
534
535 // When writing into the target.
536 data->target.cs.image = target_image;
537 data->target.cs.storage_view = target_storage_view;
538 data->target.cs.final_layout = target_final_layout;
539}
540
541/*!
542 * Add view to the common data, as required by the CS renderer.
543 *
544 * @param[in,out] data Common render dispatch data, will be updated
545 * @param world_pose_scanout_begin New world pose of this view.
546 * Populates @ref comp_render_view_data::world_pose
547 * @param world_pose_scanout_end New world pose of this view.
548 * Populates @ref comp_render_view_data::world_pose
549 * @param eye_pose New eye pose of this view
550 * Populates @ref comp_render_view_data::eye_pose_scanout_end
551 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::pre_transform.
552 * Populates @ref comp_render_view_data::fov
553 * @param squash_image Scratch image for this view
554 * Populates @ref comp_render_view_data::squash::image
555 * @param squash_storage_view Image view into the scratch image for storage, CS specific
556 * @param squash_viewport_data Where in the image to render the view
557 * Populates @ref comp_render_view_data::squash::viewport_data
558 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
559 * Populates @ref comp_render_view_data::squash_as_src::sample_view
560 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
561 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
562 * @param target_viewport_data Distortion target viewport data (aka target)
563 * Populates @ref comp_render_view_data::target::viewport_data
564 */
565static inline void
568 const struct xrt_pose *world_pose_scanout_end,
569 const struct xrt_pose *eye_pose,
570 const struct xrt_fov *fov,
571 VkImage squash_image,
572 VkImageView squash_storage_view,
573 const struct render_viewport_data *squash_viewport_data)
574{
576 data, //
579 eye_pose, //
580 fov, //
581 squash_image, //
582 squash_viewport_data); //
583
584 // When writing into the squash (aka scratch) image.
585 view->squash.cs.storage_view = squash_storage_view;
586}
587
588static inline void
589comp_render_cs_add_target_view(struct comp_render_dispatch_data *data,
590 VkImageView squash_as_src_sample_view,
591 const struct xrt_normalized_rect *squash_as_src_norm_rect,
592 const struct render_viewport_data *target_viewport_data,
593 const render_scissor_data_t *target_scissor_data)
594{
595 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
596 data, //
597 squash_as_src_sample_view, //
598 squash_as_src_norm_rect, //
599 target_viewport_data, //
600 target_scissor_data); //
601 (void)view;
602}
603
604/*!
605 * Dispatch the layer squasher for a single view.
606 *
607 * All source layer images and target image needs to be in the correct image
608 * layout, no barrier is inserted at all. The @p view_index argument is needed
609 * to grab a pre-allocated UBO from the @ref render_resources and to correctly
610 * select left/right data from various layers.
611 *
612 * Expected layouts:
613 *
614 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
615 * - Target images: `VK_IMAGE_LAYOUT_GENERAL`
616 *
617 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
618 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
619 *
620 * @param render Compute renderer object
621 * @param view_index Index of the view
622 * @param layers Layers to render, see note.
623 * @param layer_count Number of elements in @p layers array.
624 * @param pre_transform
625 * @param world_pose
626 * @param eye_pose
627 * @param target_image
628 * @param target_image_view
629 * @param target_view
630 * @param do_timewarp
631 */
632void
634 uint32_t view_index,
635 const struct comp_layer *layers,
636 const uint32_t layer_count,
639 const struct xrt_pose *world_pose_scanout_end,
640 const struct xrt_pose *eye_pose,
641 const VkImage target_image,
642 const VkImageView target_image_view,
643 const struct render_viewport_data *target_view,
644 bool do_timewarp);
645
646/*!
647 * Dispatch the layer squasher, on any number of views.
648 *
649 * All source layer images needs to be in the correct image layout, no barrier
650 * is inserted for them. The target images are barriered from undefined to general
651 * so they can be written to, then to the layout defined by @p transition_to.
652 *
653 * Expected layouts:
654 *
655 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
656 * - Target images: Any
657 *
658 * After call layouts:
659 *
660 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
661 * - Target images: @p transition_to
662 *
663 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
664 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
665 *
666 * @param render Compute renderer object
667 * @param[in] layers Layers to render, see note.
668 * @param[in] layer_count Number of elements in @p layers array.
669 * @param[in] d Common render dispatch data
670 * @param[in] transition_to Desired image layout for target images
671 */
672void
674 const struct comp_layer *layers,
675 const uint32_t layer_count,
676 const struct comp_render_dispatch_data *d,
677 VkImageLayout transition_to);
678
679/*!
680 * Write commands to @p render to do a full composition with distortion.
681 *
682 * Helper function that takes a set of layers, new device poses, a scratch
683 * images and writes the needed commands to the @ref render_compute to do a full
684 * composition with distortion. The scratch images are optionally used to squash
685 * layers should it not be possible to do a fast_path. Will insert barriers to
686 * change the scratch images and target images to the needed layout.
687 *
688 *
689 * Expected layouts:
690 *
691 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
692 * - Scratch images: Any
693 * - Target image: Any
694 *
695 * After call layouts:
696 *
697 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
698 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
699 * - Target image: @ref comp_render_dispatch_data::target::cs::final_layout
700 *
701 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
702 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
703 *
704 * @param render Compute renderer object
705 * @param[in] layers Layers to render, see note.
706 * @param[in] layer_count Number of elements in @p layers array.
707 * @param[in] d Common render dispatch data
708 *
709 */
710void
712 const struct comp_layer *layers,
713 const uint32_t layer_count,
714 const struct comp_render_dispatch_data *d);
715
716/* end of comp_render_cs group */
717/*! @} */
718
719#ifdef __cplusplus
720}
721#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_scanout_begin, const struct xrt_pose *world_pose_scanout_end, 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:265
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:231
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:187
#define U_ZERO(PTR)
Zeroes the correct amount of memory based on the type pointed-to by the argument.
Definition u_misc.h:68
static void comp_render_cs_add_squash_view(struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose_scanout_begin, const struct xrt_pose *world_pose_scanout_end, 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:566
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:767
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_scanout_begin, const struct xrt_pose *world_pose_scanout_end, 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:575
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:815
static void comp_render_cs_add_target(struct comp_render_dispatch_data *data, VkImage target_image, VkImageView target_storage_view, VkImageLayout target_final_layout)
Add the target info, as required by the CS renderer.
Definition comp_render.h:527
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:901
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:694
static void comp_render_gfx_add_squash_view(struct comp_render_dispatch_data *data, const struct xrt_pose *world_pose_scanout_begin, const struct xrt_pose *world_pose_scanout_end, 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:382
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:347
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:174
VkImageView storage_view
Target image view for distortion.
Definition comp_render.h:215
VkImageLayout final_layout
Target image layout for distortion, the final layout to transition to.
Definition comp_render.h:218
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:199
struct render_gfx_target_resources * rtr
The resources needed for the target.
Definition comp_render.h:205
bool initialized
Has this struct been setup to use the target.
Definition comp_render.h:192
bool do_timewarp
Very often true, can be disabled for debugging.
Definition comp_render.h:187
VkImage image
Target image for distortion, used for barrier.
Definition comp_render.h:212
struct comp_render_dispatch_data::@111::@112 gfx
Members used only by GFX Comp_render_gfx.
uint32_t squash_view_count
The number of squash views currently in this dispatch data.
Definition comp_render.h:180
bool fast_path
Fast path can be disabled for mirroing so needs to be an argument.
Definition comp_render.h:184
struct comp_render_dispatch_data::@111::@113 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
struct xrt_pose world_pose_scanout_begin
New world pose of this view at the beginng of scanout.
Definition comp_render.h:75
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:121
struct xrt_fov fov
New fov of this view, used for the layer scratch image.
Definition comp_render.h:87
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:134
struct xrt_matrix_2x2 vertex_rot
Distortion target vertex rotation information.
Definition comp_render.h:162
render_scissor_data_t scissor_data
Distortion target scissor data (aka target).
Definition comp_render.h:157
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:143
struct render_gfx_target_resources * rtr
Per-view layer target resources.
Definition comp_render.h:112
struct xrt_pose eye_pose
New eye pose of this view.
Definition comp_render.h:81
VkImage image
The layer image for this view (aka scratch image), used for barrier operations.
Definition comp_render.h:101
struct xrt_pose world_pose_scanout_end
New world pose of this view at the end of scanout.
Definition comp_render.h:78
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:107
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:93
The semi-low level resources and operations required to squash layers and/or apply distortion for a s...
Definition render_interface.h:1171
Each rendering (render_gfx) render to one or more targets (render_gfx_target_resources),...
Definition render_interface.h:771
The low-level resources and operations to perform layer squashing and/or mesh distortion for a single...
Definition render_interface.h:834
The pure data information about a view that the renderer is rendering to.
Definition render_interface.h:672
Describes a projection matrix fov.
Definition xrt_defines.h:512
A tightly packed 2x2 matrix of floats.
Definition xrt_defines.h:539
Normalized image rectangle, coordinates and size in 0 .
Definition xrt_defines.h:480
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Very small misc utils.
#define ARRAY_SIZE(a)
Array size helper.
Definition xrt_compiler.h:59
Common defines and enums for XRT.
Include all of the Vulkan headers in one place, and cope with any "messy" includes implied by it.