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 * Predict when the next frame should be started and when it will be
272 * turned into photons by the hardware.
273 */
274 void (*calc_frame_pacing)(struct comp_target *ct,
275 int64_t *out_frame_id,
276 int64_t *out_wake_up_time_ns,
277 int64_t *out_desired_present_time_ns,
278 int64_t *out_present_slop_ns,
279 int64_t *out_predicted_display_time_ns);
280
281 /*!
282 * The compositor tells the target a timing information about a single
283 * timing point on the frames lifecycle.
284 */
285 void (*mark_timing_point)(struct comp_target *ct,
286 enum comp_target_timing_point point,
287 int64_t frame_id,
288 int64_t when_ns);
289
290 /*!
291 * Update timing information for this target, this function should be
292 * lightweight and is called multiple times during a frame to make sure
293 * that we get the timing data as soon as possible.
294 */
295 VkResult (*update_timings)(struct comp_target *ct);
296
297 /*!
298 * Provide frame timing information about GPU start and stop time.
299 *
300 * Depend on when the information is delivered this can be called at any
301 * point of the following frames.
302 *
303 * @param[in] ct The compositor target.
304 * @param[in] frame_id The frame ID to record for.
305 * @param[in] gpu_start_ns When the GPU work startred.
306 * @param[in] gpu_end_ns When the GPU work stopped.
307 * @param[in] when_ns When the informatioon collected, nominally
308 * from @ref os_monotonic_get_ns.
309 *
310 * @see @ref frame-pacing.
311 */
312 void (*info_gpu)(
313 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns);
314
315 /*
316 *
317 * Misc functions.
318 *
319 */
320
321 /*!
322 * If the target can show a title (like a window) set the title.
323 */
324 void (*set_title)(struct comp_target *ct, const char *title);
325
326 /*!
327 * Get the available refresh rates for the compositor target
328 *
329 * @param ct The compositor target.
330 * @param count The number or refresh rates.
331 * @param refresh_rates_hz The refresh rates, in Hz. Must be allocated by caller, and have at least
332 * XRT_MAX_SUPPORTED_REFRESH_RATES elements
333 */
335 uint32_t *out_count,
336 float *out_display_refresh_rates_hz);
337
338 /*!
339 * Get the current refresh rate for the compositor target
340 *
341 * @param ct The compositor target.
342 * @param out_display_refresh_rate_hz The current refresh rate, in Hz
343 */
344 xrt_result_t (*get_current_refresh_rate)(struct comp_target *ct, float *out_display_refresh_rate_hz);
345
346 /*!
347 * Get the current refresh rate for the compositor target
348 *
349 * @param ct The compositor target.
350 * @param display_refresh_rate_hz The requested refresh rate, in Hz.
351 */
352 xrt_result_t (*request_refresh_rate)(struct comp_target *ct, float display_refresh_rate_hz);
353
354 /*!
355 * Queries if a particular queue supports presentation ops/cmds for the compositor target
356 *
357 * @param ct The compositor target.
358 * @param queue The vulkan queue to query
359 * @param out_supported If the @ref queue supports presentation ops/cmds
360 * for @ref ct present surface.
361 */
362 VkResult (*queue_supports_present)(struct comp_target *ct,
363 struct vk_bundle_queue *queue,
364 VkBool32 *out_supported);
365
366 /*!
367 * Destroys this target.
368 */
369 void (*destroy)(struct comp_target *ct);
370};
371
372/*!
373 * @copydoc comp_target::init_pre_vulkan
374 *
375 * @public @memberof comp_target
376 * @ingroup comp_main
377 */
378static inline bool
380{
381 COMP_TRACE_MARKER();
382
383 return ct->init_pre_vulkan(ct);
384}
385
386/*!
387 * @copydoc comp_target::init_post_vulkan
388 *
389 * @public @memberof comp_target
390 * @ingroup comp_main
391 */
392static inline bool
393comp_target_init_post_vulkan(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height)
394{
395 COMP_TRACE_MARKER();
396
397 return ct->init_post_vulkan(ct, preferred_width, preferred_height);
398}
399
400/*!
401 * @copydoc comp_target::check_ready
402 *
403 * @public @memberof comp_target
404 * @ingroup comp_main
405 */
406static inline bool
408{
409 COMP_TRACE_MARKER();
410
411 return ct->check_ready(ct);
412}
413
414/*!
415 * @copydoc comp_target::is_shared_presentable_image
416 *
417 * @public @memberof comp_target
418 * @ingroup comp_main
419 */
420static inline bool
422{
423 COMP_TRACE_MARKER();
424
425 return ct->is_shared_presentable_image(ct);
426}
427
428/*!
429 * @copydoc comp_target::create_images
430 *
431 * @public @memberof comp_target
432 * @ingroup comp_main
433 */
434static inline void
436 const struct comp_target_create_images_info *create_info,
437 struct vk_bundle_queue *present_queue)
438{
439 COMP_TRACE_MARKER();
440
441 ct->create_images(ct, create_info, present_queue);
442}
443
444/*!
445 * @copydoc comp_target::has_images
446 *
447 * @public @memberof comp_target
448 * @ingroup comp_main
449 */
450static inline bool
452{
453 COMP_TRACE_MARKER();
454
455 return ct->has_images(ct);
456}
457
458/*!
459 * @copydoc comp_target::acquire
460 *
461 * @public @memberof comp_target
462 * @ingroup comp_main
463 */
464static inline VkResult
465comp_target_acquire(struct comp_target *ct, uint32_t *out_index)
466{
467 COMP_TRACE_MARKER();
468
469 return ct->acquire(ct, out_index);
470}
471
472/*!
473 * @copydoc comp_target::present
474 *
475 * @public @memberof comp_target
476 * @ingroup comp_main
477 */
478static inline VkResult
480 struct vk_bundle_queue *present_queue,
481 uint32_t index,
482 uint64_t timeline_semaphore_value,
483 int64_t desired_present_time_ns,
484 int64_t present_slop_ns)
485
486{
487 COMP_TRACE_MARKER();
488
489 return ct->present( //
490 ct, //
491 present_queue, //
492 index, //
493 timeline_semaphore_value, //
494 desired_present_time_ns, //
495 present_slop_ns); //
496}
497
498/*!
499 * @copydoc comp_target::wait_for_present
500 *
501 * @public @memberof comp_target
502 * @ingroup comp_main
503 */
504static inline VkResult
506{
507 COMP_TRACE_MARKER();
508
509 return ct->wait_for_present( //
510 ct, //
511 timeout); //
512}
513
514/*!
515 * @copydoc comp_target::flush
516 *
517 * @public @memberof comp_target
518 * @ingroup comp_main
519 */
520static inline void
522{
523 COMP_TRACE_MARKER();
524
525 ct->flush(ct);
526}
527
528/*!
529 * @copydoc comp_target::calc_frame_pacing
530 *
531 * @public @memberof comp_target
532 * @ingroup comp_main
533 */
534static inline void
536 int64_t *out_frame_id,
537 int64_t *out_wake_up_time_ns,
538 int64_t *out_desired_present_time_ns,
539 int64_t *out_present_slop_ns,
540 int64_t *out_predicted_display_time_ns)
541{
542 COMP_TRACE_MARKER();
543
544 ct->calc_frame_pacing( //
545 ct, //
546 out_frame_id, //
547 out_wake_up_time_ns, //
548 out_desired_present_time_ns, //
549 out_present_slop_ns, //
550 out_predicted_display_time_ns); //
551}
552
553/*!
554 * Quick helper for marking wake up.
555 * @copydoc comp_target::mark_timing_point
556 *
557 * @public @memberof comp_target
558 * @ingroup comp_main
559 */
560static inline void
561comp_target_mark_wake_up(struct comp_target *ct, int64_t frame_id, int64_t when_woke_ns)
562{
563 COMP_TRACE_MARKER();
564
565 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_WAKE_UP, frame_id, when_woke_ns);
566}
567
568/*!
569 * Quick helper for marking begin.
570 * @copydoc comp_target::mark_timing_point
571 *
572 * @public @memberof comp_target
573 * @ingroup comp_main
574 */
575static inline void
576comp_target_mark_begin(struct comp_target *ct, int64_t frame_id, int64_t when_began_ns)
577{
578 COMP_TRACE_MARKER();
579
580 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_BEGIN, frame_id, when_began_ns);
581}
582
583/*!
584 * Quick helper for marking submit began.
585 * @copydoc comp_target::mark_timing_point
586 *
587 * @public @memberof comp_target
588 * @ingroup comp_main
589 */
590static inline void
591comp_target_mark_submit_begin(struct comp_target *ct, int64_t frame_id, int64_t when_submit_began_ns)
592{
593 COMP_TRACE_MARKER();
594
595 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN, frame_id, when_submit_began_ns);
596}
597
598/*!
599 * Quick helper for marking submit end.
600 * @copydoc comp_target::mark_timing_point
601 *
602 * @public @memberof comp_target
603 * @ingroup comp_main
604 */
605static inline void
606comp_target_mark_submit_end(struct comp_target *ct, int64_t frame_id, int64_t when_submit_end_ns)
607{
608 COMP_TRACE_MARKER();
609
610 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_END, frame_id, when_submit_end_ns);
611}
612
613/*!
614 * @copydoc comp_target::update_timings
615 *
616 * @public @memberof comp_target
617 * @ingroup comp_main
618 */
619static inline VkResult
621{
622 COMP_TRACE_MARKER();
623
624 return ct->update_timings(ct);
625}
626
627/*!
628 * @copydoc comp_target::info_gpu
629 *
630 * @public @memberof comp_target
631 * @ingroup comp_main
632 */
633static inline void
635 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
636{
637 COMP_TRACE_MARKER();
638
639 ct->info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, when_ns);
640}
641
642/*!
643 * @copydoc comp_target::set_title
644 *
645 * @public @memberof comp_target
646 * @ingroup comp_main
647 */
648static inline void
649comp_target_set_title(struct comp_target *ct, const char *title)
650{
651 COMP_TRACE_MARKER();
652
653 ct->set_title(ct, title);
654}
655
656/*!
657 * @copydoc comp_target::get_refresh_rates
658 *
659 * @public @memberof comp_target
660 * @ingroup comp_main
661 */
662static inline xrt_result_t
663comp_target_get_refresh_rates(struct comp_target *ct, uint32_t *count, float *rates)
664{
665 COMP_TRACE_MARKER();
666
667 return ct->get_refresh_rates(ct, count, rates);
668}
669
670/*!
671 * @copydoc comp_target::get_current_refresh_rate
672 *
673 * @public @memberof comp_target
674 * @ingroup comp_main
675 */
676static inline xrt_result_t
677comp_target_get_current_refresh_rate(struct comp_target *ct, float *out_display_refresh_rate_hz)
678{
679 COMP_TRACE_MARKER();
680
681 return ct->get_current_refresh_rate(ct, out_display_refresh_rate_hz);
682}
683
684/*!
685 * @copydoc comp_target::request_refresh_rate
686 *
687 * @public @memberof comp_target
688 * @ingroup comp_main
689 */
690static inline xrt_result_t
691comp_target_request_refresh_rate(struct comp_target *ct, float ratedisplay_refresh_rate_hz)
692{
693 COMP_TRACE_MARKER();
694
695 return ct->request_refresh_rate(ct, ratedisplay_refresh_rate_hz);
696}
697
698/*!
699 * @copydoc comp_target::queue_supports_present
700 *
701 * @public @memberof comp_target
702 * @ingroup comp_main
703 */
704static inline VkResult
705comp_target_queue_supports_present(struct comp_target *ct, struct vk_bundle_queue *queue, VkBool32 *out_supported)
706{
707 COMP_TRACE_MARKER();
708 return ct->queue_supports_present(ct, queue, out_supported);
709}
710
711/*!
712 * @copydoc comp_target::destroy
713 *
714 * Helper for calling through the function pointer: does a null check and sets
715 * ct_ptr to null if freed.
716 *
717 * @public @memberof comp_target
718 * @ingroup comp_main
719 */
720static inline void
722{
723 struct comp_target *ct = *ct_ptr;
724 if (ct == NULL) {
725 return;
726 }
727
728 ct->destroy(ct);
729 *ct_ptr = NULL;
730}
731
732/*!
733 * A factory of targets.
734 *
735 * @ingroup comp_main
736 */
738{
739 //! Pretty loggable name of target type.
740 const char *name;
741
742 //! Short all lowercase identifier for target type.
743 const char *identifier;
744
745 //! Does this factory require Vulkan to have been initialized.
747
748 /*!
749 * Is this a deferred target that can have it's creation
750 * delayed even further then after Vulkan initialization.
751 */
753
754 /*!
755 * Vulkan version that is required or 0 if no specific
756 * requirement, equivalent to VK_MAKE_VERSION(1, 0, 0)
757 */
759
760 //! Required instance extensions.
762
763 //! Required instance extension count.
765
766 //! Optional device extensions.
768
769 //! Optional device extension count.
771
772 /*!
773 * Checks if this target can be detected, is the preferred target or
774 * some other special consideration that this target should be used over
775 * all other targets.
776 *
777 * This is needed for NVIDIA direct mode which window must be created
778 * after vulkan has initialized.
779 */
780 bool (*detect)(const struct comp_target_factory *ctf, struct comp_compositor *c);
781
782 /*!
783 * Create a target from this factory, some targets requires Vulkan to
784 * have been initialised, see @ref requires_vulkan_for_create.
785 */
787 struct comp_compositor *c,
788 struct comp_target **out_ct);
789};
790
791/*!
792 * @copydoc comp_target_factory::detect
793 *
794 * @public @memberof comp_target_factory
795 * @ingroup comp_main
796 */
797static inline bool
799{
800 COMP_TRACE_MARKER();
801
802 return ctf->detect(ctf, c);
803}
804
805/*!
806 * @copydoc comp_target_factory::create_target
807 *
808 * @public @memberof comp_target_factory
809 * @ingroup comp_main
810 */
811static inline bool
813 struct comp_compositor *c,
814 struct comp_target **out_ct)
815{
816 COMP_TRACE_MARKER();
817
818 return ctf->create_target(ctf, c, out_ct);
819}
820
821
822#ifdef __cplusplus
823}
824#endif
int64_t time_duration_ns
Integer duration type in nanoseconds.
Definition u_time.h:88
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:561
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:505
static void comp_target_destroy(struct comp_target **ct_ptr)
Destroys this target.
Definition comp_target.h:721
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:465
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:591
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:620
static void comp_target_flush(struct comp_target *ct)
Flush any WSI state before rendering.
Definition comp_target.h:521
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:705
static bool comp_target_has_images(struct comp_target *ct)
Has this target successfully had images created?
Definition comp_target.h:451
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:677
static bool comp_target_is_shared_presentable_image(struct comp_target *ct)
Is this target shared presentable image?
Definition comp_target.h:421
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:649
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:479
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:663
static bool comp_target_check_ready(struct comp_target *ct)
Is this target ready for image creation?
Definition comp_target.h:407
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:435
static void comp_target_calc_frame_pacing(struct comp_target *ct, int64_t *out_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 the next frame should be started and when it will be turned into photons by the hardware...
Definition comp_target.h:535
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:576
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:798
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:606
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:691
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:812
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:379
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:634
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:393
@ 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:738
const char ** required_instance_extensions
Required instance extensions.
Definition comp_target.h:761
bool requires_vulkan_for_create
Does this factory require Vulkan to have been initialized.
Definition comp_target.h:746
size_t required_instance_extension_count
Required instance extension count.
Definition comp_target.h:764
const char * identifier
Short all lowercase identifier for target type.
Definition comp_target.h:743
size_t optional_device_extension_count
Optional device extension count.
Definition comp_target.h:770
const char ** optional_device_extensions
Optional device extensions.
Definition comp_target.h:767
const char * name
Pretty loggable name of target type.
Definition comp_target.h:740
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:780
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:758
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:752
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:786
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
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:352
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:324
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:369
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:285
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:312
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:295
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
void(* calc_frame_pacing)(struct comp_target *ct, int64_t *out_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 the next frame should be started and when it will be turned into photons by the hardware...
Definition comp_target.h:274
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:362
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:334
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:344
VkImageLayout final_layout
The final layout that the renderpass should leave this target in.
Definition comp_target.h:147
Definition vk_helpers.h:62
Tracing support code, see Tracing support.
Common Vulkan code header.
Header holding common defines.
Common defines and enums for XRT.