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