Monado OpenXR Runtime
comp_target.h
Go to the documentation of this file.
1// Copyright 2020, Collabora, Ltd.
2// Copyright 2024-2025, 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 //! Number of images that this target has.
150 uint32_t image_count;
151 //! Array of images and image views for rendering.
153
154 //! Transformation of the current surface, required for pre-rotation
155 VkSurfaceTransformFlagBitsKHR surface_transform;
156
157 // Holds semaphore information.
158 struct comp_target_semaphores semaphores;
159
160 /*
161 *
162 * Vulkan functions.
163 *
164 */
165
166 /*!
167 * Do any initialization that is required to happen before Vulkan has
168 * been loaded.
169 */
171
172 /*!
173 * Do any initialization that requires Vulkan to be loaded, you need to
174 * call @ref create_images after calling this function.
175 */
176 bool (*init_post_vulkan)(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height);
177
178 /*!
179 * Is this target ready for image creation?
180 *
181 * Call before calling @ref create_images
182 */
184
185 /*!
186 * Create or recreate the image(s) of the target, for swapchain based
187 * targets this will (re)create the swapchain.
188 *
189 * @pre @ref check_ready returns true
190 */
191 void (*create_images)(struct comp_target *ct, const struct comp_target_create_images_info *create_info);
192
193 /*!
194 * Has this target successfully had images created?
195 *
196 * Call before calling @ref acquire - if false but @ref check_ready is
197 * true, you'll need to call @ref create_images.
198 */
200
201 /*!
202 * Acquire the next image for rendering.
203 *
204 * If @ref comp_target_semaphores::present_complete is not null,
205 * your use of this image should wait on it..
206 *
207 * @pre @ref has_images() returns true
208 */
209 VkResult (*acquire)(struct comp_target *ct, uint32_t *out_index);
210
211 /*!
212 * Present the image at index to the screen.
213 *
214 * @pre @ref acquire succeeded for the same @p semaphore and @p index you are passing
215 *
216 * @param ct self
217 * @param queue The Vulkan queue being used
218 * @param index The swapchain image index to present
219 * @param timeline_semaphore_value The value to await on @ref comp_target_semaphores::render_complete
220 * if @ref comp_target_semaphores::render_complete_is_timeline is true.
221 * @param desired_present_time_ns The timestamp to present at, ideally.
222 * @param present_slop_ns TODO
223 */
224 VkResult (*present)(struct comp_target *ct,
225 VkQueue queue,
226 uint32_t index,
227 uint64_t timeline_semaphore_value,
228 int64_t desired_present_time_ns,
229 int64_t present_slop_ns);
230
231 /*!
232 * Flush any WSI state before rendering.
233 */
234 void (*flush)(struct comp_target *ct);
235
236
237 /*
238 *
239 * Timing functions.
240 *
241 */
242
243 /*!
244 * Predict when the next frame should be started and when it will be
245 * turned into photons by the hardware.
246 */
247 void (*calc_frame_pacing)(struct comp_target *ct,
248 int64_t *out_frame_id,
249 int64_t *out_wake_up_time_ns,
250 int64_t *out_desired_present_time_ns,
251 int64_t *out_present_slop_ns,
252 int64_t *out_predicted_display_time_ns);
253
254 /*!
255 * The compositor tells the target a timing information about a single
256 * timing point on the frames lifecycle.
257 */
258 void (*mark_timing_point)(struct comp_target *ct,
259 enum comp_target_timing_point point,
260 int64_t frame_id,
261 int64_t when_ns);
262
263 /*!
264 * Update timing information for this target, this function should be
265 * lightweight and is called multiple times during a frame to make sure
266 * that we get the timing data as soon as possible.
267 */
268 VkResult (*update_timings)(struct comp_target *ct);
269
270 /*!
271 * Provide frame timing information about GPU start and stop time.
272 *
273 * Depend on when the information is delivered this can be called at any
274 * point of the following frames.
275 *
276 * @param[in] ct The compositor target.
277 * @param[in] frame_id The frame ID to record for.
278 * @param[in] gpu_start_ns When the GPU work startred.
279 * @param[in] gpu_end_ns When the GPU work stopped.
280 * @param[in] when_ns When the informatioon collected, nominally
281 * from @ref os_monotonic_get_ns.
282 *
283 * @see @ref frame-pacing.
284 */
285 void (*info_gpu)(
286 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns);
287
288 /*
289 *
290 * Misc functions.
291 *
292 */
293
294 /*!
295 * If the target can show a title (like a window) set the title.
296 */
297 void (*set_title)(struct comp_target *ct, const char *title);
298
299 /*!
300 * Get the available refresh rates for the compositor target
301 *
302 * @param ct The compositor target.
303 * @param count The number or refresh rates.
304 * @param refresh_rates_hz The refresh rates, in Hz. Must be allocated by caller, and have at least
305 * XRT_MAX_SUPPORTED_REFRESH_RATES elements
306 */
308 uint32_t *out_count,
309 float *out_display_refresh_rates_hz);
310
311 /*!
312 * Get the current refresh rate for the compositor target
313 *
314 * @param ct The compositor target.
315 * @param out_display_refresh_rate_hz The current refresh rate, in Hz
316 */
317 xrt_result_t (*get_current_refresh_rate)(struct comp_target *ct, float *out_display_refresh_rate_hz);
318
319 /*!
320 * Get the current refresh rate for the compositor target
321 *
322 * @param ct The compositor target.
323 * @param display_refresh_rate_hz The requested refresh rate, in Hz.
324 */
325 xrt_result_t (*request_refresh_rate)(struct comp_target *ct, float display_refresh_rate_hz);
326
327
328 /*!
329 * Destroys this target.
330 */
331 void (*destroy)(struct comp_target *ct);
332};
333
334/*!
335 * @copydoc comp_target::init_pre_vulkan
336 *
337 * @public @memberof comp_target
338 * @ingroup comp_main
339 */
340static inline bool
342{
343 COMP_TRACE_MARKER();
344
345 return ct->init_pre_vulkan(ct);
346}
347
348/*!
349 * @copydoc comp_target::init_post_vulkan
350 *
351 * @public @memberof comp_target
352 * @ingroup comp_main
353 */
354static inline bool
355comp_target_init_post_vulkan(struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height)
356{
357 COMP_TRACE_MARKER();
358
359 return ct->init_post_vulkan(ct, preferred_width, preferred_height);
360}
361
362/*!
363 * @copydoc comp_target::check_ready
364 *
365 * @public @memberof comp_target
366 * @ingroup comp_main
367 */
368static inline bool
370{
371 COMP_TRACE_MARKER();
372
373 return ct->check_ready(ct);
374}
375
376/*!
377 * @copydoc comp_target::create_images
378 *
379 * @public @memberof comp_target
380 * @ingroup comp_main
381 */
382static inline void
384{
385 COMP_TRACE_MARKER();
386
387 ct->create_images(ct, create_info);
388}
389
390/*!
391 * @copydoc comp_target::has_images
392 *
393 * @public @memberof comp_target
394 * @ingroup comp_main
395 */
396static inline bool
398{
399 COMP_TRACE_MARKER();
400
401 return ct->has_images(ct);
402}
403
404/*!
405 * @copydoc comp_target::acquire
406 *
407 * @public @memberof comp_target
408 * @ingroup comp_main
409 */
410static inline VkResult
411comp_target_acquire(struct comp_target *ct, uint32_t *out_index)
412{
413 COMP_TRACE_MARKER();
414
415 return ct->acquire(ct, out_index);
416}
417
418/*!
419 * @copydoc comp_target::present
420 *
421 * @public @memberof comp_target
422 * @ingroup comp_main
423 */
424static inline VkResult
426 VkQueue queue,
427 uint32_t index,
428 uint64_t timeline_semaphore_value,
429 int64_t desired_present_time_ns,
430 int64_t present_slop_ns)
431
432{
433 COMP_TRACE_MARKER();
434
435 return ct->present( //
436 ct, //
437 queue, //
438 index, //
439 timeline_semaphore_value, //
440 desired_present_time_ns, //
441 present_slop_ns); //
442}
443
444/*!
445 * @copydoc comp_target::flush
446 *
447 * @public @memberof comp_target
448 * @ingroup comp_main
449 */
450static inline void
452{
453 COMP_TRACE_MARKER();
454
455 ct->flush(ct);
456}
457
458/*!
459 * @copydoc comp_target::calc_frame_pacing
460 *
461 * @public @memberof comp_target
462 * @ingroup comp_main
463 */
464static inline void
466 int64_t *out_frame_id,
467 int64_t *out_wake_up_time_ns,
468 int64_t *out_desired_present_time_ns,
469 int64_t *out_present_slop_ns,
470 int64_t *out_predicted_display_time_ns)
471{
472 COMP_TRACE_MARKER();
473
474 ct->calc_frame_pacing( //
475 ct, //
476 out_frame_id, //
477 out_wake_up_time_ns, //
478 out_desired_present_time_ns, //
479 out_present_slop_ns, //
480 out_predicted_display_time_ns); //
481}
482
483/*!
484 * Quick helper for marking wake up.
485 * @copydoc comp_target::mark_timing_point
486 *
487 * @public @memberof comp_target
488 * @ingroup comp_main
489 */
490static inline void
491comp_target_mark_wake_up(struct comp_target *ct, int64_t frame_id, int64_t when_woke_ns)
492{
493 COMP_TRACE_MARKER();
494
495 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_WAKE_UP, frame_id, when_woke_ns);
496}
497
498/*!
499 * Quick helper for marking begin.
500 * @copydoc comp_target::mark_timing_point
501 *
502 * @public @memberof comp_target
503 * @ingroup comp_main
504 */
505static inline void
506comp_target_mark_begin(struct comp_target *ct, int64_t frame_id, int64_t when_began_ns)
507{
508 COMP_TRACE_MARKER();
509
510 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_BEGIN, frame_id, when_began_ns);
511}
512
513/*!
514 * Quick helper for marking submit began.
515 * @copydoc comp_target::mark_timing_point
516 *
517 * @public @memberof comp_target
518 * @ingroup comp_main
519 */
520static inline void
521comp_target_mark_submit_begin(struct comp_target *ct, int64_t frame_id, int64_t when_submit_began_ns)
522{
523 COMP_TRACE_MARKER();
524
525 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN, frame_id, when_submit_began_ns);
526}
527
528/*!
529 * Quick helper for marking submit end.
530 * @copydoc comp_target::mark_timing_point
531 *
532 * @public @memberof comp_target
533 * @ingroup comp_main
534 */
535static inline void
536comp_target_mark_submit_end(struct comp_target *ct, int64_t frame_id, int64_t when_submit_end_ns)
537{
538 COMP_TRACE_MARKER();
539
540 ct->mark_timing_point(ct, COMP_TARGET_TIMING_POINT_SUBMIT_END, frame_id, when_submit_end_ns);
541}
542
543/*!
544 * @copydoc comp_target::update_timings
545 *
546 * @public @memberof comp_target
547 * @ingroup comp_main
548 */
549static inline VkResult
551{
552 COMP_TRACE_MARKER();
553
554 return ct->update_timings(ct);
555}
556
557/*!
558 * @copydoc comp_target::info_gpu
559 *
560 * @public @memberof comp_target
561 * @ingroup comp_main
562 */
563static inline void
565 struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
566{
567 COMP_TRACE_MARKER();
568
569 ct->info_gpu(ct, frame_id, gpu_start_ns, gpu_end_ns, when_ns);
570}
571
572/*!
573 * @copydoc comp_target::set_title
574 *
575 * @public @memberof comp_target
576 * @ingroup comp_main
577 */
578static inline void
579comp_target_set_title(struct comp_target *ct, const char *title)
580{
581 COMP_TRACE_MARKER();
582
583 ct->set_title(ct, title);
584}
585
586/*!
587 * @copydoc comp_target::get_refresh_rates
588 *
589 * @public @memberof comp_target
590 * @ingroup comp_main
591 */
592static inline xrt_result_t
593comp_target_get_refresh_rates(struct comp_target *ct, uint32_t *count, float *rates)
594{
595 COMP_TRACE_MARKER();
596
597 return ct->get_refresh_rates(ct, count, rates);
598}
599
600/*!
601 * @copydoc comp_target::get_current_refresh_rate
602 *
603 * @public @memberof comp_target
604 * @ingroup comp_main
605 */
606static inline xrt_result_t
607comp_target_get_current_refresh_rate(struct comp_target *ct, float *out_display_refresh_rate_hz)
608{
609 COMP_TRACE_MARKER();
610
611 return ct->get_current_refresh_rate(ct, out_display_refresh_rate_hz);
612}
613
614/*!
615 * @copydoc comp_target::request_refresh_rate
616 *
617 * @public @memberof comp_target
618 * @ingroup comp_main
619 */
620static inline xrt_result_t
621comp_target_request_refresh_rate(struct comp_target *ct, float ratedisplay_refresh_rate_hz)
622{
623 COMP_TRACE_MARKER();
624
625 return ct->request_refresh_rate(ct, ratedisplay_refresh_rate_hz);
626}
627
628/*!
629 * @copydoc comp_target::destroy
630 *
631 * Helper for calling through the function pointer: does a null check and sets
632 * ct_ptr to null if freed.
633 *
634 * @public @memberof comp_target
635 * @ingroup comp_main
636 */
637static inline void
639{
640 struct comp_target *ct = *ct_ptr;
641 if (ct == NULL) {
642 return;
643 }
644
645 ct->destroy(ct);
646 *ct_ptr = NULL;
647}
648
649/*!
650 * A factory of targets.
651 *
652 * @ingroup comp_main
653 */
655{
656 //! Pretty loggable name of target type.
657 const char *name;
658
659 //! Short all lowercase identifier for target type.
660 const char *identifier;
661
662 //! Does this factory require Vulkan to have been initialized.
664
665 /*!
666 * Is this a deferred target that can have it's creation
667 * delayed even further then after Vulkan initialization.
668 */
670
671 /*!
672 * Vulkan version that is required or 0 if no specific
673 * requirement, equivalent to VK_MAKE_VERSION(1, 0, 0)
674 */
676
677 //! Required instance extensions.
679
680 //! Required instance extension count.
682
683 //! Optional device extensions.
685
686 //! Optional device extension count.
688
689 /*!
690 * Checks if this target can be detected, is the preferred target or
691 * some other special consideration that this target should be used over
692 * all other targets.
693 *
694 * This is needed for NVIDIA direct mode which window must be created
695 * after vulkan has initialized.
696 */
697 bool (*detect)(const struct comp_target_factory *ctf, struct comp_compositor *c);
698
699 /*!
700 * Create a target from this factory, some targets requires Vulkan to
701 * have been initialised, see @ref requires_vulkan_for_create.
702 */
704 struct comp_compositor *c,
705 struct comp_target **out_ct);
706};
707
708/*!
709 * @copydoc comp_target_factory::detect
710 *
711 * @public @memberof comp_target_factory
712 * @ingroup comp_main
713 */
714static inline bool
716{
717 COMP_TRACE_MARKER();
718
719 return ctf->detect(ctf, c);
720}
721
722/*!
723 * @copydoc comp_target_factory::create_target
724 *
725 * @public @memberof comp_target_factory
726 * @ingroup comp_main
727 */
728static inline bool
730 struct comp_compositor *c,
731 struct comp_target **out_ct)
732{
733 COMP_TRACE_MARKER();
734
735 return ctf->create_target(ctf, c, out_ct);
736}
737
738
739#ifdef __cplusplus
740}
741#endif
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:491
static void comp_target_destroy(struct comp_target **ct_ptr)
Destroys this target.
Definition: comp_target.h:638
comp_target_display_timing_usage
If the target should use the display timing information.
Definition: comp_target.h:52
static VkResult comp_target_present(struct comp_target *ct, VkQueue 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:425
static VkResult comp_target_acquire(struct comp_target *ct, uint32_t *out_index)
Acquire the next image for rendering.
Definition: comp_target.h:411
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:521
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:550
static void comp_target_flush(struct comp_target *ct)
Flush any WSI state before rendering.
Definition: comp_target.h:451
static bool comp_target_has_images(struct comp_target *ct)
Has this target successfully had images created?
Definition: comp_target.h:397
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:607
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:579
static void comp_target_create_images(struct comp_target *ct, const struct comp_target_create_images_info *create_info)
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the s...
Definition: comp_target.h:383
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:593
static bool comp_target_check_ready(struct comp_target *ct)
Is this target ready for image creation?
Definition: comp_target.h:369
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:465
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:506
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:715
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:536
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:621
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:729
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:341
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:564
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:355
@ 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:39
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:655
const char ** required_instance_extensions
Required instance extensions.
Definition: comp_target.h:678
bool requires_vulkan_for_create
Does this factory require Vulkan to have been initialized.
Definition: comp_target.h:663
size_t required_instance_extension_count
Required instance extension count.
Definition: comp_target.h:681
const char * identifier
Short all lowercase identifier for target type.
Definition: comp_target.h:660
size_t optional_device_extension_count
Optional device extension count.
Definition: comp_target.h:687
const char ** optional_device_extensions
Optional device extensions.
Definition: comp_target.h:684
const char * name
Pretty loggable name of target type.
Definition: comp_target.h:657
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:697
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:675
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:669
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:703
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:199
void(* create_images)(struct comp_target *ct, const struct comp_target_create_images_info *create_info)
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the s...
Definition: comp_target.h:191
bool(* check_ready)(struct comp_target *ct)
Is this target ready for image creation?
Definition: comp_target.h:183
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:325
void(* flush)(struct comp_target *ct)
Flush any WSI state before rendering.
Definition: comp_target.h:234
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:297
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:176
void(* destroy)(struct comp_target *ct)
Destroys this target.
Definition: comp_target.h:331
struct comp_target_image * images
Array of images and image views for rendering.
Definition: comp_target.h:152
uint32_t image_count
Number of images that this target has.
Definition: comp_target.h:150
VkResult(* acquire)(struct comp_target *ct, uint32_t *out_index)
Acquire the next image for rendering.
Definition: comp_target.h:209
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:258
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:285
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:170
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:268
const char * name
Name of the backing system.
Definition: comp_target.h:138
VkSurfaceTransformFlagBitsKHR surface_transform
Transformation of the current surface, required for pre-rotation.
Definition: comp_target.h:155
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:247
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:307
struct comp_compositor * c
Owning compositor.
Definition: comp_target.h:135
VkFormat format
The format that the renderpass targeting this target should use.
Definition: comp_target.h:144
VkResult(* present)(struct comp_target *ct, VkQueue 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:224
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:317
VkImageLayout final_layout
The final layout that the renderpass should leave this target in.
Definition: comp_target.h:147
Tracing support code, see Tracing support.
Common Vulkan code header.
Header holding common defines.
Common defines and enums for XRT.