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 } cs;
217 } target;
218};
219
220/*!
221 * Initialize structure for use without the target step.
222 *
223 * @param[out] data Common render dispatch data. Will be zeroed and initialized.
224 * @param fast_path Whether we will use the "fast path" avoiding layer squashing.
225 * @param do_timewarp Whether timewarp (reprojection) will be performed.
226 */
227static inline void
228comp_render_initial_init(struct comp_render_dispatch_data *data, bool fast_path, bool do_timewarp)
229{
230 U_ZERO(data);
231
232 data->fast_path = fast_path;
233 data->do_timewarp = do_timewarp;
234}
235
236/*!
237 * Shared implementation setting up common view params between GFX and CS.
238 *
239 * Private implementation method, do not use outside of more-specific add_view calls!
240 *
241 * @param data Common render dispatch data, will be updated
242 * @param world_pose New world pose of this view.
243 * Populates @ref comp_render_view_data::world_pose
244 * @param eye_pose New eye pose of this view
245 * Populates @ref comp_render_view_data::eye_pose
246 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::target_pre_transform
247 * Populates @ref comp_render_view_data::fov
248 * @param squash_image Scratch image for this view
249 * Populates @ref comp_render_view_data::squash::image
250 * @param squash_viewport_data Where in the image to render the view
251 * Populates @ref comp_render_view_data::squash::viewport_data
252 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
253 * Populates @ref comp_render_view_data::squash_as_src::sample_view
254 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
255 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
256 * @param target_viewport_data Distortion target viewport data (aka target)
257 * Populates @ref comp_render_view_data::target::viewport_data
258
259 * @return Pointer to the @ref comp_render_view_data we have been populating, for additional setup.
260 */
261static inline struct comp_render_view_data *
264 const struct xrt_pose *world_pose_scanout_end,
265 const struct xrt_pose *eye_pose,
266 const struct xrt_fov *fov,
267 VkImage squash_image,
268 const struct render_viewport_data *squash_viewport_data)
269{
270 uint32_t i = data->squash_view_count++;
271
272 assert(i < ARRAY_SIZE(data->views));
273
274 struct comp_render_view_data *view = &data->views[i];
275
277
278 // Common
281 view->eye_pose = *eye_pose;
282 view->fov = *fov;
283
284 // When writing into the squash (aka scratch) image.
285 view->squash.image = squash_image;
286 view->squash.viewport_data = *squash_viewport_data;
287
288 return view;
289}
290
291static inline struct comp_render_view_data *
292comp_render_dispatch_add_target_view(struct comp_render_dispatch_data *data,
293 VkImageView squash_as_src_sample_view,
294 const struct xrt_normalized_rect *squash_as_src_norm_rect,
295 const struct render_viewport_data *target_viewport_data,
296 const render_scissor_data_t *target_scissor_data)
297{
298 uint32_t i = data->target.view_count++;
299
300 assert(i < data->squash_view_count);
301 assert(i < ARRAY_SIZE(data->views));
302
303 struct comp_render_view_data *view = &data->views[i];
304
305 // When using the squash (aka scratch) image as a source.
306 view->squash_as_src.sample_view = squash_as_src_sample_view;
307 view->squash_as_src.norm_rect = *squash_as_src_norm_rect;
308
309 // When writing into the target.
310 view->target.viewport_data = *target_viewport_data;
311 view->target.scissor_data = *target_scissor_data;
312
313 return view;
314}
315
316/*! @} */
317
318/*
319 *
320 * Gfx functions.
321 *
322 */
323
324/*!
325 *
326 * @defgroup comp_render_gfx
327 *
328 * GFX renderer control and dispatch - uses graphics shaders.
329 *
330 * Depends on the common @ref comp_render_dispatch_data, as well as the resources
331 * @ref render_gfx_target_resources (often called `rtr`), and @ref render_gfx.
332 *
333 * @ingroup comp_render
334 * @{
335 */
336
337/*!
338 * Initialize structure for use of the GFX renderer.
339 *
340 * @param[in,out] data Common render dispatch data.
341 * @param target_rtr GFX-specific resources for the entire framebuffer. Must be populated before call.
342 */
343static inline void
345{
346 // Error tracking.
347 data->target.initialized = true;
348
349 // When writing into the target.
350 data->target.gfx.rtr = target_rtr;
351}
352
353/*!
354 * Add view to the common data, as required by the GFX renderer.
355 *
356 * @param[in,out] data Common render dispatch data, will be updated
357 * @param world_pose New world pose of this view.
358 * Populates @ref comp_render_view_data::world_pose
359 * @param eye_pose New eye pose of this view
360 * Populates @ref comp_render_view_data::eye_pose
361 * @param fov Assigned to fov in the view data, and used to
362 * compute @ref comp_render_view_data::pre_transform - also
363 * populates @ref comp_render_view_data::fov
364 * @param layer_image Scratch image for this view
365 * Populates @ref comp_render_view_data::squash::image
366 * @param later_rtr Will be associated with this view. GFX-specific
367 * @param layer_viewport_data Where in the image to render the view
368 * Populates @ref comp_render_view_data::squash::viewport_data
369 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
370 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
371 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
372 * Populates @ref comp_render_view_data::squash_as_src::sample_view
373 * @param target_vertex_rot
374 * Populates @ref comp_render_view_data::target.gfx.vertex_rot
375 * @param target_viewport_data Distortion target viewport data (aka target)
376 * Populates @ref comp_render_view_data::target.viewport_data
377 */
378static inline void
381 const struct xrt_pose *world_pose_scanout_end,
382 const struct xrt_pose *eye_pose,
383 const struct xrt_fov *fov,
384 VkImage squash_image,
385 struct render_gfx_target_resources *squash_rtr,
386 const struct render_viewport_data *layer_viewport_data)
387{
389 data, //
392 eye_pose, //
393 fov, //
394 squash_image, //
395 layer_viewport_data); //
396
397 // When writing into the squash (aka scratch) image.
398 view->squash.gfx.rtr = squash_rtr;
399}
400
401static inline void
402comp_render_gfx_add_target_view(struct comp_render_dispatch_data *data,
403 VkImageView squash_as_src_sample_view,
404 const struct xrt_normalized_rect *squash_as_src_norm_rect,
405 const struct xrt_matrix_2x2 *target_vertex_rot,
406 const struct render_viewport_data *target_viewport_data,
407 const render_scissor_data_t *target_scissor_data)
408{
409 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
410 data, //
411 squash_as_src_sample_view, //
412 squash_as_src_norm_rect, //
413 target_viewport_data, //
414 target_scissor_data); //
415
416 // When writing into the target.
417 view->target.gfx.vertex_rot = *target_vertex_rot;
418}
419
420/*!
421 * Dispatch the (graphics pipeline) layer squasher, on any number of views.
422 *
423 * All source layer images needs to be in the correct image layout, no barrier
424 * is inserted for them. The target images are barriered from undefined to general
425 * so they can be written to, then to the layout defined by @p transition_to.
426 *
427 * Expected layouts:
428 *
429 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
430 * - Target images: Any
431 *
432 * After call layouts:
433 *
434 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
435 * - Target images: @p transition_to
436 *
437 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
438 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
439 *
440 * @param render Graphics renderer object
441 * @param[in] layers Layers to render, see note.
442 * @param[in] layer_count Number of elements in @p layers array.
443 * @param[in] d Common render dispatch data
444 * @param[in] transition_to Desired image layout for target images
445 */
446void
448 const struct comp_layer *layers,
449 uint32_t layer_count,
450 const struct comp_render_dispatch_data *d,
451 VkImageLayout transition_to);
452
453/*!
454 * Writes the needed commands to the @ref render_gfx to do a full composition with distortion.
455 *
456 * Takes a set of layers, new device poses, scratch
457 * images with associated @ref render_gfx_target_resources and writes the needed
458 * commands to the @ref render_gfx to do a full composition with distortion.
459 * The scratch images are optionally used to squash layers should it not be
460 * possible to do a @p comp_render_dispatch_data::fast_path. Will use the render
461 * passes of the targets which set the layout.
462 *
463 * The render passes of @p comp_render_dispatch_data::views::rtr must be created
464 * with a final_layout of `VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL` or there will
465 * be validation errors.
466 *
467 * Expected layouts:
468 *
469 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
470 * - Scratch images: Any (as per the @ref render_gfx_render_pass)
471 * - Target image: Any (as per the @ref render_gfx_render_pass)
472 *
473 * After call layouts:
474 *
475 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
476 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
477 * - Target image: What the render pass of @p rtr specifies.
478 *
479 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
480 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
481 *
482 * @param render GFX render object
483 * @param[in] layers Layers to render, see note.
484 * @param[in] layer_count Number of elements in @p layers array.
485 * @param[in] d Common render dispatch data
486 */
487void
489 const struct comp_layer *layers,
490 const uint32_t layer_count,
491 const struct comp_render_dispatch_data *d);
492
493/* end of comp_render_gfx group */
494
495/*! @} */
496
497
498/*
499 *
500 * CS functions.
501 *
502 */
503
504/*!
505 *
506 * @defgroup comp_render_cs
507 *
508 * CS renderer control and dispatch - uses compute shaders
509 *
510 * Depends on @ref render_compute
511 *
512 * @ingroup comp_render
513 * @{
514 */
515
516/*!
517 * Add the target info, as required by the CS renderer.
518 *
519 * @param[in,out] data Common render dispatch data.
520 * @param target_image Image to render into
521 * @param target_storage_view Corresponding image view
522 */
523static inline void
524comp_render_cs_add_target(struct comp_render_dispatch_data *data, VkImage target_image, VkImageView target_storage_view)
525{
526 // Error tracking.
527 data->target.initialized = true;
528
529 // When writing into the target.
530 data->target.cs.image = target_image;
531 data->target.cs.storage_view = target_storage_view;
532}
533
534/*!
535 * Add view to the common data, as required by the CS renderer.
536 *
537 * @param[in,out] data Common render dispatch data, will be updated
538 * @param world_pose_scanout_begin New world pose of this view.
539 * Populates @ref comp_render_view_data::world_pose
540 * @param world_pose_scanout_end New world pose of this view.
541 * Populates @ref comp_render_view_data::world_pose
542 * @param eye_pose New eye pose of this view
543 * Populates @ref comp_render_view_data::eye_pose_scanout_end
544 * @param fov Assigned to fov in the view data, and used to compute @ref comp_render_view_data::pre_transform.
545 * Populates @ref comp_render_view_data::fov
546 * @param squash_image Scratch image for this view
547 * Populates @ref comp_render_view_data::squash::image
548 * @param squash_storage_view Image view into the scratch image for storage, CS specific
549 * @param squash_viewport_data Where in the image to render the view
550 * Populates @ref comp_render_view_data::squash::viewport_data
551 * @param squash_as_src_sample_view The image view into the scratch image for sampling.
552 * Populates @ref comp_render_view_data::squash_as_src::sample_view
553 * @param squash_as_src_norm_rect How to transform when sampling from the scratch image.
554 * Populates @ref comp_render_view_data::squash_as_src::norm_rect
555 * @param target_viewport_data Distortion target viewport data (aka target)
556 * Populates @ref comp_render_view_data::target::viewport_data
557 */
558static inline void
561 const struct xrt_pose *world_pose_scanout_end,
562 const struct xrt_pose *eye_pose,
563 const struct xrt_fov *fov,
564 VkImage squash_image,
565 VkImageView squash_storage_view,
566 const struct render_viewport_data *squash_viewport_data)
567{
569 data, //
572 eye_pose, //
573 fov, //
574 squash_image, //
575 squash_viewport_data); //
576
577 // When writing into the squash (aka scratch) image.
578 view->squash.cs.storage_view = squash_storage_view;
579}
580
581static inline void
582comp_render_cs_add_target_view(struct comp_render_dispatch_data *data,
583 VkImageView squash_as_src_sample_view,
584 const struct xrt_normalized_rect *squash_as_src_norm_rect,
585 const struct render_viewport_data *target_viewport_data,
586 const render_scissor_data_t *target_scissor_data)
587{
588 struct comp_render_view_data *view = comp_render_dispatch_add_target_view( //
589 data, //
590 squash_as_src_sample_view, //
591 squash_as_src_norm_rect, //
592 target_viewport_data, //
593 target_scissor_data); //
594 (void)view;
595}
596
597/*!
598 * Dispatch the layer squasher for a single view.
599 *
600 * All source layer images and target image needs to be in the correct image
601 * layout, no barrier is inserted at all. The @p view_index argument is needed
602 * to grab a pre-allocated UBO from the @ref render_resources and to correctly
603 * select left/right data from various layers.
604 *
605 * Expected layouts:
606 *
607 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
608 * - Target images: `VK_IMAGE_LAYOUT_GENERAL`
609 *
610 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
611 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
612 *
613 * @param render Compute renderer object
614 * @param view_index Index of the view
615 * @param layers Layers to render, see note.
616 * @param layer_count Number of elements in @p layers array.
617 * @param pre_transform
618 * @param world_pose
619 * @param eye_pose
620 * @param target_image
621 * @param target_image_view
622 * @param target_view
623 * @param do_timewarp
624 */
625void
627 uint32_t view_index,
628 const struct comp_layer *layers,
629 const uint32_t layer_count,
632 const struct xrt_pose *world_pose_scanout_end,
633 const struct xrt_pose *eye_pose,
634 const VkImage target_image,
635 const VkImageView target_image_view,
636 const struct render_viewport_data *target_view,
637 bool do_timewarp);
638
639/*!
640 * Dispatch the layer squasher, on any number of views.
641 *
642 * All source layer images needs to be in the correct image layout, no barrier
643 * is inserted for them. The target images are barriered from undefined to general
644 * so they can be written to, then to the layout defined by @p transition_to.
645 *
646 * Expected layouts:
647 *
648 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
649 * - Target images: Any
650 *
651 * After call layouts:
652 *
653 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
654 * - Target images: @p transition_to
655 *
656 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
657 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
658 *
659 * @param render Compute renderer object
660 * @param[in] layers Layers to render, see note.
661 * @param[in] layer_count Number of elements in @p layers array.
662 * @param[in] d Common render dispatch data
663 * @param[in] transition_to Desired image layout for target images
664 */
665void
667 const struct comp_layer *layers,
668 const uint32_t layer_count,
669 const struct comp_render_dispatch_data *d,
670 VkImageLayout transition_to);
671
672/*!
673 * Write commands to @p render to do a full composition with distortion.
674 *
675 * Helper function that takes a set of layers, new device poses, a scratch
676 * images and writes the needed commands to the @ref render_compute to do a full
677 * composition with distortion. The scratch images are optionally used to squash
678 * layers should it not be possible to do a fast_path. Will insert barriers to
679 * change the scratch images and target images to the needed layout.
680 *
681 *
682 * Expected layouts:
683 *
684 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
685 * - Scratch images: Any
686 * - Target image: Any
687 *
688 * After call layouts:
689 *
690 * - Layer images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
691 * - Scratch images: `VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL`
692 * - Target image: `VK_IMAGE_LAYOUT_PRESENT_SRC_KHR`
693 *
694 * @note Swapchains in the @p layers must implement @ref comp_swapchain in
695 * addition to just @ref xrt_swapchain, as this function downcasts to @ref comp_swapchain !
696 *
697 * @param render Compute renderer object
698 * @param[in] layers Layers to render, see note.
699 * @param[in] layer_count Number of elements in @p layers array.
700 * @param[in] d Common render dispatch data
701 *
702 */
703void
705 const struct comp_layer *layers,
706 const uint32_t layer_count,
707 const struct comp_render_dispatch_data *d);
708
709/* end of comp_render_cs group */
710/*! @} */
711
712#ifdef __cplusplus
713}
714#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:262
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:228
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:559
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:762
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:524
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:570
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:810
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:379
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:344
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
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.