Monado OpenXR Runtime
Loading...
Searching...
No Matches
comp_target.h
Go to the documentation of this file.
1// Copyright 2020-2026, Collabora, Ltd.
2// Copyright 2024-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Abstracted compositor rendering target.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup comp_main
9 */
10
11#pragma once
12
13#include "xrt/xrt_compiler.h"
14#include "xrt/xrt_defines.h"
15
16#include "vk/vk_helpers.h"
17
18#include "util/u_trace_marker.h"
19
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/*!
27 * For marking timepoints on a frame's lifetime, not a async event.
28 *
29 * @ingroup comp_main
30 */
32{
33 //! Woke up after sleeping in wait frame.
35
36 //! Began CPU side work for GPU.
38
39 //! Just before submitting work to the GPU.
41
42 //! Just after submitting work to the GPU.
44};
45
46/*!
47 * If the target should use the display timing information.
48 *
49 * @ingroup comp_main
50 */
52{
53 COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING = 0,
54 COMP_TARGET_USE_DISPLAY_IF_AVAILABLE = 1,
55};
56
57/*!
58 * Image and view pair for @ref comp_target.
59 *
60 * @ingroup comp_main
61 */
63{
64 VkImage handle;
65 VkImageView view;
66};
67
68/*!
69 * Information given in when creating the swapchain images,
70 * argument to @ref comp_target_create_images.
71 *
72 * @ingroup comp_main
73 */
75{
76 //! Image usage for the images, must be followed.
77 VkImageUsageFlags image_usage;
78
79 //! Acceptable formats for the images, must be followed.
81
82 // Number of formats.
83 uint32_t format_count;
84
85 //! Preferred extent, can be ignored by the target.
86 VkExtent2D extent;
87
88 //! Preferred color space, can be ignored by the target.
89 VkColorSpaceKHR color_space;
90
91 // Preferred present_mode, can be ignored by the target.
92 VkPresentModeKHR present_mode;
93};
94
95/*!
96 * Collection of semaphores needed for a target.
97 *
98 * @ingroup comp_main
99 */
101{
102 /*!
103 * Optional semaphore the target should signal when present is complete.
104 */
105 VkSemaphore present_complete;
106
107 /*!
108 * Semaphore the renderer (consuming this target)
109 * should signal when rendering is complete.
110 */
111 VkSemaphore render_complete;
112
113 /*!
114 * If true, @ref render_complete is a timeline
115 * semaphore instead of a binary semaphore.
116 */
118};
119
120/*!
121 * @brief A compositor target: where the compositor renders to.
122 *
123 * A target is essentially a swapchain, but it is such a overloaded term so
124 * we are differentiating swapchains that the compositor provides to clients and
125 * swapchains that the compositor renders by naming the latter to target.
126 *
127 * For design purposes, when amending this interface, remember that targets may not necessarily be backed by a
128 * swapchain in all cases, for instance with remote rendering.
129 *
130 * @ingroup comp_main
131 */
133{
134 //! Owning compositor.
136
137 //! Name of the backing system.
138 const char *name;
139
140 //! Current dimensions of the target.
141 uint32_t width, height;
142
143 //! The format that the renderpass targeting this target should use.
144 VkFormat format;
145
146 //! The final layout that the renderpass should leave this target in.
147 VkImageLayout final_layout;
148
149 //! Load ops required for present
150 VkAttachmentLoadOp present_load_op;
151
152 //! Number of images that this target has.
153 uint32_t image_count;
154 //! Array of images and image views for rendering.
156
157 //! Transformation of the current surface, required for pre-rotation
158 VkSurfaceTransformFlagBitsKHR surface_transform;
159
160 //! Holds semaphore information.
162
163 //! Whether wait_for_present is supported by this comp_target.
165
166 /*
167 *
168 * Vulkan functions.
169 *
170 */
171
172 /*!
173 * Do any initialization that is required to happen before Vulkan has
174 * been loaded.
175 */
177
178 /*!
179 * Do any initialization that requires Vulkan to be loaded, you need to
180 * call @ref create_images after calling this function.
181 */
182 bool (*init_post_vulkan)(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height);
183
184 /*!
185 * Is this target ready for image creation?
186 *
187 * Call before calling @ref create_images
188 */
190
191 /*!
192 * Is this target shared presentable image?
193 *
194 * Call before after @ref create_images
195 */
197
198 /*!
199 * Create or recreate the image(s) of the target, for swapchain based
200 * targets this will (re)create the swapchain.
201 *
202 * @param ct self
203 * @param create_info Image creation parameters
204 * @param present_queue The queue that will be used for presentation operations (must not be NULL)
205 *
206 * @pre @ref check_ready returns true
207 */
208 void (*create_images)(struct comp_target *ct,
209 const struct comp_target_create_images_info *create_info,
210 struct vk_bundle_queue *present_queue);
211
212 /*!
213 * Has this target successfully had images created?
214 *
215 * Call before calling @ref acquire - if false but @ref check_ready is
216 * true, you'll need to call @ref create_images.
217 */
219
220 /*!
221 * Acquire the next image for rendering.
222 *
223 * If @ref comp_target_semaphores::present_complete is not null,
224 * your use of this image should wait on it..
225 *
226 * @pre @ref has_images() returns true
227 */
228 VkResult (*acquire)(struct comp_target *ct, uint32_t *out_index);
229
230 /*!
231 * Present the image at index to the screen.
232 *
233 * @pre @ref acquire succeeded for the same @p semaphore and @p index you are passing
234 *
235 * @param ct self
236 * @param present_queue The Vulkan queue bundle being used for presentation (must not be NULL)
237 * @param index The swapchain image index to present
238 * @param timeline_semaphore_value The value to await on @ref comp_target_semaphores::render_complete
239 * if @ref comp_target_semaphores::render_complete_is_timeline is true.
240 * @param desired_present_time_ns The timestamp to present at, ideally.
241 * @param present_slop_ns TODO
242 */
243 VkResult (*present)(struct comp_target *ct,
244 struct vk_bundle_queue *present_queue,
245 uint32_t index,
246 uint64_t timeline_semaphore_value,
247 int64_t desired_present_time_ns,
248 int64_t present_slop_ns);
249
250 /*!
251 * Wait for the latest presented image to be displayed to the user.
252 *
253 * @param ct self
254 * @param timeout_ns The amount of time to wait for presentation to succeed.
255 */
256 VkResult (*wait_for_present)(struct comp_target *ct, time_duration_ns timeout_ns);
257
258 /*!
259 * Flush any WSI state before rendering.
260 */
261 void (*flush)(struct comp_target *ct);
262
263
264 /*
265 *
266 * Timing functions.
267 *
268 */
269
270 /*!
271 * Allocate a new frame ID, this does not make any predictions.
272 *
273 * Call @ref calc_frame_pacing afterwards with the returned ID. Between
274 * the two calls, the target may be given information that will
275 * influence the prediction, like @ref update_present_offset.
276 *
277 * @param[out] out_frame_id Id used to refer to this frame again.
278 */
279 void (*allocate_frame)(struct comp_target *ct, int64_t *out_frame_id);
280
281 /*!
282 * Update the target's estimate of the time between present (first
283 * pixel scanned out) and photons, affects subsequent frame pacing
284 * predictions. Call after @ref allocate_frame and before
285 * @ref calc_frame_pacing.
286 *
287 * @param frame_id The frame ID from @ref allocate_frame.
288 * @param present_to_display_offset_ns The improved estimate of the time between present and photons.
289 */
290 void (*update_present_offset)(struct comp_target *ct, int64_t frame_id, int64_t present_to_display_offset_ns);
291
292 /*!
293 * Predict when a frame previously allocated with @ref allocate_frame
294 * should be started and when it will be turned into photons by the
295 * hardware.
296 *
297 * @param frame_id The frame ID from @ref allocate_frame.
298 */
299 void (*calc_frame_pacing)(struct comp_target *ct,
300 int64_t frame_id,
301 int64_t *out_wake_up_time_ns,
302 int64_t *out_desired_present_time_ns,
303 int64_t *out_present_slop_ns,
304 int64_t *out_predicted_display_time_ns);
305
306 /*!
307 * The compositor tells the target a timing information about a single
308 * timing point on the frames lifecycle.
309 */
310 void (*mark_timing_point)(struct comp_target *ct,
311 enum comp_target_timing_point point,
312 int64_t frame_id,
313 int64_t when_ns);
314
315 /*!
316 * Update timing information for this target, this function should be
317 * lightweight and is called multiple times during a frame to make sure
318 * that we get the timing data as soon as possible.
319 */
320 VkResult (*update_timings)(struct comp_target *ct);
321
322 /*!
323 * Provide frame timing information about GPU start and stop time.
324 *
325 * Depend on when the information is delivered this can be called at any
326 * point of the following frames.
327 *
328 * @param[in] ct The compositor target.
329 * @param[in] frame_id The frame ID to record for.
330 * @param[in] gpu_start_ns When the GPU work startred.
331 * @param[in] gpu_end_ns When the GPU work stopped.
332 * @param[in] when_ns When the informatioon collected, nominally
333 * from @ref os_monotonic_get_ns.
334 *
335 * @see @ref frame-pacing.
336 */
337 void (*info_gpu)(
338 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns);
339
340 /*
341 *
342 * Misc functions.
343 *
344 */
345
346 /*!
347 * If the target can show a title (like a window) set the title.
348 */
349 void (*set_title)(struct comp_target *ct, const char *title);
350
351 /*!
352 * Get the available refresh rates for the compositor target
353 *
354 * @param ct The compositor target.
355 * @param count The number or refresh rates.
356 * @param refresh_rates_hz The refresh rates, in Hz. Must be allocated by caller, and have at least
357 * XRT_MAX_SUPPORTED_REFRESH_RATES elements
358 */
360 uint32_t *out_count,
361 float *out_display_refresh_rates_hz);
362
363 /*!
364 * Get the current refresh rate for the compositor target
365 *
366 * @param ct The compositor target.
367 * @param out_display_refresh_rate_hz The current refresh rate, in Hz
368 */
369 xrt_result_t (*get_current_refresh_rate)(struct comp_target *ct, float *out_display_refresh_rate_hz);
370
371 /*!
372 * Get the current refresh rate for the compositor target
373 *
374 * @param ct The compositor target.
375 * @param display_refresh_rate_hz The requested refresh rate, in Hz.
376 */
377 xrt_result_t (*request_refresh_rate)(struct comp_target *ct, float display_refresh_rate_hz);
378
379 /*!
380 * Queries if a particular queue supports presentation ops/cmds for the compositor target
381 *
382 * @param ct The compositor target.
383 * @param queue The vulkan queue to query
384 * @param out_supported If the @ref queue supports presentation ops/cmds
385 * for @ref ct present surface.
386 */
387 VkResult (*queue_supports_present)(struct comp_target *ct,
388 struct vk_bundle_queue *queue,
389 VkBool32 *out_supported);
390
391 /*!
392 * Destroys this target.
393 */
394 void (*destroy)(struct comp_target *ct);
395};
396
397/*!
398 * @copydoc comp_target::init_pre_vulkan
399 *
400 * @public @memberof comp_target
401 * @ingroup comp_main
402 */
403static inline bool
405{
406 COMP_TRACE_MARKER();
407
408 return ct->init_pre_vulkan(ct);
409}
410
411/*!
412 * @copydoc comp_target::init_post_vulkan
413 *
414 * @public @memberof comp_target
415 * @ingroup comp_main
416 */
417static inline bool
418comp_target_init_post_vulkan(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height)
419{
420 COMP_TRACE_MARKER();
421
422 return ct->init_post_vulkan(ct, preferred_width, preferred_height);
423}
424
425/*!
426 * @copydoc comp_target::check_ready
427 *
428 * @public @memberof comp_target
429 * @ingroup comp_main
430 */
431static inline bool
433{
434 COMP_TRACE_MARKER();
435
436 return ct->check_ready(ct);
437}
438
439/*!
440 * @copydoc comp_target::is_shared_presentable_image
441 *
442 * @public @memberof comp_target
443 * @ingroup comp_main
444 */
445static inline bool
447{
448 COMP_TRACE_MARKER();
449
450 return ct->is_shared_presentable_image(ct);
451}
452
453/*!
454 * @copydoc comp_target::create_images
455 *
456 * @public @memberof comp_target
457 * @ingroup comp_main
458 */
459static inline void
461 const struct comp_target_create_images_info *create_info,
462 struct vk_bundle_queue *present_queue)
463{
464 COMP_TRACE_MARKER();
465
466 ct->create_images(ct, create_info, present_queue);
467}
468
469/*!
470 * @copydoc comp_target::has_images
471 *
472 * @public @memberof comp_target
473 * @ingroup comp_main
474 */
475static inline bool
477{
478 COMP_TRACE_MARKER();
479
480 return ct->has_images(ct);
481}
482
483/*!
484 * @copydoc comp_target::acquire
485 *
486 * @public @memberof comp_target
487 * @ingroup comp_main
488 */
489static inline VkResult
490comp_target_acquire(struct comp_target *ct, uint32_t *out_index)
491{
492 COMP_TRACE_MARKER();
493
494 return ct->acquire(ct, out_index);
495}
496
497/*!
498 * @copydoc comp_target::present
499 *
500 * @public @memberof comp_target
501 * @ingroup comp_main
502 */
503static inline VkResult
505 struct vk_bundle_queue *present_queue,
506 uint32_t index,
507 uint64_t timeline_semaphore_value,
508 int64_t desired_present_time_ns,
509 int64_t present_slop_ns)
510
511{
512 COMP_TRACE_MARKER();
513
514 return ct->present( //
515 ct, //
516 present_queue, //
517 index, //
518 timeline_semaphore_value, //
519 desired_present_time_ns, //
520 present_slop_ns); //
521}
522
523/*!
524 * @copydoc comp_target::wait_for_present
525 *
526 * @public @memberof comp_target
527 * @ingroup comp_main
528 */
529static inline VkResult
531{
532 COMP_TRACE_MARKER();
533
534 return ct->wait_for_present( //
535 ct, //
536 timeout); //
537}
538
539/*!
540 * @copydoc comp_target::flush
541 *
542 * @public @memberof comp_target
543 * @ingroup comp_main
544 */
545static inline void
547{
548 COMP_TRACE_MARKER();
549
550 ct->flush(ct);
551}
552
553/*!
554 * @copydoc comp_target::allocate_frame
555 *
556 * @public @memberof comp_target
557 * @ingroup comp_main
558 */
559static inline void
560comp_target_allocate_frame(struct comp_target *ct, int64_t *out_frame_id)
561{
562 COMP_TRACE_MARKER();
563
564 ct->allocate_frame(ct, out_frame_id);
565}
566
567/*!
568 * @copydoc comp_target::update_present_offset
569 *
570 * @public @memberof comp_target
571 * @ingroup comp_main
572 */
573static inline void
574comp_target_update_present_offset(struct comp_target *ct, int64_t frame_id, int64_t present_to_display_offset_ns)
575{
576 COMP_TRACE_MARKER();
577
578 ct->update_present_offset(ct, frame_id, present_to_display_offset_ns);
579}
580
581/*!
582 * @copydoc comp_target::calc_frame_pacing
583 *
584 * @public @memberof comp_target
585 * @ingroup comp_main
586 */
587static inline void
589 int64_t frame_id,
590 int64_t *out_wake_up_time_ns,
591 int64_t *out_desired_present_time_ns,
592 int64_t *out_present_slop_ns,
593 int64_t *out_predicted_display_time_ns)
594{
595 COMP_TRACE_MARKER();
596
597 ct->calc_frame_pacing( //
598 ct, //
599 frame_id, //
600 out_wake_up_time_ns, //
601 out_desired_present_time_ns, //
602 out_present_slop_ns, //
603 out_predicted_display_time_ns); //
604}
605
606/*!
607 * Quick helper for marking wake up.
608 * @copydoc comp_target::mark_timing_point
609 *
610 * @public @memberof comp_target
611 * @ingroup comp_main
612 */
613static inline void
614comp_target_mark_wake_up(struct comp_target *ct, int64_t frame_id, int64_t when_woke_ns)
615{
616 COMP_TRACE_MARKER();
617
618 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_WAKE_UP, frame_id, when_woke_ns);
619}
620
621/*!
622 * Quick helper for marking begin.
623 * @copydoc comp_target::mark_timing_point
624 *
625 * @public @memberof comp_target
626 * @ingroup comp_main
627 */
628static inline void
629comp_target_mark_begin(struct comp_target *ct, int64_t frame_id, int64_t when_began_ns)
630{
631 COMP_TRACE_MARKER();
632
633 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_BEGIN, frame_id, when_began_ns);
634}
635
636/*!
637 * Quick helper for marking submit began.
638 * @copydoc comp_target::mark_timing_point
639 *
640 * @public @memberof comp_target
641 * @ingroup comp_main
642 */
643static inline void
644comp_target_mark_submit_begin(struct comp_target *ct, int64_t frame_id, int64_t when_submit_began_ns)
645{
646 COMP_TRACE_MARKER();
647
648 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN, frame_id, when_submit_began_ns);
649}
650
651/*!
652 * Quick helper for marking submit end.
653 * @copydoc comp_target::mark_timing_point
654 *
655 * @public @memberof comp_target
656 * @ingroup comp_main
657 */
658static inline void
659comp_target_mark_submit_end(struct comp_target *ct, int64_t frame_id, int64_t when_submit_end_ns)
660{
661 COMP_TRACE_MARKER();
662
663 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_END, frame_id, when_submit_end_ns);
664}
665
666/*!
667 * @copydoc comp_target::update_timings
668 *
669 * @public @memberof comp_target
670 * @ingroup comp_main
671 */
672static inline VkResult
674{
675 COMP_TRACE_MARKER();
676
677 return ct->update_timings(ct);
678}
679
680/*!
681 * @copydoc comp_target::info_gpu
682 *
683 * @public @memberof comp_target
684 * @ingroup comp_main
685 */
686static inline void
688 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
689{
690 COMP_TRACE_MARKER();
691
692 ct->info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, when_ns);
693}
694
695/*!
696 * @copydoc comp_target::set_title
697 *
698 * @public @memberof comp_target
699 * @ingroup comp_main
700 */
701static inline void
702comp_target_set_title(struct comp_target *ct, const char *title)
703{
704 COMP_TRACE_MARKER();
705
706 ct->set_title(ct, title);
707}
708
709/*!
710 * @copydoc comp_target::get_refresh_rates
711 *
712 * @public @memberof comp_target
713 * @ingroup comp_main
714 */
715static inline xrt_result_t
716comp_target_get_refresh_rates(struct comp_target *ct, uint32_t *count, float *rates)
717{
718 COMP_TRACE_MARKER();
719
720 return ct->get_refresh_rates(ct, count, rates);
721}
722
723/*!
724 * @copydoc comp_target::get_current_refresh_rate
725 *
726 * @public @memberof comp_target
727 * @ingroup comp_main
728 */
729static inline xrt_result_t
730comp_target_get_current_refresh_rate(struct comp_target *ct, float *out_display_refresh_rate_hz)
731{
732 COMP_TRACE_MARKER();
733
734 return ct->get_current_refresh_rate(ct, out_display_refresh_rate_hz);
735}
736
737/*!
738 * @copydoc comp_target::request_refresh_rate
739 *
740 * @public @memberof comp_target
741 * @ingroup comp_main
742 */
743static inline xrt_result_t
744comp_target_request_refresh_rate(struct comp_target *ct, float ratedisplay_refresh_rate_hz)
745{
746 COMP_TRACE_MARKER();
747
748 return ct->request_refresh_rate(ct, ratedisplay_refresh_rate_hz);
749}
750
751/*!
752 * @copydoc comp_target::queue_supports_present
753 *
754 * @public @memberof comp_target
755 * @ingroup comp_main
756 */
757static inline VkResult
758comp_target_queue_supports_present(struct comp_target *ct, struct vk_bundle_queue *queue, VkBool32 *out_supported)
759{
760 COMP_TRACE_MARKER();
761 return ct->queue_supports_present(ct, queue, out_supported);
762}
763
764/*!
765 * @copydoc comp_target::destroy
766 *
767 * Helper for calling through the function pointer: does a null check and sets
768 * ct_ptr to null if freed.
769 *
770 * @public @memberof comp_target
771 * @ingroup comp_main
772 */
773static inline void
775{
776 struct comp_target *ct = *ct_ptr;
777 if (ct == NULL) {
778 return;
779 }
780
781 ct->destroy(ct);
782 *ct_ptr = NULL;
783}
784
785/*!
786 * A factory of targets.
787 *
788 * @ingroup comp_main
789 */
791{
792 //! Pretty loggable name of target type.
793 const char *name;
794
795 //! Short all lowercase identifier for target type.
796 const char *identifier;
797
798 //! Does this factory require Vulkan to have been initialized.
800
801 /*!
802 * Is this a deferred target that can have it's creation
803 * delayed even further then after Vulkan initialization.
804 */
806
807 /*!
808 * Vulkan version that is required or 0 if no specific
809 * requirement, equivalent to VK_MAKE_VERSION(1, 0, 0)
810 */
812
813 //! Required instance extensions.
815
816 //! Required instance extension count.
818
819 //! Optional device extensions.
821
822 //! Optional device extension count.
824
825 /*!
826 * Checks if this target can be detected, is the preferred target or
827 * some other special consideration that this target should be used over
828 * all other targets.
829 *
830 * This is needed for NVIDIA direct mode which window must be created
831 * after vulkan has initialized.
832 */
833 bool (*detect)(const struct comp_target_factory *ctf, struct comp_compositor *c);
834
835 /*!
836 * Create a target from this factory, some targets requires Vulkan to
837 * have been initialised, see @ref requires_vulkan_for_create.
838 */
840 struct comp_compositor *c,
841 struct comp_target **out_ct);
842};
843
844/*!
845 * @copydoc comp_target_factory::detect
846 *
847 * @public @memberof comp_target_factory
848 * @ingroup comp_main
849 */
850static inline bool
852{
853 COMP_TRACE_MARKER();
854
855 return ctf->detect(ctf, c);
856}
857
858/*!
859 * @copydoc comp_target_factory::create_target
860 *
861 * @public @memberof comp_target_factory
862 * @ingroup comp_main
863 */
864static inline bool
866 struct comp_compositor *c,
867 struct comp_target **out_ct)
868{
869 COMP_TRACE_MARKER();
870
871 return ctf->create_target(ctf, c, out_ct);
872}
873
874
875#ifdef __cplusplus
876}
877#endif
int64_t time_duration_ns
Integer duration type in nanoseconds.
Definition u_time.h:88
static void comp_target_calc_frame_pacing(struct comp_target *ct, int64_t frame_id, int64_t *out_wake_up_time_ns, int64_t *out_desired_present_time_ns, int64_t *out_present_slop_ns, int64_t *out_predicted_display_time_ns)
Predict when a frame previously allocated with allocate_frame should be started and when it will be t...
Definition comp_target.h:588
static void comp_target_mark_wake_up(struct comp_target *ct, int64_t frame_id, int64_t when_woke_ns)
Quick helper for marking wake up.
Definition comp_target.h:614
static VkResult comp_target_wait_for_present(struct comp_target *ct, time_duration_ns timeout)
Wait for the latest presented image to be displayed to the user.
Definition comp_target.h:530
static void comp_target_destroy(struct comp_target **ct_ptr)
Destroys this target.
Definition comp_target.h:774
comp_target_display_timing_usage
If the target should use the display timing information.
Definition comp_target.h:52
static VkResult comp_target_acquire(struct comp_target *ct, uint32_t *out_index)
Acquire the next image for rendering.
Definition comp_target.h:490
static void comp_target_mark_submit_begin(struct comp_target *ct, int64_t frame_id, int64_t when_submit_began_ns)
Quick helper for marking submit began.
Definition comp_target.h:644
static VkResult comp_target_update_timings(struct comp_target *ct)
Update timing information for this target, this function should be lightweight and is called multiple...
Definition comp_target.h:673
static void comp_target_flush(struct comp_target *ct)
Flush any WSI state before rendering.
Definition comp_target.h:546
static VkResult comp_target_queue_supports_present(struct comp_target *ct, struct vk_bundle_queue *queue, VkBool32 *out_supported)
Queries if a particular queue supports presentation ops/cmds for the compositor target.
Definition comp_target.h:758
static bool comp_target_has_images(struct comp_target *ct)
Has this target successfully had images created?
Definition comp_target.h:476
static xrt_result_t comp_target_get_current_refresh_rate(struct comp_target *ct, float *out_display_refresh_rate_hz)
Get the current refresh rate for the compositor target.
Definition comp_target.h:730
static bool comp_target_is_shared_presentable_image(struct comp_target *ct)
Is this target shared presentable image?
Definition comp_target.h:446
static void comp_target_set_title(struct comp_target *ct, const char *title)
If the target can show a title (like a window) set the title.
Definition comp_target.h:702
static void comp_target_allocate_frame(struct comp_target *ct, int64_t *out_frame_id)
Allocate a new frame ID, this does not make any predictions.
Definition comp_target.h:560
static VkResult comp_target_present(struct comp_target *ct, struct vk_bundle_queue *present_queue, uint32_t index, uint64_t timeline_semaphore_value, int64_t desired_present_time_ns, int64_t present_slop_ns)
Present the image at index to the screen.
Definition comp_target.h:504
static xrt_result_t comp_target_get_refresh_rates(struct comp_target *ct, uint32_t *count, float *rates)
Get the available refresh rates for the compositor target.
Definition comp_target.h:716
static bool comp_target_check_ready(struct comp_target *ct)
Is this target ready for image creation?
Definition comp_target.h:432
static void comp_target_create_images(struct comp_target *ct, const struct comp_target_create_images_info *create_info, struct vk_bundle_queue *present_queue)
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the s...
Definition comp_target.h:460
comp_target_timing_point
For marking timepoints on a frame's lifetime, not a async event.
Definition comp_target.h:32
static void comp_target_mark_begin(struct comp_target *ct, int64_t frame_id, int64_t when_began_ns)
Quick helper for marking begin.
Definition comp_target.h:629
static bool comp_target_factory_detect(const struct comp_target_factory *ctf, struct comp_compositor *c)
Checks if this target can be detected, is the preferred target or some other special consideration th...
Definition comp_target.h:851
static void comp_target_mark_submit_end(struct comp_target *ct, int64_t frame_id, int64_t when_submit_end_ns)
Quick helper for marking submit end.
Definition comp_target.h:659
static xrt_result_t comp_target_request_refresh_rate(struct comp_target *ct, float ratedisplay_refresh_rate_hz)
Get the current refresh rate for the compositor target.
Definition comp_target.h:744
static bool comp_target_factory_create_target(const struct comp_target_factory *ctf, struct comp_compositor *c, struct comp_target **out_ct)
Create a target from this factory, some targets requires Vulkan to have been initialised,...
Definition comp_target.h:865
static bool comp_target_init_pre_vulkan(struct comp_target *ct)
Do any initialization that is required to happen before Vulkan has been loaded.
Definition comp_target.h:404
static void comp_target_info_gpu(struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
Provide frame timing information about GPU start and stop time.
Definition comp_target.h:687
static bool comp_target_init_post_vulkan(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height)
Do any initialization that requires Vulkan to be loaded, you need to call create_images after calling...
Definition comp_target.h:418
static void comp_target_update_present_offset(struct comp_target *ct, int64_t frame_id, int64_t present_to_display_offset_ns)
Update the target's estimate of the time between present (first pixel scanned out) and photons,...
Definition comp_target.h:574
@ COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN
Just before submitting work to the GPU.
Definition comp_target.h:40
@ COMP_TARGET_TIMING_POINT_BEGIN
Began CPU side work for GPU.
Definition comp_target.h:37
@ COMP_TARGET_TIMING_POINT_WAKE_UP
Woke up after sleeping in wait frame.
Definition comp_target.h:34
@ COMP_TARGET_TIMING_POINT_SUBMIT_END
Just after submitting work to the GPU.
Definition comp_target.h:43
enum xrt_result xrt_result_t
Result type used across Monado.
#define XRT_MAX_SWAPCHAIN_FORMATS
Max formats supported by a compositor, artificial limit.
Definition xrt_limits.h:58
Main compositor struct tying everything in the compositor together.
Definition comp_compositor.h:89
Information given in when creating the swapchain images, argument to comp_target_create_images.
Definition comp_target.h:75
VkColorSpaceKHR color_space
Preferred color space, can be ignored by the target.
Definition comp_target.h:89
VkExtent2D extent
Preferred extent, can be ignored by the target.
Definition comp_target.h:86
VkImageUsageFlags image_usage
Image usage for the images, must be followed.
Definition comp_target.h:77
VkFormat formats[XRT_MAX_SWAPCHAIN_FORMATS]
Acceptable formats for the images, must be followed.
Definition comp_target.h:80
A factory of targets.
Definition comp_target.h:791
const char ** required_instance_extensions
Required instance extensions.
Definition comp_target.h:814
bool requires_vulkan_for_create
Does this factory require Vulkan to have been initialized.
Definition comp_target.h:799
size_t required_instance_extension_count
Required instance extension count.
Definition comp_target.h:817
const char * identifier
Short all lowercase identifier for target type.
Definition comp_target.h:796
size_t optional_device_extension_count
Optional device extension count.
Definition comp_target.h:823
const char ** optional_device_extensions
Optional device extensions.
Definition comp_target.h:820
const char * name
Pretty loggable name of target type.
Definition comp_target.h:793
bool(* detect)(const struct comp_target_factory *ctf, struct comp_compositor *c)
Checks if this target can be detected, is the preferred target or some other special consideration th...
Definition comp_target.h:833
uint32_t required_instance_version
Vulkan version that is required or 0 if no specific requirement, equivalent to VK_MAKE_VERSION(1,...
Definition comp_target.h:811
bool is_deferred
Is this a deferred target that can have it's creation delayed even further then after Vulkan initiali...
Definition comp_target.h:805
bool(* create_target)(const struct comp_target_factory *ctf, struct comp_compositor *c, struct comp_target **out_ct)
Create a target from this factory, some targets requires Vulkan to have been initialised,...
Definition comp_target.h:839
Image and view pair for comp_target.
Definition comp_target.h:63
Collection of semaphores needed for a target.
Definition comp_target.h:101
VkSemaphore render_complete
Semaphore the renderer (consuming this target) should signal when rendering is complete.
Definition comp_target.h:111
VkSemaphore present_complete
Optional semaphore the target should signal when present is complete.
Definition comp_target.h:105
bool render_complete_is_timeline
If true, render_complete is a timeline semaphore instead of a binary semaphore.
Definition comp_target.h:117
A compositor target: where the compositor renders to.
Definition comp_target.h:133
bool(* has_images)(struct comp_target *ct)
Has this target successfully had images created?
Definition comp_target.h:218
void(* create_images)(struct comp_target *ct, const struct comp_target_create_images_info *create_info, struct vk_bundle_queue *present_queue)
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the s...
Definition comp_target.h:208
bool(* check_ready)(struct comp_target *ct)
Is this target ready for image creation?
Definition comp_target.h:189
void(* calc_frame_pacing)(struct comp_target *ct, int64_t frame_id, int64_t *out_wake_up_time_ns, int64_t *out_desired_present_time_ns, int64_t *out_present_slop_ns, int64_t *out_predicted_display_time_ns)
Predict when a frame previously allocated with allocate_frame should be started and when it will be t...
Definition comp_target.h:299
xrt_result_t(* request_refresh_rate)(struct comp_target *ct, float display_refresh_rate_hz)
Get the current refresh rate for the compositor target.
Definition comp_target.h:377
void(* flush)(struct comp_target *ct)
Flush any WSI state before rendering.
Definition comp_target.h:261
VkResult(* present)(struct comp_target *ct, struct vk_bundle_queue *present_queue, uint32_t index, uint64_t timeline_semaphore_value, int64_t desired_present_time_ns, int64_t present_slop_ns)
Present the image at index to the screen.
Definition comp_target.h:243
uint32_t width
Current dimensions of the target.
Definition comp_target.h:141
void(* set_title)(struct comp_target *ct, const char *title)
If the target can show a title (like a window) set the title.
Definition comp_target.h:349
bool(* init_post_vulkan)(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height)
Do any initialization that requires Vulkan to be loaded, you need to call create_images after calling...
Definition comp_target.h:182
void(* destroy)(struct comp_target *ct)
Destroys this target.
Definition comp_target.h:394
bool(* is_shared_presentable_image)(struct comp_target *ct)
Is this target shared presentable image?
Definition comp_target.h:196
struct comp_target_image * images
Array of images and image views for rendering.
Definition comp_target.h:155
VkResult(* wait_for_present)(struct comp_target *ct, time_duration_ns timeout_ns)
Wait for the latest presented image to be displayed to the user.
Definition comp_target.h:256
uint32_t image_count
Number of images that this target has.
Definition comp_target.h:153
VkResult(* acquire)(struct comp_target *ct, uint32_t *out_index)
Acquire the next image for rendering.
Definition comp_target.h:228
VkAttachmentLoadOp present_load_op
Load ops required for present.
Definition comp_target.h:150
void(* mark_timing_point)(struct comp_target *ct, enum comp_target_timing_point point, int64_t frame_id, int64_t when_ns)
The compositor tells the target a timing information about a single timing point on the frames lifecy...
Definition comp_target.h:310
void(* info_gpu)(struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
Provide frame timing information about GPU start and stop time.
Definition comp_target.h:337
void(* allocate_frame)(struct comp_target *ct, int64_t *out_frame_id)
Allocate a new frame ID, this does not make any predictions.
Definition comp_target.h:279
bool(* init_pre_vulkan)(struct comp_target *ct)
Do any initialization that is required to happen before Vulkan has been loaded.
Definition comp_target.h:176
VkResult(* update_timings)(struct comp_target *ct)
Update timing information for this target, this function should be lightweight and is called multiple...
Definition comp_target.h:320
const char * name
Name of the backing system.
Definition comp_target.h:138
struct comp_target_semaphores semaphores
Holds semaphore information.
Definition comp_target.h:161
VkSurfaceTransformFlagBitsKHR surface_transform
Transformation of the current surface, required for pre-rotation.
Definition comp_target.h:158
VkResult(* queue_supports_present)(struct comp_target *ct, struct vk_bundle_queue *queue, VkBool32 *out_supported)
Queries if a particular queue supports presentation ops/cmds for the compositor target.
Definition comp_target.h:387
xrt_result_t(* get_refresh_rates)(struct comp_target *ct, uint32_t *out_count, float *out_display_refresh_rates_hz)
Get the available refresh rates for the compositor target.
Definition comp_target.h:359
struct comp_compositor * c
Owning compositor.
Definition comp_target.h:135
bool wait_for_present_supported
Whether wait_for_present is supported by this comp_target.
Definition comp_target.h:164
VkFormat format
The format that the renderpass targeting this target should use.
Definition comp_target.h:144
xrt_result_t(* get_current_refresh_rate)(struct comp_target *ct, float *out_display_refresh_rate_hz)
Get the current refresh rate for the compositor target.
Definition comp_target.h:369
VkImageLayout final_layout
The final layout that the renderpass should leave this target in.
Definition comp_target.h:147
void(* update_present_offset)(struct comp_target *ct, int64_t frame_id, int64_t present_to_display_offset_ns)
Update the target's estimate of the time between present (first pixel scanned out) and photons,...
Definition comp_target.h:290
Definition vk_helpers.h:63
Tracing support code, see Tracing support.
Common Vulkan code header.
Header holding common defines.
Common defines and enums for XRT.