Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_compositor.h
Go to the documentation of this file.
1// Copyright 2019-2024, Collabora, Ltd.
2// Copyright 2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Header declaring XRT graphics interfaces.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
9 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
10 * @author Christoph Haag <christoph.haag@collabora.com>
11 * @author Korcan Hussein <korcan.hussein@collabora.com>
12 * @ingroup xrt_iface
13 */
14
15#pragma once
16
17#include "xrt/xrt_limits.h"
18#include "xrt/xrt_defines.h"
19#include "xrt/xrt_handles.h"
20#include "xrt/xrt_config_os.h"
21#include "xrt/xrt_config_have.h"
22#include "xrt/xrt_windows.h"
23
24#if defined(XRT_HAVE_D3D11)
25#include <d3d11.h>
26#elif defined(XRT_DOXYGEN)
27struct ID3D11Texture2D;
28#endif
29
30#if defined(XRT_HAVE_D3D12)
31#include <d3d12.h>
32#elif defined(XRT_DOXYGEN)
33struct ID3D12Resource;
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40
41/*
42 *
43 * Pre-declare things, also they should not be in the xrt_iface group.
44 *
45 */
46
47struct xrt_device;
48struct xrt_image_native;
49struct xrt_compositor;
51
52typedef struct VkCommandBuffer_T *VkCommandBuffer;
53#ifdef XRT_64_BIT
54typedef struct VkImage_T *VkImage;
55typedef struct VkDeviceMemory_T *VkDeviceMemory;
56#else
57typedef uint64_t VkImage;
58typedef uint64_t VkDeviceMemory;
59#endif
60
61
62/*!
63 * @addtogroup xrt_iface
64 * @{
65 */
66
67
68/*
69 *
70 * Layers.
71 *
72 */
73
74/*!
75 * Layer type.
76 */
78{
79 XRT_LAYER_PROJECTION,
80 XRT_LAYER_PROJECTION_DEPTH,
81 XRT_LAYER_QUAD,
82 XRT_LAYER_CUBE,
83 XRT_LAYER_CYLINDER,
84 XRT_LAYER_EQUIRECT1,
85 XRT_LAYER_EQUIRECT2,
86 XRT_LAYER_PASSTHROUGH
87};
88
89/*!
90 * Bit field for holding information about how a layer should be composited.
91 */
93{
94 XRT_LAYER_COMPOSITION_CORRECT_CHROMATIC_ABERRATION_BIT = 1u << 0u,
95 XRT_LAYER_COMPOSITION_BLEND_TEXTURE_SOURCE_ALPHA_BIT = 1u << 1u,
96 XRT_LAYER_COMPOSITION_UNPREMULTIPLIED_ALPHA_BIT = 1u << 2u,
97 /*!
98 * The layer is locked to the device and the pose should only be
99 * adjusted for the IPD.
100 */
102
103 /*!
104 * If this flag is set the compositor should use the scale and bias
105 * from the @ref xrt_layer_data struct.
106 */
108
109 //! Normal super sampling, see XrCompositionLayerSettingsFlagsFB.
111
112 //! Quality super sampling, see XrCompositionLayerSettingsFlagsFB.
114
115 //! Normal sharpening, see XrCompositionLayerSettingsFlagsFB.
117
118 //! Quality sharpening, see XrCompositionLayerSettingsFlagsFB.
120
121 /*!
122 * This layer has advanced blending information, this bit
123 * supersedes the behavior of
124 * @ref XRT_LAYER_COMPOSITION_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
125 * see @p XrCompositionLayerAlphaBlendFB.
126 */
128
129 /*!
130 * Depth testing is requested when composing this layer if this flag is set,
131 * see XrCompositionLayerDepthTestFB.
132 */
134
135 /*!
136 * This layer has inverted alpha,
137 * see @p XR_COMPOSITION_LAYER_INVERTED_ALPHA_BIT_EXT
138 */
140};
141
142/*!
143 * XrCompareOpFB
144 */
146{
147 XRT_COMPARE_OP_NEVER_FB = 0,
148 XRT_COMPARE_OP_LESS_FB = 1,
149 XRT_COMPARE_OP_EQUAL_FB = 2,
150 XRT_COMPARE_OP_LESS_OR_EQUAL_FB = 3,
151 XRT_COMPARE_OP_GREATER_FB = 4,
152 XRT_COMPARE_OP_NOT_EQUAL_FB = 5,
153 XRT_COMPARE_OP_GREATER_OR_EQUAL_FB = 6,
154 XRT_COMPARE_OP_ALWAYS_FB = 7,
155 XRT_COMPARE_OP_MAX_ENUM_FB = 0x7FFFFFFF
156};
157
158/*!
159 * Which view is the layer visible to?
160 *
161 * Used for quad layers.
162 *
163 * @note Doesn't have the same values as the OpenXR counterpart!
164 */
166{
167 XRT_LAYER_EYE_VISIBILITY_NONE = 0x0,
168 XRT_LAYER_EYE_VISIBILITY_LEFT_BIT = 0x1,
169 XRT_LAYER_EYE_VISIBILITY_RIGHT_BIT = 0x2,
170 XRT_LAYER_EYE_VISIBILITY_BOTH = 0x3,
171};
172
173/*!
174 * Blend factors.
175 */
177{
178 XRT_BLEND_FACTOR_ZERO = 0,
179 XRT_BLEND_FACTOR_ONE = 1,
180 XRT_BLEND_FACTOR_SRC_ALPHA = 2,
181 XRT_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 3,
182 XRT_BLEND_FACTOR_DST_ALPHA = 4,
183 XRT_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 5,
184 XRT_BLEND_FACTOR_MAX_ENUM_FB = 0x7FFFFFFF,
185};
186
187
188/*!
189 * Chroma key parameters in HSV space.
190 * Alpha 0-1 interpolates between hsv_min and hsv_max
191 * with curve as a power curve defined by the curve exponent.
192 *
193 * Used for projection layers.
194 */
196{
197 //!< Minimum HSV bounds
199 //! Maximum HSV bounds
201 //! Power curve for alpha falloff (1.0 = linear)
202 float curve;
203 //! Despill strength (0.0 = none, 1.0 = full)
204 float despill;
205};
206
207/*!
208 * Advanced blend
209 * provides explicit control over source and destination blend factors,
210 * with separate controls for color and alpha
211 *
212 * See @ref XRT_LAYER_COMPOSITION_ADVANCED_BLENDING_BIT.
213 */
215{
216 enum xrt_blend_factor src_factor_color;
217 enum xrt_blend_factor dst_factor_color;
218 enum xrt_blend_factor src_factor_alpha;
219 enum xrt_blend_factor dst_factor_alpha;
220};
221
222/*!
223 * Specifies a sub-image in a layer.
224 */
226{
227 //! Image index in the (implicit) swapchain
228 uint32_t image_index;
229 //! Index in image array (for array textures)
230 uint32_t array_index;
231 //! The rectangle in the image to use
233 //! Normalized sub image coordinates and size.
235};
236
237/*!
238 * All of the pure data values associated with a single view in a projection
239 * layer.
240 *
241 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
242 * this struct.
243 */
245{
246 struct xrt_sub_image sub;
247
248 struct xrt_fov fov;
249 struct xrt_pose pose;
250};
251
252/*!
253 * All the pure data values associated with a projection layer.
254 *
255 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
256 * this struct.
257 */
259{
260 struct xrt_layer_projection_view_data v[XRT_MAX_VIEWS];
261
262 struct xrt_layer_chroma_key_data chroma_key;
263};
264
265/*!
266 * All the pure data values associated with a depth information attached
267 * to a layer.
268 *
269 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
270 * this struct.
271 */
273{
274 struct xrt_sub_image sub;
275
276 float min_depth;
277 float max_depth;
278 float near_z;
279 float far_z;
280};
281
283{
284 bool depth_mask;
285 enum xrt_compare_op_fb compare_op;
286};
287
288/*!
289 * All the pure data values associated with a projection layer with depth
290 * swapchain attached.
291 *
292 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
293 * this struct.
294 */
296{
297 struct xrt_layer_projection_view_data v[XRT_MAX_VIEWS];
298
299 struct xrt_layer_depth_data d[XRT_MAX_VIEWS];
300
301 struct xrt_layer_chroma_key_data chroma_key;
302};
303
304/*!
305 * All the pure data values associated with a quad layer.
306 *
307 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
308 * this struct.
309 */
311{
312 enum xrt_layer_eye_visibility visibility;
313
314 struct xrt_sub_image sub;
315
316 struct xrt_pose pose;
317 struct xrt_vec2 size;
318};
319
320/*!
321 * All the pure data values associated with a cube layer.
322 *
323 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
324 * this struct.
325 */
327{
328 enum xrt_layer_eye_visibility visibility;
329
330 struct xrt_sub_image sub;
331
332 struct xrt_pose pose;
333};
334
335/*!
336 * All the pure data values associated with a cylinder layer.
337 *
338 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
339 * this struct.
340 */
342{
343 enum xrt_layer_eye_visibility visibility;
344
345 struct xrt_sub_image sub;
346
347 struct xrt_pose pose;
348 float radius;
349 float central_angle;
350 float aspect_ratio;
351};
352
353/*!
354 * All the pure data values associated with a equirect1 layer.
355 *
356 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
357 * this struct.
358 */
360{
361 enum xrt_layer_eye_visibility visibility;
362
363 struct xrt_sub_image sub;
364
365 struct xrt_pose pose;
366 float radius;
367 struct xrt_vec2 scale;
368 struct xrt_vec2 bias;
369};
370
371/*!
372 * All the pure data values associated with a equirect2 layer.
373 *
374 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
375 * this struct.
376 */
378{
379 enum xrt_layer_eye_visibility visibility;
380
381 struct xrt_sub_image sub;
382
383 struct xrt_pose pose;
384 float radius;
385 float central_horizontal_angle;
386 float upper_vertical_angle;
387 float lower_vertical_angle;
388};
389
390/*!
391 * @interface xrt_passthrough
392 */
394{
395 bool paused;
396};
397
398/*!
399 * @interface xrt_passthrough_layer
400 */
402{
403 bool paused;
404};
405
406/*!
407 * All the pure data values associated with a passthrough layer.
408 *
409 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
410 * this struct.
411 */
413{
414 struct xrt_passthrough xrt_pt;
415 struct xrt_passthrough_layer xrt_pl;
416};
417
418/*!
419 * All the pure data values associated with a composition layer.
420 *
421 * The @ref xrt_swapchain references and @ref xrt_device are provided outside of
422 * this struct.
423 */
425{
426 /*!
427 * Tag for compositor layer type.
428 */
430
431 /*!
432 * Often @ref XRT_INPUT_GENERIC_HEAD_POSE
433 */
435
436 /*!
437 * "Display no-earlier-than" timestamp for this layer.
438 *
439 * The layer may be displayed after this point, but must never be
440 * displayed before.
441 *
442 * alignas for 32 bit client support,
443 */
444 XRT_ALIGNAS(8) int64_t timestamp;
445
446 /*!
447 * Composition flags
448 */
450
451 /*!
452 * Depth test data
453 */
455
456 /*!
457 * Whether the main compositor should flip the direction of y when
458 * rendering.
459 *
460 * This is actually an input only to the "main" compositor
461 * comp_compositor. It is overwritten by the various client
462 * implementations of the @ref xrt_compositor interface depending on the
463 * conventions of the associated graphics API. Other @ref
464 * xrt_compositor_native implementations that are not the main
465 * compositor just pass this field along unchanged to the "real"
466 * compositor.
467 */
468 bool flip_y;
469
470 /*!
471 * Modulate the color sourced from the images.
472 */
474
475 /*!
476 * Modulate the color sourced from the images.
477 */
479
480 /*!
481 * Advanced blend factors
482 */
484
485 /*!
486 * Union of data values for the various layer types.
487 *
488 * The initialized member of this union should match the value of
489 * xrt_layer_data::type. It also should be clear because of the layer
490 * function called between xrt_compositor::layer_begin and
491 * xrt_compositor::layer_commit where this data was passed.
492 */
493 union {
494 struct xrt_layer_projection_data proj;
496 struct xrt_layer_quad_data quad;
497 struct xrt_layer_cube_data cube;
498 struct xrt_layer_cylinder_data cylinder;
499 struct xrt_layer_equirect1_data equirect1;
500 struct xrt_layer_equirect2_data equirect2;
501 struct xrt_layer_passthrough_data passthrough;
502 };
503 uint32_t view_count;
504};
505
506/*!
507 * Per frame data for the layer submission calls, used in
508 * @ref xrt_compositor::layer_begin.
509 */
511{
512 //! alignas for 32 bit client support, see @ref ipc-design
513 XRT_ALIGNAS(8) int64_t frame_id;
514 int64_t display_time_ns;
515 enum xrt_blend_mode env_blend_mode;
516};
517
518
519/*
520 *
521 * Swapchain.
522 *
523 */
524
525/*!
526 * Special flags for creating swapchain images.
527 */
529{
530 //! Our compositor just ignores this bit.
532 //! Signals that the allocator should only allocate one image.
534 /*!
535 * Signals to the compositor to use the equivalent sRGB format of the UNORM swapchain.
536 *
537 * The swapchain must have @ref XRT_SWAPCHAIN_USAGE_MUTABLE_FORMAT and must have
538 * both formats in the format list.
539 */
541};
542
543/*!
544 * Usage of the swapchain images.
545 */
547{
548 XRT_SWAPCHAIN_USAGE_COLOR = 0x00000001,
549 XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL = 0x00000002,
550 XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS = 0x00000004,
551 XRT_SWAPCHAIN_USAGE_TRANSFER_SRC = 0x00000008,
552 XRT_SWAPCHAIN_USAGE_TRANSFER_DST = 0x00000010,
553 XRT_SWAPCHAIN_USAGE_SAMPLED = 0x00000020,
554 XRT_SWAPCHAIN_USAGE_MUTABLE_FORMAT = 0x00000040,
555 XRT_SWAPCHAIN_USAGE_INPUT_ATTACHMENT = 0x00000080,
556};
557
558/*!
559 * The direction of a transition.
560 */
562{
563 XRT_BARRIER_TO_APP = 1,
564 XRT_BARRIER_TO_COMP = 2,
565};
566
567/*!
568 * @interface xrt_swapchain
569 *
570 * Common swapchain interface/base.
571 *
572 * Swapchains are owned by the @ref xrt_compositor that they where created from,
573 * it's the state trackers job to ensure all swapchains are destroyed before
574 * destroying the @ref xrt_compositor.
575 */
577{
578 /*!
579 * Reference helper.
580 */
581 struct xrt_reference reference;
582
583 /*!
584 * Number of images.
585 *
586 * The images themselves are on the subclasses.
587 */
588 uint32_t image_count;
589
590 /*!
591 * @ref dec_image_use must have been called as often as @ref inc_image_use.
592 */
593 void (*destroy)(struct xrt_swapchain *xsc);
594
595 /*!
596 * Obtain the index of the next image to use, without blocking on being
597 * able to write to it.
598 *
599 * See xrAcquireSwapchainImage.
600 *
601 * Caller must make sure that no image is acquired before calling
602 * @ref xrt_swapchain_acquire_image.
603 *
604 * @param xsc Self pointer
605 * @param[out] out_index Image index to use next
606 *
607 * Call @ref xrt_swapchain_wait_image before writing to the image index output from this function.
608 */
609 xrt_result_t (*acquire_image)(struct xrt_swapchain *xsc, uint32_t *out_index);
610
611 /*!
612 * @brief Increments the use counter of a swapchain image.
613 */
614 xrt_result_t (*inc_image_use)(struct xrt_swapchain *xsc, uint32_t index);
615
616 /*!
617 * @brief Decrements the use counter of a swapchain image.
618 *
619 * @ref wait_image will return once the image use counter is 0.
620 */
621 xrt_result_t (*dec_image_use)(struct xrt_swapchain *xsc, uint32_t index);
622
623 /*!
624 * Wait until image @p index is available for exclusive use, or until @p timeout_ns expires.
625 *
626 * See xrWaitSwapchainImage, which is the basis for this API.
627 * The state tracker needs to track image index, which should have come from @ref xrt_swapchain_acquire_image
628
629 * @param xsc Self pointer
630 * @param timeout_ns Timeout in nanoseconds,
631 * @param index Image index to wait for.
632 */
633 xrt_result_t (*wait_image)(struct xrt_swapchain *xsc, int64_t timeout_ns, uint32_t index);
634
635 /*!
636 * Do any barrier transitions to and from the application.
637 *
638 * @param xsc Self pointer
639 * @param direction Direction of the barrier transition.
640 * @param index Image index to barrier transition.
641 */
642 xrt_result_t (*barrier_image)(struct xrt_swapchain *xsc, enum xrt_barrier_direction direction, uint32_t index);
643
644 /*!
645 * See xrReleaseSwapchainImage, state tracker needs to track index.
646 */
647 xrt_result_t (*release_image)(struct xrt_swapchain *xsc, uint32_t index);
648};
649
650/*!
651 * Update the reference counts on swapchain(s).
652 *
653 * @param[in,out] dst Pointer to a object reference: if the object reference is
654 * non-null will decrement its counter. The reference that
655 * @p dst points to will be set to @p src.
656 * @param[in] src New object for @p dst to refer to (may be null).
657 * If non-null, will have its refcount increased.
658 * @ingroup xrt_iface
659 * @relates xrt_swapchain
660 */
661XRT_NONNULL_FIRST static inline void
663{
664 struct xrt_swapchain *old_dst = *dst;
665
666 if (old_dst == src) {
667 return;
668 }
669
670 if (src) {
671 xrt_reference_inc(&src->reference);
672 }
673
674 *dst = src;
675
676 if (old_dst) {
677 if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
678 old_dst->destroy(old_dst);
679 }
680 }
681}
682
683/*!
684 * @copydoc xrt_swapchain::acquire_image
685 *
686 * Helper for calling through the function pointer.
687 *
688 * @public @memberof xrt_swapchain
689 */
690XRT_NONNULL_ALL static inline xrt_result_t
691xrt_swapchain_acquire_image(struct xrt_swapchain *xsc, uint32_t *out_index)
692{
693 return xsc->acquire_image(xsc, out_index);
694}
695
696/*!
697 * @copydoc xrt_swapchain::inc_image_use
698 *
699 * Helper for calling through the function pointer.
700 *
701 * @public @memberof xrt_swapchain
702 */
703XRT_NONNULL_ALL static inline xrt_result_t
704xrt_swapchain_inc_image_use(struct xrt_swapchain *xsc, uint32_t index)
705{
706 return xsc->inc_image_use(xsc, index);
707}
708
709/*!
710 * @copydoc xrt_swapchain::dec_image_use
711 *
712 * Helper for calling through the function pointer.
713 *
714 * @public @memberof xrt_swapchain
715 */
716XRT_NONNULL_ALL static inline xrt_result_t
717xrt_swapchain_dec_image_use(struct xrt_swapchain *xsc, uint32_t index)
718{
719 return xsc->dec_image_use(xsc, index);
720}
721
722/*!
723 * @copydoc xrt_swapchain::wait_image
724 *
725 * Helper for calling through the function pointer.
726 *
727 * @public @memberof xrt_swapchain
728 */
729XRT_NONNULL_ALL static inline xrt_result_t
730xrt_swapchain_wait_image(struct xrt_swapchain *xsc, int64_t timeout_ns, uint32_t index)
731{
732 return xsc->wait_image(xsc, timeout_ns, index);
733}
734
735/*!
736 * @copydoc xrt_swapchain::barrier_image
737 *
738 * Helper for calling through the function pointer.
739 *
740 * @public @memberof xrt_swapchain
741 */
742XRT_NONNULL_ALL static inline xrt_result_t
743xrt_swapchain_barrier_image(struct xrt_swapchain *xsc, enum xrt_barrier_direction direction, uint32_t index)
744{
745 return xsc->barrier_image(xsc, direction, index);
746}
747
748/*!
749 * @copydoc xrt_swapchain::release_image
750 *
751 * Helper for calling through the function pointer.
752 *
753 * @public @memberof xrt_swapchain
754 */
755XRT_NONNULL_ALL static inline xrt_result_t
756xrt_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
757{
758 return xsc->release_image(xsc, index);
759}
760
761
762/*
763 *
764 * Fence.
765 *
766 */
767
768/*!
769 * Compositor fence used for synchronization.
770 */
772{
773 /*!
774 * Waits on the fence with the given timeout.
775 */
776 xrt_result_t (*wait)(struct xrt_compositor_fence *xcf, uint64_t timeout);
777
778 /*!
779 * Destroys the fence.
780 */
781 void (*destroy)(struct xrt_compositor_fence *xcf);
782};
783
784/*!
785 * @copydoc xrt_compositor_fence::wait
786 *
787 * Helper for calling through the function pointer.
788 *
789 * @public @memberof xrt_compositor_fence
790 */
791XRT_NONNULL_ALL static inline xrt_result_t
793{
794 return xcf->wait(xcf, timeout);
795}
796
797/*!
798 * @copydoc xrt_compositor_fence::destroy
799 *
800 * Helper for calling through the function pointer: does a null check and sets
801 * xcf_ptr to null if freed.
802 *
803 * @public @memberof xrt_compositor_fence
804 */
805static inline void
807{
808 struct xrt_compositor_fence *xcf = *xcf_ptr;
809 if (xcf == NULL) {
810 return;
811 }
812
813 xcf->destroy(xcf);
814 *xcf_ptr = NULL;
815}
816
817
818/*
819 *
820 * Compositor semaphore.
821 *
822 */
823
824/*!
825 * Compositor semaphore used for synchronization, needs to be as capable as a
826 * Vulkan pipeline semaphore.
827 */
829{
830 /*!
831 * Reference helper.
832 */
833 struct xrt_reference reference;
834
835 /*!
836 * Does a CPU side wait on the semaphore to reach the given value.
837 */
838 xrt_result_t (*wait)(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout_ns);
839
840 /*!
841 * Destroys the semaphore.
842 */
843 void (*destroy)(struct xrt_compositor_semaphore *xcsem);
844};
845
846/*!
847 * Update the reference counts on compositor semaphore(s).
848 *
849 * @param[in,out] dst Pointer to a object reference: if the object reference is
850 * non-null will decrement its counter. The reference that
851 * @p dst points to will be set to @p src.
852 * @param[in] src New object for @p dst to refer to (may be null).
853 * If non-null, will have its refcount increased.
854 * @ingroup xrt_iface
855 * @relates xrt_compositor_semaphore
856 */
857XRT_NONNULL_FIRST static inline void
859{
860 struct xrt_compositor_semaphore *old_dst = *dst;
861
862 if (old_dst == src) {
863 return;
864 }
865
866 if (src) {
867 xrt_reference_inc(&src->reference);
868 }
869
870 *dst = src;
871
872 if (old_dst) {
873 if (xrt_reference_dec_and_is_zero(&old_dst->reference)) {
874 old_dst->destroy(old_dst);
875 }
876 }
877}
878
879/*!
880 * @copydoc xrt_compositor_semaphore::wait
881 *
882 * Helper for calling through the function pointer.
883 *
884 * @public @memberof xrt_compositor_semaphore
885 */
886XRT_NONNULL_ALL static inline xrt_result_t
887xrt_compositor_semaphore_wait(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout)
888{
889 return xcsem->wait(xcsem, value, timeout);
890}
891
892
893/*
894 *
895 * Compositor.
896 *
897 */
898
900{
901 XRT_COMPOSITOR_FRAME_POINT_WOKE, //!< The client woke up after waiting.
902};
903
904/*!
905 * Swapchain creation info.
906 */
908{
909 enum xrt_swapchain_create_flags create;
910 enum xrt_swapchain_usage_bits bits;
911 uint32_t format;
912 uint32_t sample_count;
913 uint32_t width;
914 uint32_t height;
915 uint32_t face_count;
916 uint32_t array_size;
917 uint32_t mip_count;
918
919 /*
920 * List of formats that could be used when creating views of the swapchain images.
921 * See XR_KHR_vulkan_swapchain_format_list and VK_KHR_image_format_list
922 */
923 uint32_t format_count;
925};
926
927/*!
928 * Passthrough creation info.
929 */
934
935/*!
936 * Passthrough layer creation info.
937 */
943
944/*!
945 * Struct used to negotiate properties of a swapchain that is created outside
946 * of the compositor. Often used by a client compositor or IPC layer to allocate
947 * the swapchain images and then pass them into the native compositor.
948 */
950{
951 //! How many images the compositor want in the swapchain.
952 uint32_t image_count;
953
954 //! New creation bits.
956};
957
958/*!
959 * Session information, mostly overlay extension data.
960 */
962{
963 bool is_overlay;
964 //! alignas for 32 bit client support, see @ref ipc-design
965 XRT_ALIGNAS(8) uint64_t flags;
966 uint32_t z_order;
967};
968
969/*!
970 * Capabilities and information about the compositor and device together.
971 *
972 * For client compositors the formats of the native compositor are translated.
973 */
975{
976 //! Number of formats, never changes.
977 uint32_t format_count;
978
979 /*!
980 * Supported formats, never changes.
981 * alignas for 32 bit client support, see @ref ipc-design
982 */
984
985 //! Max texture size that GPU supports (size of a single dimension), zero means any size.
986 uint32_t max_texture_size;
987};
988
989/*!
990 * Begin Session information not known until clients have created an xrt-instance such as which
991 * extensions are enabled, view type, etc.
992 */
994{
995 enum xrt_view_type view_type;
996 bool ext_hand_tracking_enabled;
997 bool ext_hand_tracking_data_source_enabled;
998 bool ext_eye_gaze_interaction_enabled;
999 bool ext_future_enabled;
1000 bool ext_hand_interaction_enabled;
1001 bool htc_facial_tracking_enabled;
1002 bool fb_body_tracking_enabled;
1003 bool fb_face_tracking2_enabled;
1004 bool meta_body_tracking_full_body_enabled;
1005 bool meta_body_tracking_calibration_enabled;
1006 bool meta_body_tracking_fidelity_enabled;
1007 bool android_face_tracking_enabled;
1008};
1009
1010/*!
1011 * Hints the XR runtime what type of task the thread is doing.
1012 */
1014{
1015 XRT_THREAD_HINT_APPLICATION_MAIN = 1,
1016 XRT_THREAD_HINT_APPLICATION_WORKER = 2,
1017 XRT_THREAD_HINT_RENDERER_MAIN = 3,
1018 XRT_THREAD_HINT_RENDERER_WORKER = 4,
1019};
1020
1021/*!
1022 * @interface xrt_compositor
1023 *
1024 * Common compositor client interface/base.
1025 *
1026 * A compositor is very much analogous to an `XrSession` but without any of the
1027 * input functionality, and does have the same lifetime as an `XrSession`.
1028 */
1030{
1031 /*!
1032 * Capabilities and recommended values information.
1033 */
1035
1036 /*!
1037 * For a given @ref xrt_swapchain_create_info struct returns a filled
1038 * out @ref xrt_swapchain_create_properties.
1039 */
1040 xrt_result_t (*get_swapchain_create_properties)(struct xrt_compositor *xc,
1041 const struct xrt_swapchain_create_info *info,
1042 struct xrt_swapchain_create_properties *xsccp);
1043
1044 /*!
1045 * @name Function pointers for swapchain and sync creation and import
1046 * @{
1047 */
1048 /*!
1049 * Create a swapchain with a set of images.
1050 *
1051 * The pointer pointed to by @p out_xsc has to either be NULL or a valid
1052 * @ref xrt_swapchain pointer. If there is a valid @ref xrt_swapchain
1053 * pointed by the pointed pointer it will have it reference decremented.
1054 */
1055 xrt_result_t (*create_swapchain)(struct xrt_compositor *xc,
1056 const struct xrt_swapchain_create_info *info,
1057 struct xrt_swapchain **out_xsc);
1058
1059 /*!
1060 * Create a swapchain from a set of native images.
1061 *
1062 * The pointer pointed to by @p out_xsc has to either be NULL or a valid
1063 * @ref xrt_swapchain pointer. If there is a valid @ref xrt_swapchain
1064 * pointed by the pointed pointer it will have it reference decremented.
1065 */
1066 xrt_result_t (*import_swapchain)(struct xrt_compositor *xc,
1067 const struct xrt_swapchain_create_info *info,
1068 struct xrt_image_native *native_images,
1069 uint32_t image_count,
1070 struct xrt_swapchain **out_xsc);
1071
1072 /*!
1073 * Create a compositor fence from a native sync handle.
1074 */
1075 xrt_result_t (*import_fence)(struct xrt_compositor *xc,
1077 struct xrt_compositor_fence **out_xcf);
1078
1079 /*!
1080 * Create a compositor semaphore, also returns a native handle of the
1081 * semaphore which is owned by the @ref xrt_compositor_semaphore struct.
1082 * The return values are always both valid, or on an error condition
1083 * encountered and error is returned, both not valid (untouched).
1084 *
1085 * @param[in] xc Compositor self pointer.
1086 * @param[out] out_handle Native handle owned by the samephore.
1087 * @param[out] out_handle Return of the created semahpore.
1088 */
1089 xrt_result_t (*create_semaphore)(struct xrt_compositor *xc,
1090 xrt_graphics_sync_handle_t *out_handle,
1091 struct xrt_compositor_semaphore **out_xcsem);
1092 /*! @} */
1093
1094 /*!
1095 * Create a passthrough.
1096 */
1097 xrt_result_t (*create_passthrough)(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info);
1098
1099
1100 /*!
1101 * Create a passthrough layer.
1102 */
1103 xrt_result_t (*create_passthrough_layer)(struct xrt_compositor *xc,
1104 const struct xrt_passthrough_layer_create_info *info);
1105 /*!
1106 * Destroy a passthrough.
1107 */
1108 xrt_result_t (*destroy_passthrough)(struct xrt_compositor *xc);
1109
1110 /*!
1111 * @name Function pointers for session functions
1112 * @{
1113 */
1114 /*!
1115 * See xrBeginSession.
1116 */
1117 xrt_result_t (*begin_session)(struct xrt_compositor *xc, const struct xrt_begin_session_info *info);
1118
1119 /*!
1120 * See xrEndSession, unlike the OpenXR one the state tracker is
1121 * responsible to call discard frame before calling this function. See
1122 * discard_frame.
1123 */
1124 xrt_result_t (*end_session)(struct xrt_compositor *xc);
1125
1126 /*! @} */
1127
1128 /*!
1129 * @name Function pointers for frame functions
1130 * @{
1131 */
1132
1133 /*!
1134 * This function and @ref mark_frame function calls are a alternative to
1135 * @ref wait_frame.
1136 *
1137 * The only requirement on the compositor for the @p frame_id
1138 * is that it is a positive number and larger then the last returned
1139 * frame_id.
1140 *
1141 * After a call to predict_frame, the state tracker is not allowed to
1142 * call this function until after a call to @ref mark_frame (with point
1143 * @ref XRT_COMPOSITOR_FRAME_POINT_WOKE), followed by either
1144 * @ref begin_frame or @ref discard_frame.
1145 *
1146 * @param[in] xc The compositor
1147 * @param[out] out_frame_id Frame id
1148 * @param[out] out_wake_time_ns When we want the client to be awoken to begin rendering.
1149 * @param[out] out_predicted_gpu_time_ns When we expect the client to finish the GPU work. If not
1150 * computed/available, set to 0.
1151 * @param[out] out_predicted_display_time_ns When the pixels turns into photons.
1152 * @param[out] out_predicted_display_period_ns The period for the frames.
1153 */
1154 xrt_result_t (*predict_frame)(struct xrt_compositor *xc,
1155 int64_t *out_frame_id,
1156 int64_t *out_wake_time_ns,
1157 int64_t *out_predicted_gpu_time_ns,
1158 int64_t *out_predicted_display_time_ns,
1159 int64_t *out_predicted_display_period_ns);
1160
1161 /*!
1162 * This function and @ref predict_frame function calls are a alternative to
1163 * @ref wait_frame.
1164 *
1165 * If point is @ref XRT_COMPOSITOR_FRAME_POINT_WOKE it is to mark that the
1166 * client woke up from waiting on a frame.
1167 *
1168 * @param[in] xc The compositor
1169 * @param[in] frame_id Frame id
1170 * @param[in] point What type of frame point to mark.
1171 * @param[in] when_ns When this point happened.
1172 */
1173 xrt_result_t (*mark_frame)(struct xrt_compositor *xc,
1174 int64_t frame_id,
1175 enum xrt_compositor_frame_point point,
1176 int64_t when_ns);
1177
1178 /*!
1179 * See xrWaitFrame.
1180 *
1181 * This function has the same semantics as calling @ref predict_frame,
1182 * sleeping, and then calling @ref mark_frame with a point of
1183 * @ref XRT_COMPOSITOR_FRAME_POINT_WOKE.
1184 *
1185 * The only requirement on the compositor for the @p frame_id
1186 * is that it is a positive number and larger then the last returned
1187 * @p frame_id.
1188 *
1189 * After a call to wait_frame, the state tracker is not allowed to call
1190 * this function until after a call to either @ref begin_frame or
1191 * @ref discard_frame.
1192 *
1193 * If the caller can do its own blocking, use the pair of functions
1194 * xrt_compositor::predict_frame and xrt_compositor::mark_frame instead
1195 * of this single blocking function.
1196 */
1197 xrt_result_t (*wait_frame)(struct xrt_compositor *xc,
1198 int64_t *out_frame_id,
1199 int64_t *out_predicted_display_time,
1200 int64_t *out_predicted_display_period);
1201
1202 /*!
1203 * See xrBeginFrame.
1204 *
1205 * Must have made a call to either @ref predict_frame or @ref wait_frame
1206 * before calling this function. After this function is called you must
1207 * call layer_commit.
1208 *
1209 * @param[in] xc The compositor
1210 * @param[in] frame_id Frame id
1211 */
1212 xrt_result_t (*begin_frame)(struct xrt_compositor *xc, int64_t frame_id);
1213
1214 /*!
1215 * @brief Explicitly discard a frame.
1216 *
1217 * This isn't in the OpenXR API but is explicit in the XRT interfaces.
1218 *
1219 * Two calls to xrBeginFrame without intervening xrEndFrame will cause
1220 * the state tracker to call:
1221 *
1222 * ```c
1223 * // first xrBeginFrame
1224 * xrt_comp_begin_frame(xc, frame_id);
1225 * // second xrBeginFrame
1226 * xrt_comp_discard_frame(xc, frame_id);
1227 * xrt_comp_begin_frame(xc, frame_id);
1228 * ```
1229 */
1230 xrt_result_t (*discard_frame)(struct xrt_compositor *xc, int64_t frame_id);
1231
1232 /*! @} */
1233
1234
1235 /*!
1236 * @name Function pointers for layer submission
1237 * @{
1238 */
1239 /*!
1240 * @brief Begins layer submission.
1241 *
1242 * This and the other `layer_*` calls are equivalent to xrEndFrame,
1243 * except split over multiple calls. It's only after
1244 * xrt_compositor::layer_commit that layers will be displayed.
1245 * From the point of view of the swapchain, the image is used as
1246 * soon as it's given in a call.
1247 */
1248 xrt_result_t (*layer_begin)(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data);
1249
1250 /*!
1251 * @brief Adds a projection layer for submissions.
1252 *
1253 * Note that e.g. the same swapchain object may be passed as both
1254 * @p l_xsc and @p r_xsc - the parameters in @p data identify
1255 * the subrect and array texture index to use for each of the views.
1256 *
1257 * @param xc Self pointer
1258 * @param xdev The device the layer is relative to.
1259 * @param xsc Array of swapchain objects containing eye RGB data.
1260 * @param data All of the pure data bits (not pointers/handles),
1261 * including what parts of the supplied swapchain
1262 * objects to use for each view.
1263 */
1264 xrt_result_t (*layer_projection)(struct xrt_compositor *xc,
1265 struct xrt_device *xdev,
1266 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
1267 const struct xrt_layer_data *data);
1268
1269 /*!
1270 * @brief Adds a projection layer for submission, has depth information.
1271 *
1272 * Note that e.g. the same swapchain object may be passed as both
1273 * @p l_xsc and @p r_xsc - the parameters in @p data identify
1274 * the subrect and array texture index to use for each of the views.
1275 * This flexibility is required by the OpenXR API and is passed through
1276 * to the compositor to preserve the maximum information
1277 *
1278 * @param xc Self pointer
1279 * @param xdev The device the layer is relative to.
1280 * @param xsc Array of swapchain objects containing eye RGB data.
1281 * @param d_xsc Array of swapchain objects containing eye depth data.
1282 * @param data All of the pure data bits (not pointers/handles),
1283 * including what parts of the supplied swapchain
1284 * objects to use for each view.
1285 */
1286 xrt_result_t (*layer_projection_depth)(struct xrt_compositor *xc,
1287 struct xrt_device *xdev,
1288 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
1289 struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS],
1290 const struct xrt_layer_data *data);
1291
1292 /*!
1293 * Adds a quad layer for submission, the center of the quad is specified
1294 * by the pose and extends outwards from it.
1295 *
1296 * @param xc Self pointer
1297 * @param xdev The device the layer is relative to.
1298 * @param xsc Swapchain.
1299 * @param data All of the pure data bits (not pointers/handles),
1300 * including what part of the supplied swapchain
1301 * object to use.
1302 */
1303 xrt_result_t (*layer_quad)(struct xrt_compositor *xc,
1304 struct xrt_device *xdev,
1305 struct xrt_swapchain *xsc,
1306 const struct xrt_layer_data *data);
1307
1308 /*!
1309 * Adds a cube layer for submission.
1310 *
1311 * @param xc Self pointer
1312 * @param xdev The device the layer is relative to.
1313 * @param xsc Swapchain.
1314 * @param data All of the pure data bits (not pointers/handles),
1315 * including what part of the supplied swapchain
1316 * object to use.
1317 */
1318 xrt_result_t (*layer_cube)(struct xrt_compositor *xc,
1319 struct xrt_device *xdev,
1320 struct xrt_swapchain *xsc,
1321 const struct xrt_layer_data *data);
1322
1323 /*!
1324 * Adds a cylinder layer for submission.
1325 *
1326 * @param xc Self pointer
1327 * @param xdev The device the layer is relative to.
1328 * @param xsc Swapchain.
1329 * @param data All of the pure data bits (not pointers/handles),
1330 * including what part of the supplied swapchain
1331 * object to use.
1332 */
1333 xrt_result_t (*layer_cylinder)(struct xrt_compositor *xc,
1334 struct xrt_device *xdev,
1335 struct xrt_swapchain *xsc,
1336 const struct xrt_layer_data *data);
1337
1338 /*!
1339 * Adds a equirect1 layer for submission.
1340 *
1341 * @param xc Self pointer
1342 * @param xdev The device the layer is relative to.
1343 * @param xsc Swapchain.
1344 * @param data All of the pure data bits (not pointers/handles),
1345 * including what part of the supplied swapchain
1346 * object to use.
1347 */
1348 xrt_result_t (*layer_equirect1)(struct xrt_compositor *xc,
1349 struct xrt_device *xdev,
1350 struct xrt_swapchain *xsc,
1351 const struct xrt_layer_data *data);
1352
1353
1354 /*!
1355 * Adds a equirect2 layer for submission.
1356 *
1357 * @param xc Self pointer
1358 * @param xdev The device the layer is relative to.
1359 * @param xsc Swapchain.
1360 * @param data All of the pure data bits (not pointers/handles),
1361 * including what part of the supplied swapchain
1362 * object to use.
1363 */
1364 xrt_result_t (*layer_equirect2)(struct xrt_compositor *xc,
1365 struct xrt_device *xdev,
1366 struct xrt_swapchain *xsc,
1367 const struct xrt_layer_data *data);
1368
1369 /*!
1370 * Adds a passthrough layer for submission.
1371 *
1372 * @param xc Self pointer
1373 * @param xdev The device the layer is relative to.
1374 * @param data All of the pure data bits (not pointers/handles),
1375 * including what part of the supplied swapchain
1376 * object to use.
1377 */
1378 xrt_result_t (*layer_passthrough)(struct xrt_compositor *xc,
1379 struct xrt_device *xdev,
1380 const struct xrt_layer_data *data);
1381
1382 /*!
1383 * @brief Commits all of the submitted layers.
1384 *
1385 * Only after this call will the compositor actually use the layers.
1386 */
1387 xrt_result_t (*layer_commit)(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle);
1388
1389 /*!
1390 * @brief Commits all of the submitted layers, with a semaphore.
1391 *
1392 * Only after this call will the compositor actually use the layers.
1393 * @param xc Self pointer
1394 * @param xcsem Semaphore that will be signalled when the app GPU
1395 * work has completed.
1396 * @param value Semaphore value upone completion of GPU work.
1397 */
1398 xrt_result_t (*layer_commit_with_semaphore)(struct xrt_compositor *xc,
1399 struct xrt_compositor_semaphore *xcsem,
1400 uint64_t value);
1401
1402 /*! @} */
1403
1404
1405 /*!
1406 * @name Function pointers for XR_FB_display_refresh_rate.
1407 * @{
1408 */
1409
1410 /*!
1411 * Get the current display refresh rate.
1412 *
1413 * @param xc Self pointer
1414 * @param out_display_refresh_rate_hz Current display refresh rate in Hertz.
1415 */
1416 xrt_result_t (*get_display_refresh_rate)(struct xrt_compositor *xc, float *out_display_refresh_rate_hz);
1417
1418 /*!
1419 * Request system to change the display refresh rate to the requested value.
1420 *
1421 * @param xc Self pointer
1422 * @param display_refresh_rate_hz Requested display refresh rate in Hertz.
1423 */
1424 xrt_result_t (*request_display_refresh_rate)(struct xrt_compositor *xc, float display_refresh_rate_hz);
1425
1426 /*! @} */
1427
1428
1429 /*!
1430 * @brief Set CPU/GPU performance level.
1431 */
1432 xrt_result_t (*set_performance_level)(struct xrt_compositor *xc,
1433 enum xrt_perf_domain domain,
1434 enum xrt_perf_set_level level);
1435
1436 /*!
1437 * @brief Get the extents of the reference space's bounds rectangle.
1438 */
1439 xrt_result_t (*get_reference_bounds_rect)(struct xrt_compositor *xc,
1440 enum xrt_reference_space_type reference_space_type,
1441 struct xrt_vec2 *bounds);
1442
1443 /*!
1444 * Teardown the compositor.
1445 *
1446 * The state tracker must have made sure that no frames or sessions are
1447 * currently pending.
1448 *
1449 * @see xrt_compositor::discard_frame or xrt_compositor::end_frame for a pending frame
1450 * @see xrt_compositor::end_session for an open session.
1451 */
1452 void (*destroy)(struct xrt_compositor *xc);
1453
1454 /*!
1455 * @name Function pointers for extensions
1456 * @{
1457 */
1458
1459 /*!
1460 * @brief Set thread attributes according to thread type
1461 */
1462 xrt_result_t (*set_thread_hint)(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id);
1463
1464 /*! @} */
1465};
1466
1467/*!
1468 * @copydoc xrt_compositor::get_swapchain_create_properties
1469 *
1470 * Helper for calling through the function pointer.
1471 *
1472 * @public @memberof xrt_compositor
1473 */
1474XRT_NONNULL_ALL static inline xrt_result_t
1476 const struct xrt_swapchain_create_info *info,
1477 struct xrt_swapchain_create_properties *xsccp)
1478{
1479 return xc->get_swapchain_create_properties(xc, info, xsccp);
1480}
1481
1482/*!
1483 * @name Swapchain and sync creation and import methods
1484 * @{
1485 */
1486
1487/*!
1488 * @copydoc xrt_compositor::create_swapchain
1489 *
1490 * Helper for calling through the function pointer.
1491 *
1492 * @public @memberof xrt_compositor
1493 */
1494XRT_NONNULL_ALL static inline xrt_result_t
1496 const struct xrt_swapchain_create_info *info,
1497 struct xrt_swapchain **out_xsc)
1498{
1499 return xc->create_swapchain(xc, info, out_xsc);
1500}
1501
1502/*!
1503 * @copydoc xrt_compositor::import_swapchain
1504 *
1505 * Helper for calling through the function pointer.
1506 *
1507 * @public @memberof xrt_compositor
1508 */
1509XRT_NONNULL_ALL static inline xrt_result_t
1511 const struct xrt_swapchain_create_info *info,
1512 struct xrt_image_native *native_images,
1513 uint32_t image_count,
1514 struct xrt_swapchain **out_xsc)
1515{
1516 return xc->import_swapchain(xc, info, native_images, image_count, out_xsc);
1517}
1518
1519/*!
1520 * @copydoc xrt_compositor::import_fence
1521 *
1522 * Helper for calling through the function pointer.
1523 *
1524 * @public @memberof xrt_compositor
1525 */
1526XRT_NONNULL_ALL static inline xrt_result_t
1529 struct xrt_compositor_fence **out_xcf)
1530{
1531 return xc->import_fence(xc, handle, out_xcf);
1532}
1533
1534/*!
1535 * @copydoc xrt_compositor::create_semaphore
1536 *
1537 * Helper for calling through the function pointer.
1538 *
1539 * @public @memberof xrt_compositor
1540 */
1541XRT_NONNULL_ALL static inline xrt_result_t
1543 xrt_graphics_sync_handle_t *out_handle,
1544 struct xrt_compositor_semaphore **out_xcsem)
1545{
1546 return xc->create_semaphore(xc, out_handle, out_xcsem);
1547}
1548
1549/*! @} */
1550
1551/*!
1552 * @copydoc xrt_compositor::create_passthrough
1553 *
1554 * Helper for calling through the function pointer.
1555 *
1556 * @public @memberof xrt_compositor
1557 */
1558XRT_NONNULL_ALL static inline xrt_result_t
1560{
1561 return xc->create_passthrough(xc, info);
1562}
1563
1564/*!
1565 * @copydoc xrt_compositor::create_passthrough_layer
1566 *
1567 * Helper for calling through the function pointer.
1568 *
1569 * @public @memberof xrt_compositor
1570 */
1571XRT_NONNULL_ALL static inline xrt_result_t
1573{
1574 return xc->create_passthrough_layer(xc, info);
1575}
1576
1577/*!
1578 * @copydoc xrt_compositor::destroy_passthrough
1579 *
1580 * Helper for calling through the function pointer.
1581 *
1582 * @public @memberof xrt_compositor
1583 */
1584XRT_NONNULL_ALL static inline xrt_result_t
1586{
1587 return xc->destroy_passthrough(xc);
1588}
1589
1590/*!
1591 * @name Session methods
1592 * @{
1593 */
1594
1595/*!
1596 * @copydoc xrt_compositor::begin_session
1597 *
1598 * Helper for calling through the function pointer.
1599 *
1600 * @public @memberof xrt_compositor
1601 */
1602XRT_NONNULL_ALL static inline xrt_result_t
1604{
1605 return xc->begin_session(xc, info);
1606}
1607
1608/*!
1609 * @copydoc xrt_compositor::end_session
1610 *
1611 * Helper for calling through the function pointer.
1612 *
1613 * @public @memberof xrt_compositor
1614 */
1615XRT_NONNULL_ALL static inline xrt_result_t
1617{
1618 return xc->end_session(xc);
1619}
1620
1621/*! @} */
1622
1623
1624/*!
1625 * @name Frame-related methods
1626 * @brief Related to the OpenXR `xr*Frame` functions
1627 * @{
1628 */
1629
1630/*!
1631 * @copydoc xrt_compositor::predict_frame
1632 *
1633 * Helper for calling through the function pointer.
1634 *
1635 * @public @memberof xrt_compositor
1636 */
1637XRT_NONNULL_ALL static inline xrt_result_t
1639 int64_t *out_frame_id,
1640 int64_t *out_wake_time_ns,
1641 int64_t *out_predicted_gpu_time_ns,
1642 int64_t *out_predicted_display_time_ns,
1643 int64_t *out_predicted_display_period_ns)
1644{
1645 return xc->predict_frame( //
1646 xc, //
1647 out_frame_id, //
1648 out_wake_time_ns, //
1649 out_predicted_gpu_time_ns, //
1650 out_predicted_display_time_ns, //
1651 out_predicted_display_period_ns); //
1652}
1653
1654/*!
1655 * @copydoc xrt_compositor::mark_frame
1656 *
1657 * Helper for calling through the function pointer.
1658 *
1659 * @public @memberof xrt_compositor
1660 */
1661XRT_NONNULL_ALL static inline xrt_result_t
1662xrt_comp_mark_frame(struct xrt_compositor *xc, int64_t frame_id, enum xrt_compositor_frame_point point, int64_t when_ns)
1663{
1664 return xc->mark_frame(xc, frame_id, point, when_ns);
1665}
1666
1667/*!
1668 * @copydoc xrt_compositor::wait_frame
1669 *
1670 * Helper for calling through the function pointer.
1671 *
1672 * @public @memberof xrt_compositor
1673 */
1674XRT_NONNULL_ALL static inline xrt_result_t
1676 int64_t *out_frame_id,
1677 int64_t *out_predicted_display_time,
1678 int64_t *out_predicted_display_period)
1679{
1680 return xc->wait_frame(xc, out_frame_id, out_predicted_display_time, out_predicted_display_period);
1681}
1682
1683/*!
1684 * @copydoc xrt_compositor::begin_frame
1685 *
1686 * Helper for calling through the function pointer.
1687 *
1688 * @public @memberof xrt_compositor
1689 */
1690XRT_NONNULL_ALL static inline xrt_result_t
1691xrt_comp_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
1692{
1693 return xc->begin_frame(xc, frame_id);
1694}
1695
1696/*!
1697 * @copydoc xrt_compositor::discard_frame
1698 *
1699 * Helper for calling through the function pointer.
1700 *
1701 * @public @memberof xrt_compositor
1702 */
1703XRT_NONNULL_ALL static inline xrt_result_t
1704xrt_comp_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
1705{
1706 return xc->discard_frame(xc, frame_id);
1707}
1708
1709/*! @} */
1710
1711
1712/*!
1713 * @name Layer submission methods
1714 * @brief Equivalent to `xrEndFrame`, but split across multiple calls.
1715 * @{
1716 */
1717
1718/*!
1719 * @copydoc xrt_compositor::layer_begin
1720 *
1721 * Helper for calling through the function pointer.
1722 *
1723 * @public @memberof xrt_compositor
1724 */
1725XRT_NONNULL_ALL static inline xrt_result_t
1727{
1728 return xc->layer_begin(xc, data);
1729}
1730
1731/*!
1732 * @copydoc xrt_compositor::layer_projection
1733 *
1734 * Helper for calling through the function pointer.
1735 *
1736 * @public @memberof xrt_compositor
1737 */
1738XRT_NONNULL_ALL static inline xrt_result_t
1740 struct xrt_device *xdev,
1741 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
1742 const struct xrt_layer_data *data)
1743{
1744 return xc->layer_projection(xc, xdev, xsc, data);
1745}
1746
1747/*!
1748 * @copydoc xrt_compositor::layer_projection_depth
1749 *
1750 * Helper for calling through the function pointer.
1751 *
1752 * @public @memberof xrt_compositor
1753 */
1754XRT_NONNULL_ALL static inline xrt_result_t
1756 struct xrt_device *xdev,
1757 struct xrt_swapchain *xsc[XRT_MAX_VIEWS],
1758 struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS],
1759 const struct xrt_layer_data *data)
1760{
1761 return xc->layer_projection_depth(xc, xdev, xsc, d_xsc, data);
1762}
1763
1764/*!
1765 * @copydoc xrt_compositor::layer_quad
1766 *
1767 * Helper for calling through the function pointer.
1768 *
1769 * @public @memberof xrt_compositor
1770 */
1771XRT_NONNULL_ALL static inline xrt_result_t
1773 struct xrt_device *xdev,
1774 struct xrt_swapchain *xsc,
1775 const struct xrt_layer_data *data)
1776{
1777 return xc->layer_quad(xc, xdev, xsc, data);
1778}
1779
1780/*!
1781 * @copydoc xrt_compositor::layer_cube
1782 *
1783 * Helper for calling through the function pointer.
1784 *
1785 * @public @memberof xrt_compositor
1786 */
1787XRT_NONNULL_ALL static inline xrt_result_t
1789 struct xrt_device *xdev,
1790 struct xrt_swapchain *xsc,
1791 const struct xrt_layer_data *data)
1792{
1793 return xc->layer_cube(xc, xdev, xsc, data);
1794}
1795
1796/*!
1797 * @copydoc xrt_compositor::layer_cylinder
1798 *
1799 * Helper for calling through the function pointer.
1800 *
1801 * @public @memberof xrt_compositor
1802 */
1803XRT_NONNULL_ALL static inline xrt_result_t
1805 struct xrt_device *xdev,
1806 struct xrt_swapchain *xsc,
1807 const struct xrt_layer_data *data)
1808{
1809 return xc->layer_cylinder(xc, xdev, xsc, data);
1810}
1811
1812
1813/*!
1814 * @copydoc xrt_compositor::layer_equirect1
1815 *
1816 * Helper for calling through the function pointer.
1817 *
1818 * @public @memberof xrt_compositor
1819 */
1820XRT_NONNULL_ALL static inline xrt_result_t
1822 struct xrt_device *xdev,
1823 struct xrt_swapchain *xsc,
1824 const struct xrt_layer_data *data)
1825{
1826 return xc->layer_equirect1(xc, xdev, xsc, data);
1827}
1828
1829/*!
1830 * @copydoc xrt_compositor::layer_equirect2
1831 *
1832 * Helper for calling through the function pointer.
1833 *
1834 * @public @memberof xrt_compositor
1835 */
1836XRT_NONNULL_ALL static inline xrt_result_t
1838 struct xrt_device *xdev,
1839 struct xrt_swapchain *xsc,
1840 const struct xrt_layer_data *data)
1841{
1842 return xc->layer_equirect2(xc, xdev, xsc, data);
1843}
1844
1845/*!
1846 * @copydoc xrt_compositor::layer_passthrough
1847 *
1848 * Helper for calling through the function pointer.
1849 *
1850 * @public @memberof xrt_compositor
1851 */
1852XRT_NONNULL_ALL static inline xrt_result_t
1853xrt_comp_layer_passthrough(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
1854{
1855 return xc->layer_passthrough(xc, xdev, data);
1856}
1857
1858/*!
1859 * @copydoc xrt_compositor::layer_commit
1860 *
1861 * Helper for calling through the function pointer.
1862 *
1863 * @public @memberof xrt_compositor
1864 */
1865XRT_NONNULL_FIRST
1866static inline xrt_result_t
1868{
1869 return xc->layer_commit(xc, sync_handle);
1870}
1871
1872/*!
1873 * @copydoc xrt_compositor::layer_commit_with_semaphore
1874 *
1875 * Helper for calling through the function pointer.
1876 *
1877 * @public @memberof xrt_compositor
1878 */
1879XRT_NONNULL_ALL static inline xrt_result_t
1881{
1882 return xc->layer_commit_with_semaphore(xc, xcsem, value);
1883}
1884
1885/*! @} */
1886
1887/*!
1888 * @copydoc xrt_compositor::get_display_refresh_rate
1889 *
1890 * Helper for calling through the function pointer.
1891 *
1892 * @public @memberof xrt_compositor
1893 */
1894XRT_NONNULL_ALL static inline xrt_result_t
1895xrt_comp_get_display_refresh_rate(struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
1896{
1897 return xc->get_display_refresh_rate(xc, out_display_refresh_rate_hz);
1898}
1899
1900/*!
1901 * @copydoc xrt_compositor::request_display_refresh_rate
1902 *
1903 * Helper for calling through the function pointer.
1904 *
1905 * @public @memberof xrt_compositor
1906 */
1907XRT_NONNULL_ALL static inline xrt_result_t
1908xrt_comp_request_display_refresh_rate(struct xrt_compositor *xc, float display_refresh_rate_hz)
1909{
1910 return xc->request_display_refresh_rate(xc, display_refresh_rate_hz);
1911}
1912
1913
1914/*!
1915 * @copydoc xrt_compositor::set_performance_level
1916 *
1917 * Helper for calling through the function pointer.
1918 *
1919 * @public @memberof xrt_compositor
1920 */
1921XRT_NONNULL_ALL static inline xrt_result_t
1923{
1924 return xc->set_performance_level(xc, domain, level);
1925}
1926
1927/*!
1928 * @copydoc xrt_compositor::get_reference_bounds_rect
1929 *
1930 * Helper for calling through the function pointer.
1931 *
1932 * @public @memberof xrt_compositor
1933 */
1934XRT_NONNULL_ALL static inline xrt_result_t
1936 enum xrt_reference_space_type reference_space_type,
1937 struct xrt_vec2 *bounds)
1938{
1939 if (xc->get_reference_bounds_rect == NULL) {
1941 }
1942
1943 return xc->get_reference_bounds_rect(xc, reference_space_type, bounds);
1944}
1945
1946/*!
1947 * @copydoc xrt_compositor::destroy
1948 *
1949 * Helper for calling through the function pointer: does a null check and sets
1950 * xc_ptr to null if freed.
1951 *
1952 * @public @memberof xrt_compositor
1953 */
1954XRT_NONNULL_ALL static inline void
1956{
1957 struct xrt_compositor *xc = *xc_ptr;
1958 if (xc == NULL) {
1959 return;
1960 }
1961
1962 xc->destroy(xc);
1963 *xc_ptr = NULL;
1964}
1965
1966/*!
1967 * @name Function pointers for extensions
1968 * @{
1969 */
1970
1971/*!
1972 * @brief Set thread attributes according to thread type
1973 */
1974XRT_NONNULL_ALL static inline xrt_result_t
1975xrt_comp_set_thread_hint(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id)
1976{
1977 return xc->set_thread_hint(xc, hint, thread_id);
1978}
1979
1980/*! @} */
1981
1982/*
1983 *
1984 * OpenGL interface.
1985 *
1986 */
1987
1988/*!
1989 * Base class for an OpenGL (ES) client swapchain.
1990 *
1991 * @ingroup xrt_iface comp_client
1992 * @extends xrt_swapchain
1993 */
1995{
1996 //! @public Base
1997 struct xrt_swapchain base;
1998
1999 // GLuint
2000 unsigned int images[XRT_MAX_SWAPCHAIN_IMAGES];
2001};
2002
2003/*!
2004 * Base class for an OpenGL (ES) client compositor.
2005 *
2006 * @ingroup xrt_iface comp_client
2007 * @extends xrt_compositor
2008 */
2010{
2011 struct xrt_compositor base;
2012};
2013
2014/*!
2015 * Down-cast helper.
2016 *
2017 * @private @memberof xrt_swapchain_gl
2018 *
2019 * @todo unused - remove?
2020 */
2021static inline struct xrt_swapchain_gl *
2023{
2024 return (struct xrt_swapchain_gl *)xsc;
2025}
2026
2027/*!
2028 * Down-cast helper.
2029 *
2030 * @private @memberof xrt_compositor_gl
2031 *
2032 * @todo unused - remove?
2033 */
2034static inline struct xrt_compositor_gl *
2036{
2037 return (struct xrt_compositor_gl *)xc;
2038}
2039
2040
2041/*
2042 *
2043 * Vulkan interface.
2044 *
2045 */
2046
2047/*!
2048 * Base class for a Vulkan client swapchain.
2049 *
2050 * @ingroup xrt_iface comp_client
2051 * @extends xrt_swapchain
2052 */
2054{
2055 //! @public Base
2056 struct xrt_swapchain base;
2057
2058 //! Images to be used by the caller.
2060};
2061
2062/*!
2063 * Base class for a Vulkan client compositor.
2064 *
2065 * @ingroup xrt_iface comp_client
2066 * @extends xrt_compositor
2067 */
2069{
2070 //! @public Base
2071 struct xrt_compositor base;
2072};
2073
2074/*!
2075 * Down-cast helper.
2076 *
2077 * @private @memberof xrt_swapchain_vk
2078 *
2079 * @todo unused - remove?
2080 */
2081static inline struct xrt_swapchain_vk *
2083{
2084 return (struct xrt_swapchain_vk *)xsc;
2085}
2086
2087/*!
2088 * Down-cast helper.
2089 *
2090 * @private @memberof xrt_compositor_vk
2091 *
2092 * @todo unused - remove?
2093 */
2094static inline struct xrt_compositor_vk *
2096{
2097 return (struct xrt_compositor_vk *)xc;
2098}
2099
2100#if defined(XRT_HAVE_D3D11) || defined(XRT_DOXYGEN)
2101
2102/*
2103 *
2104 * D3D11 interface.
2105 *
2106 */
2107
2108/*!
2109 * Base class for a D3D11 client swapchain.
2110 *
2111 * @ingroup xrt_iface comp_client
2112 * @extends xrt_swapchain
2113 */
2115{
2116 //! @public Base
2117 struct xrt_swapchain base;
2118
2119 //! Images to be used by the caller.
2120 ID3D11Texture2D *images[XRT_MAX_SWAPCHAIN_IMAGES];
2121};
2122
2123/*!
2124 * Base class for a D3D11 client compositor.
2125 *
2126 * @ingroup xrt_iface comp_client
2127 * @extends xrt_compositor
2128 */
2130{
2131 //! @public Base
2132 struct xrt_compositor base;
2133};
2134
2135/*!
2136 * Graphics usage requirements for D3D APIs.
2137 *
2138 * @ingroup xrt_iface
2139 */
2141{
2142 LUID adapter_luid;
2143 D3D_FEATURE_LEVEL min_feature_level;
2144};
2145
2146#endif // XRT_OS_WINDOWS
2147
2148
2149#if defined(XRT_HAVE_D3D12) || defined(XRT_DOXYGEN)
2150/*
2151 *
2152 * D3D12 interface.
2153 *
2154 */
2155
2156/*!
2157 * Base class for a D3D12 client swapchain.
2158 *
2159 * @ingroup xrt_iface comp_client
2160 * @extends xrt_swapchain
2161 */
2163{
2164 //! @public Base
2165 struct xrt_swapchain base;
2166
2167 //! Images to be used by the caller.
2168 ID3D12Resource *images[XRT_MAX_SWAPCHAIN_IMAGES];
2169};
2170
2171/*!
2172 * Base class for a D3D12 client compositor.
2173 *
2174 * @ingroup xrt_iface comp_client
2175 * @extends xrt_compositor
2176 */
2178{
2179 //! @public Base
2180 struct xrt_compositor base;
2181};
2182#endif
2183
2184/*
2185 *
2186 * Native interface.
2187 *
2188 * These types are supported by underlying native buffers, which are DMABUF file
2189 * descriptors on Linux.
2190 *
2191 */
2192
2193/*!
2194 * A single image of a swapchain based on native buffer handles.
2195 *
2196 * @ingroup xrt_iface comp
2197 * @see xrt_swapchain_native, xrt_graphics_buffer_handle_t
2198 */
2200{
2201 /*!
2202 * Native buffer handle.
2203 */
2205
2206 /*!
2207 * @brief Buffer size in memory.
2208 *
2209 * Optional, set to 0 if unknown at allocation time.
2210 * If not zero, used for a max memory requirements check when importing
2211 * into Vulkan.
2212 */
2213 uint64_t size;
2214
2215 /*!
2216 * Is the image created with a dedicated allocation or not.
2217 */
2219
2220 /*!
2221 * Is the native buffer handle a DXGI handle?
2222 *
2223 * - If true, it is some kind of weird global handle, not reference counted, but
2224 * widely compatible with various images. Ostensibly deprecated, but works the best
2225 * on Windows.
2226 * - If false, it's either not Windows, or a reference counted "NT Handle"
2227 * which has awkward limitations, such as "usually no depth images allowed".
2228 */
2230};
2231
2232/*!
2233 * @interface xrt_swapchain_native
2234 * Base class for a swapchain that exposes a native buffer handle to be imported
2235 * into a client API.
2236 *
2237 * @ingroup xrt_iface comp
2238 * @extends xrt_swapchain
2239 */
2241{
2242 //! @public Base
2243 struct xrt_swapchain base;
2244
2245 /*!
2246 * Unique id for the swapchain, only unique for the current process, is
2247 * not synchronized between service and any apps via the IPC layer.
2248 */
2250
2252};
2253
2254/*!
2255 * @copydoc xrt_swapchain_reference
2256 *
2257 * @relates xrt_swapchain_native
2258 */
2259static inline void
2261{
2262 xrt_swapchain_reference((struct xrt_swapchain **)dst, (struct xrt_swapchain *)src);
2263}
2264
2265/*!
2266 * @interface xrt_compositor_native
2267 *
2268 * Main compositor server interface.
2269 *
2270 * @ingroup xrt_iface comp
2271 * @extends xrt_compositor
2272 */
2274{
2275 //! @public Base
2276 struct xrt_compositor base;
2277};
2278
2279/*!
2280 * @brief Create a native swapchain with a set of images.
2281 *
2282 * A specialized version of @ref xrt_comp_create_swapchain, for use only on @ref
2283 * xrt_compositor_native.
2284 *
2285 * Helper for calling through the base's function pointer then performing the
2286 * known-safe downcast.
2287 *
2288 * The pointer pointed to by @p out_xsc has to either be NULL or a valid
2289 * @ref xrt_swapchain pointer. If there is a valid @ref xrt_swapchain
2290 * pointed by the pointed pointer it will have it reference decremented.
2291 *
2292 * @public @memberof xrt_compositor_native
2293 */
2294XRT_NONNULL_ALL static inline xrt_result_t
2296 const struct xrt_swapchain_create_info *info,
2297 struct xrt_swapchain_native **out_xscn)
2298{
2299 struct xrt_swapchain *xsc = NULL; // Has to be NULL.
2300
2301 xrt_result_t ret = xrt_comp_create_swapchain(&xcn->base, info, &xsc);
2302 if (ret == XRT_SUCCESS) {
2303 // Need to unref any swapchain already there first.
2304 xrt_swapchain_native_reference(out_xscn, NULL);
2305
2306 // Already referenced.
2307 *out_xscn = (struct xrt_swapchain_native *)xsc;
2308 }
2309
2310 return ret;
2311}
2312
2313/*!
2314 * @copydoc xrt_compositor::destroy
2315 *
2316 * Helper for calling through the function pointer: does a null check and sets
2317 * xcn_ptr to null if freed.
2318 *
2319 * @public @memberof xrt_compositor_native
2320 */
2321XRT_NONNULL_ALL static inline void
2323{
2324 struct xrt_compositor_native *xcn = *xcn_ptr;
2325 if (xcn == NULL) {
2326 return;
2327 }
2328
2329 xcn->base.destroy(&xcn->base);
2330 *xcn_ptr = NULL;
2331}
2332
2333/*!
2334 * Holds information about the view configuration properties for a view in a system compositor.
2335 */
2337{
2338 struct
2339 {
2340 uint32_t width_pixels;
2341 uint32_t height_pixels;
2342 uint32_t sample_count;
2343 } recommended; //!< Recommended for this view.
2344
2345 struct
2346 {
2347 uint32_t width_pixels;
2348 uint32_t height_pixels;
2349 uint32_t sample_count;
2350 } max; //!< Maximums for this view.
2351};
2352
2354{
2355 //! Which view type this is for, mono, stereo, quad_with_inset, etc...
2357
2358 //! Must match the view_type, in the future view_types might have variable views.
2359 uint32_t view_count;
2360
2361 //! The per view information.
2362 struct xrt_view_config_properties views[XRT_MAX_COMPOSITOR_VIEW_CONFIGS_VIEW_COUNT];
2363};
2364
2365
2366/*
2367 *
2368 * System composition: how to composite on a system, either directly or by combining layers from multiple apps
2369 *
2370 */
2371
2372/*!
2373 * Capabilities and information about the system compositor (and its wrapped native compositor, if any),
2374 * and device together.
2375 */
2377{
2378 uint32_t view_type_count;
2379 enum xrt_view_type view_types[XRT_MAX_COMPOSITOR_VIEW_CONFIGS_COUNT];
2380
2381 //! Maximum number of composition layers supported, never changes.
2382 uint32_t max_layers;
2383
2384 /*!
2385 * Blend modes supported by the system (the combination of the
2386 * compositor and the HMD capabilities), never changes.
2387 *
2388 * In preference order. Based on the modes reported by the device,
2389 * but the compositor has a chance to modify this.
2390 */
2391 enum xrt_blend_mode supported_blend_modes[XRT_BLEND_MODE_MAX_ENUM];
2392
2393 //! Number of meaningful elements in xrt_system_compositor_info::supported_blend_modes
2395
2396 uint32_t refresh_rate_count;
2397 float refresh_rates_hz[XRT_MAX_SUPPORTED_REFRESH_RATES];
2398
2399 //! The vk device as used by the compositor, never changes.
2401
2402 //! The vk device suggested for Vulkan clients, never changes.
2404
2405 //! The (Windows) LUID for the GPU device suggested for D3D clients, never changes.
2407
2408 //! Whether @ref client_d3d_deviceLUID is valid
2410
2411 //! Whether submitting projection layers of a differing FOV from the target FOV is supported.
2413};
2414
2416
2417/*!
2418 * @interface xrt_multi_compositor_control
2419 * Special functions to control multi session/clients.
2420 * Effectively an optional aspect of @ref xrt_system_compositor
2421 * exposed by implementations that can combine layers from multiple sessions/clients.
2422 */
2424{
2425 /*!
2426 * Sets the state of the compositor, generating any events to the client
2427 * if the state is actually changed. Input focus is enforced/handled by
2428 * a different component but is still signaled by the compositor.
2429 */
2431 struct xrt_compositor *xc,
2432 bool visible,
2433 bool focused,
2434 int64_t timestamp_ns);
2435
2436 /*!
2437 * Set the rendering Z order for rendering, visible has higher priority
2438 * then z_order but is still saved until visible again. This a signed
2439 * 64 bit integer compared to a unsigned 32 bit integer in OpenXR, so
2440 * that non-overlay clients can be handled like overlay ones.
2441 */
2442 xrt_result_t (*set_z_order)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t z_order);
2443
2444 /*!
2445 * Set the chroma key parameters for the base app's projection layers.
2446 * This is used to punch holes through opaque projection layers and adjust their blend mode.
2447 * Uses HSV min/max range for flexible color targeting.
2448 *
2449 * @param hsv_min Minimum HSV bounds
2450 * @param hsv_max Maximum HSV bounds
2451 * @param curve Power curve for alpha falloff
2452 * @param despill Despill strength
2453 */
2454 xrt_result_t (*set_base_chroma_key_params)(struct xrt_system_compositor *xsc,
2455 struct xrt_colour_hsv_f32 hsv_min,
2456 struct xrt_colour_hsv_f32 hsv_max,
2457 float curve,
2458 float despill);
2459
2460 /*!
2461 * Tell this client/session if the main application is visible or not.
2462 */
2463 xrt_result_t (*set_main_app_visibility)(struct xrt_system_compositor *xsc,
2464 struct xrt_compositor *xc,
2465 bool visible);
2466
2467 /*!
2468 * Notify this client/session if the compositor is going to lose the ability of rendering.
2469 *
2470 * @param loss_time_ns System monotonic timestamps, such as returned by os_monotonic_get_ns().
2471 */
2472 xrt_result_t (*notify_loss_pending)(struct xrt_system_compositor *xsc,
2473 struct xrt_compositor *xc,
2474 int64_t loss_time_ns);
2475
2476 /*!
2477 * Notify this client/session if the compositor lost the ability of rendering.
2478 */
2479 xrt_result_t (*notify_lost)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc);
2480
2481 /*!
2482 * Notify this client/session if the display refresh rate has been changed.
2483 */
2484 xrt_result_t (*notify_display_refresh_changed)(struct xrt_system_compositor *xsc,
2485 struct xrt_compositor *xc,
2486 float from_display_refresh_rate_hz,
2487 float to_display_refresh_rate_hz);
2488};
2489
2490/*!
2491 * The system compositor handles composition for a system.
2492 * It is not itself a "compositor" (as in xrt_compositor), but it can create/own compositors.
2493 * - In a multi-app capable system, the system compositor may own an internal compositor, and
2494 * xrt_system_compositor::create_native_compositor will
2495 * create a compositor that submits layers to a merging mechanism.
2496 * - In a non-multi-app capable system, xrt_system_compositor::create_native_compositor
2497 * creates normal, native compositors, that do not wrap or feed into any other compositor.
2498 *
2499 * This is a long lived object: it has the same life time as an XrSystemID.
2500 */
2502{
2503 /*!
2504 * An optional aspect/additional interface, providing multi-app control.
2505 * Populated if this system compositor supports multi client controls.
2506 */
2508
2509 //! Info regarding the system.
2511
2512 /*!
2513 * Create a new native compositor.
2514 *
2515 * This signals that you want to start XR, and as such implicitly brings
2516 * up a new session. Does not "call" `xrBeginSession`.
2517 *
2518 * Some system compositors might only support one `xrt_compositor`
2519 * active at a time, will return `XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED`
2520 * if this is the case.
2521 *
2522 * In a multi-session capable system compositor, this may return a "proxy"
2523 * for feeding a single client's layers to a compositor or a layer merging mechanism,
2524 * rather than a raw native compositor (not wrapping or forwarding) directly.
2525 */
2526 xrt_result_t (*create_native_compositor)(struct xrt_system_compositor *xsc,
2527 const struct xrt_session_info *xsi,
2528 struct xrt_session_event_sink *xses,
2529 struct xrt_compositor_native **out_xcn);
2530
2531 /*!
2532 * Gets the view configuration for the specified view type.
2533 */
2534 xrt_result_t (*get_view_config)(struct xrt_system_compositor *xsc,
2535 enum xrt_view_type view_type,
2536 struct xrt_view_config *out_view_config);
2537
2538 /*!
2539 * Teardown the system compositor.
2540 *
2541 * The state tracker must make sure that no compositors are alive.
2542 */
2543 void (*destroy)(struct xrt_system_compositor *xsc);
2544};
2545
2546/*!
2547 * @copydoc xrt_multi_compositor_control::set_state
2548 *
2549 * Helper for calling through the function pointer.
2550 *
2551 * If the system compositor @p xsc does not implement @ref xrt_multi_compositor_control,
2552 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2553 *
2554 * @public @memberof xrt_system_compositor
2555 */
2556XRT_NONNULL_ALL static inline xrt_result_t
2558 struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns)
2559{
2560 if (xsc->xmcc == NULL) {
2562 }
2563
2564 return xsc->xmcc->set_state(xsc, xc, visible, focused, timestamp_ns);
2565}
2566
2567/*!
2568 * @copydoc xrt_multi_compositor_control::set_z_order
2569 *
2570 * Helper for calling through the function pointer.
2571 *
2572 * If the system compositor @p xsc does not implement @ref xrt_multi_compositor_control,
2573 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2574 *
2575 * @public @memberof xrt_system_compositor
2576 */
2577XRT_NONNULL_ALL static inline xrt_result_t
2578xrt_syscomp_set_z_order(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t z_order)
2579{
2580 if (xsc->xmcc == NULL) {
2582 }
2583
2584 return xsc->xmcc->set_z_order(xsc, xc, z_order);
2585}
2586
2587
2588/*!
2589 * @copydoc xrt_multi_compositor_control::set_main_app_visibility
2590 *
2591 * Helper for calling through the function pointer.
2592 *
2593 * If the system compositor @p xsc does not implement @ref xrt_multi_compositor_control,
2594 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2595 *
2596 * @public @memberof xrt_system_compositor
2597 */
2598XRT_NONNULL_ALL static inline xrt_result_t
2600{
2601 if (xsc->xmcc == NULL) {
2603 }
2604
2605 return xsc->xmcc->set_main_app_visibility(xsc, xc, visible);
2606}
2607
2608/*!
2609 * @copydoc xrt_multi_compositor_control::notify_loss_pending
2610 *
2611 * Helper for calling through the function pointer.
2612 *
2613 * If the system compositor @p xsc does not implement @ref xrt_multi_compositor_control,
2614 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2615 *
2616 * @public @memberof xrt_system_compositor
2617 */
2618XRT_NONNULL_ALL static inline xrt_result_t
2619xrt_syscomp_notify_loss_pending(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t loss_time_ns)
2620{
2621 if (xsc->xmcc == NULL) {
2623 }
2624
2625 return xsc->xmcc->notify_loss_pending(xsc, xc, loss_time_ns);
2626}
2627
2628/*!
2629 * @copydoc xrt_multi_compositor_control::notify_lost
2630 *
2631 * Helper for calling through the function pointer.
2632 *
2633 * If the system compositor @p xsc does not implement @ref xrt_multi_compositor_control,
2634 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2635 *
2636 * @public @memberof xrt_system_compositor
2637 */
2638XRT_NONNULL_ALL static inline xrt_result_t
2640{
2641 if (xsc->xmcc == NULL) {
2643 }
2644
2645 return xsc->xmcc->notify_lost(xsc, xc);
2646}
2647
2648/*!
2649 * @copydoc xrt_multi_compositor_control::notify_display_refresh_changed
2650 *
2651 * Helper for calling through the function pointer.
2652 *
2653 * If the system compositor @p xsc does not implement @ref xrt_multi_composition_control,
2654 * this returns @ref XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED.
2655 *
2656 * @public @memberof xrt_system_compositor
2657 */
2658XRT_NONNULL_ALL static inline xrt_result_t
2660 struct xrt_compositor *xc,
2661 float from_display_refresh_rate_hz,
2662 float to_display_refresh_rate_hz)
2663{
2664 if (xsc->xmcc == NULL) {
2666 }
2667
2668 return xsc->xmcc->notify_display_refresh_changed(xsc, xc, from_display_refresh_rate_hz,
2669 to_display_refresh_rate_hz);
2670}
2671
2672/*!
2673 * @copydoc xrt_system_compositor::create_native_compositor
2674 *
2675 * Helper for calling through the function pointer.
2676 *
2677 * @public @memberof xrt_system_compositor
2678 */
2679XRT_NONNULL_ALL static inline xrt_result_t
2681 const struct xrt_session_info *xsi,
2682 struct xrt_session_event_sink *xses,
2683 struct xrt_compositor_native **out_xcn)
2684{
2685 return xsc->create_native_compositor(xsc, xsi, xses, out_xcn);
2686}
2687
2688/*!
2689 * @copydoc xrt_system_compositor::get_view_config
2690 *
2691 * Helper for calling through the function pointer.
2692 *
2693 * @public @memberof xrt_system_compositor
2694 */
2695XRT_NONNULL_ALL static inline xrt_result_t
2697 enum xrt_view_type view_type,
2698 struct xrt_view_config *out_view_config)
2699{
2700 return xsc->get_view_config(xsc, view_type, out_view_config);
2701}
2702
2703/*!
2704 * @copydoc xrt_system_compositor::destroy
2705 *
2706 * Helper for calling through the function pointer: does a null check and sets
2707 * xcn_ptr to null if freed.
2708 *
2709 * @public @memberof xrt_system_compositor
2710 */
2711XRT_NONNULL_ALL static inline void
2713{
2714 struct xrt_system_compositor *xsc = *xsc_ptr;
2715 if (xsc == NULL) {
2716 return;
2717 }
2718
2719 xsc->destroy(xsc);
2720 *xsc_ptr = NULL;
2721}
2722
2723
2724/*
2725 *
2726 * Image allocator.
2727 *
2728 */
2729
2730/*!
2731 * Allocator for system native images, in general you do not need to free the
2732 * images as they will be consumed by importing them to the graphics API.
2733 *
2734 * @see xrt_image_native
2735 */
2737{
2738 /*!
2739 * Allocate a set of images suitable to be used to back a swapchain
2740 * with the given create info properties (@p xsci).
2741 */
2742 xrt_result_t (*images_allocate)(struct xrt_image_native_allocator *xina,
2743 const struct xrt_swapchain_create_info *xsci,
2744 size_t image_count,
2745 struct xrt_image_native *out_images);
2746
2747 /*!
2748 * Free the given images.
2749 */
2750 xrt_result_t (*images_free)(struct xrt_image_native_allocator *xina,
2751 size_t image_count,
2752 struct xrt_image_native *images);
2753
2754 /*!
2755 * Destroy the image allocator.
2756 */
2757 void (*destroy)(struct xrt_image_native_allocator *xina);
2758};
2759
2760/*!
2761 * @copydoc xrt_image_native_allocator::xrt_images_allocate
2762 *
2763 * Helper for calling through the function pointer.
2764 *
2765 * @public @memberof xrt_image_native_allocate
2766 */
2767XRT_NONNULL_ALL static inline xrt_result_t
2768xrt_images_allocate(struct xrt_image_native_allocator *xina,
2769 const struct xrt_swapchain_create_info *xsci,
2770 size_t image_count,
2771 struct xrt_image_native *out_images)
2772{
2773 return xina->images_allocate(xina, xsci, image_count, out_images);
2774}
2775
2776/*!
2777 * @copydoc xrt_image_native_allocator::images_free
2778 *
2779 * Helper for calling through the function pointer.
2780 *
2781 * @public @memberof xrt_image_native_allocate
2782 */
2783XRT_NONNULL_ALL static inline xrt_result_t
2784xrt_images_free(struct xrt_image_native_allocator *xina, size_t image_count, struct xrt_image_native *images)
2785{
2786 return xina->images_free(xina, image_count, images);
2787}
2788
2789/*!
2790 * @copydoc xrt_image_native_allocator::destroy
2791 *
2792 * Helper for calling through the function pointer: does a null check and sets
2793 * xina_ptr to null if freed.
2794 *
2795 * @public @memberof xrt_image_native_allocator
2796 */
2797XRT_NONNULL_ALL static inline void
2799{
2800 struct xrt_image_native_allocator *xina = *xina_ptr;
2801 if (xina == NULL) {
2802 return;
2803 }
2804
2805 xina->destroy(xina);
2806 *xina_ptr = NULL;
2807}
2808
2809
2810/*!
2811 * @}
2812 */
2813
2814
2815#ifdef __cplusplus
2816}
2817#endif
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_commit_with_semaphore(struct xrt_compositor *xc, struct xrt_compositor_semaphore *xcsem, uint64_t value)
Commits all of the submitted layers, with a semaphore.
Definition xrt_compositor.h:1880
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_notify_display_refresh_changed(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, float from_display_refresh_rate_hz, float to_display_refresh_rate_hz)
Notify this client/session if the display refresh rate has been changed.
Definition xrt_compositor.h:2659
xrt_compare_op_fb
XrCompareOpFB.
Definition xrt_compositor.h:146
static XRT_NONNULL_ALL xrt_result_t xrt_comp_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
See xrBeginFrame.
Definition xrt_compositor.h:1691
static XRT_NONNULL_ALL xrt_result_t xrt_comp_wait_frame(struct xrt_compositor *xc, int64_t *out_frame_id, int64_t *out_predicted_display_time, int64_t *out_predicted_display_period)
See xrWaitFrame.
Definition xrt_compositor.h:1675
static XRT_NONNULL_ALL void xrt_comp_destroy(struct xrt_compositor **xc_ptr)
Teardown the compositor.
Definition xrt_compositor.h:1955
xrt_swapchain_usage_bits
Usage of the swapchain images.
Definition xrt_compositor.h:547
static XRT_NONNULL_ALL xrt_result_t xrt_comp_get_swapchain_create_properties(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_create_properties *xsccp)
For a given xrt_swapchain_create_info struct returns a filled out xrt_swapchain_create_properties.
Definition xrt_compositor.h:1475
static XRT_NONNULL_FIRST void xrt_compositor_semaphore_reference(struct xrt_compositor_semaphore **dst, struct xrt_compositor_semaphore *src)
Update the reference counts on compositor semaphore(s).
Definition xrt_compositor.h:858
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_set_main_app_visibility(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible)
Tell this client/session if the main application is visible or not.
Definition xrt_compositor.h:2599
static XRT_NONNULL_ALL xrt_result_t xrt_comp_get_display_refresh_rate(struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
Get the current display refresh rate.
Definition xrt_compositor.h:1895
xrt_blend_mode
Blend mode that the device supports, exact mirror of XrEnvironmentBlendMode.
Definition xrt_defines.h:112
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
Begins layer submission.
Definition xrt_compositor.h:1726
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_set_state(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns)
Sets the state of the compositor, generating any events to the client if the state is actually change...
Definition xrt_compositor.h:2557
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_notify_loss_pending(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t loss_time_ns)
Notify this client/session if the compositor is going to lose the ability of rendering.
Definition xrt_compositor.h:2619
static XRT_NONNULL_ALL xrt_result_t xrt_comp_set_performance_level(struct xrt_compositor *xc, enum xrt_perf_domain domain, enum xrt_perf_set_level level)
Set CPU/GPU performance level.
Definition xrt_compositor.h:1922
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_passthrough(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
Adds a passthrough layer for submission.
Definition xrt_compositor.h:1853
static XRT_NONNULL_ALL void xrt_syscomp_destroy(struct xrt_system_compositor **xsc_ptr)
Teardown the system compositor.
Definition xrt_compositor.h:2712
static XRT_NONNULL_FIRST xrt_result_t xrt_comp_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
Commits all of the submitted layers.
Definition xrt_compositor.h:1867
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_inc_image_use(struct xrt_swapchain *xsc, uint32_t index)
Increments the use counter of a swapchain image.
Definition xrt_compositor.h:704
static XRT_NONNULL_ALL xrt_result_t xrt_compositor_fence_wait(struct xrt_compositor_fence *xcf, uint64_t timeout)
Waits on the fence with the given timeout.
Definition xrt_compositor.h:792
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_cube(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a cube layer for submission.
Definition xrt_compositor.h:1788
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_cylinder(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a cylinder layer for submission.
Definition xrt_compositor.h:1804
static XRT_NONNULL_ALL xrt_result_t xrt_comp_request_display_refresh_rate(struct xrt_compositor *xc, float display_refresh_rate_hz)
Request system to change the display refresh rate to the requested value.
Definition xrt_compositor.h:1908
static XRT_NONNULL_ALL xrt_result_t xrt_comp_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
Explicitly discard a frame.
Definition xrt_compositor.h:1704
static XRT_NONNULL_ALL xrt_result_t xrt_comp_native_create_swapchain(struct xrt_compositor_native *xcn, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_native **out_xscn)
Create a native swapchain with a set of images.
Definition xrt_compositor.h:2295
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition xrt_limits.h:53
static XRT_NONNULL_ALL xrt_result_t xrt_comp_begin_session(struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
See xrBeginSession.
Definition xrt_compositor.h:1603
static XRT_NONNULL_ALL xrt_result_t xrt_comp_import_swapchain(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_image_native *native_images, uint32_t image_count, struct xrt_swapchain **out_xsc)
Create a swapchain from a set of native images.
Definition xrt_compositor.h:1510
static XRT_NONNULL_ALL xrt_result_t xrt_comp_mark_frame(struct xrt_compositor *xc, int64_t frame_id, enum xrt_compositor_frame_point point, int64_t when_ns)
This function and predict_frame function calls are a alternative to wait_frame.
Definition xrt_compositor.h:1662
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_set_z_order(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t z_order)
Set the rendering Z order for rendering, visible has higher priority then z_order but is still saved ...
Definition xrt_compositor.h:2578
static XRT_NONNULL_ALL xrt_result_t xrt_comp_create_swapchain(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
Create a swapchain with a set of images.
Definition xrt_compositor.h:1495
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_create_native_compositor(struct xrt_system_compositor *xsc, const struct xrt_session_info *xsi, struct xrt_session_event_sink *xses, struct xrt_compositor_native **out_xcn)
Create a new native compositor.
Definition xrt_compositor.h:2680
xrt_input_name
Every internal input source known to monado with a baked in type.
Definition xrt_defines.h:930
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_projection_depth(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Adds a projection layer for submission, has depth information.
Definition xrt_compositor.h:1755
#define XRT_MAX_SWAPCHAIN_CREATE_INFO_FORMAT_LIST_COUNT
Max formats in the swapchain creation info formats list, artificial limit.
Definition xrt_limits.h:73
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_acquire_image(struct xrt_swapchain *xsc, uint32_t *out_index)
Obtain the index of the next image to use, without blocking on being able to write to it.
Definition xrt_compositor.h:691
xrt_swapchain_create_flags
Special flags for creating swapchain images.
Definition xrt_compositor.h:529
static XRT_NONNULL_ALL xrt_result_t xrt_compositor_semaphore_wait(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout)
Does a CPU side wait on the semaphore to reach the given value.
Definition xrt_compositor.h:887
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_barrier_image(struct xrt_swapchain *xsc, enum xrt_barrier_direction direction, uint32_t index)
Do any barrier transitions to and from the application.
Definition xrt_compositor.h:743
static XRT_NONNULL_ALL xrt_result_t xrt_comp_predict_frame(struct xrt_compositor *xc, int64_t *out_frame_id, int64_t *out_wake_time_ns, int64_t *out_predicted_gpu_time_ns, int64_t *out_predicted_display_time_ns, int64_t *out_predicted_display_period_ns)
This function and mark_frame function calls are a alternative to wait_frame.
Definition xrt_compositor.h:1638
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
See xrReleaseSwapchainImage, state tracker needs to track index.
Definition xrt_compositor.h:756
enum xrt_result xrt_result_t
Result type used across Monado.
static XRT_NONNULL_ALL xrt_result_t xrt_comp_end_session(struct xrt_compositor *xc)
See xrEndSession, unlike the OpenXR one the state tracker is responsible to call discard frame before...
Definition xrt_compositor.h:1616
xrt_compositor_frame_point
Definition xrt_compositor.h:900
static void xrt_swapchain_native_reference(struct xrt_swapchain_native **dst, struct xrt_swapchain_native *src)
Update the reference counts on swapchain(s).
Definition xrt_compositor.h:2260
static XRT_NONNULL_ALL xrt_result_t xrt_comp_create_passthrough(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
Create a passthrough.
Definition xrt_compositor.h:1559
static XRT_NONNULL_ALL xrt_result_t xrt_comp_import_fence(struct xrt_compositor *xc, xrt_graphics_sync_handle_t handle, struct xrt_compositor_fence **out_xcf)
Create a compositor fence from a native sync handle.
Definition xrt_compositor.h:1527
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_equirect1(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a equirect1 layer for submission.
Definition xrt_compositor.h:1821
xrt_layer_composition_flags
Bit field for holding information about how a layer should be composited.
Definition xrt_compositor.h:93
xrt_thread_hint
Hints the XR runtime what type of task the thread is doing.
Definition xrt_compositor.h:1014
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_dec_image_use(struct xrt_swapchain *xsc, uint32_t index)
Decrements the use counter of a swapchain image.
Definition xrt_compositor.h:717
static void xrt_compositor_fence_destroy(struct xrt_compositor_fence **xcf_ptr)
Destroys the fence.
Definition xrt_compositor.h:806
xrt_reference_space_type
Type of a OpenXR mapped reference space, maps to the semantic spaces on the xrt_space_overseer struct...
Definition xrt_defines.h:625
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_get_view_config(struct xrt_system_compositor *xsc, enum xrt_view_type view_type, struct xrt_view_config *out_view_config)
Gets the view configuration for the specified view type.
Definition xrt_compositor.h:2696
xrt_layer_eye_visibility
Which view is the layer visible to?
Definition xrt_compositor.h:166
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_projection(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Adds a projection layer for submissions.
Definition xrt_compositor.h:1739
static XRT_NONNULL_ALL xrt_result_t xrt_comp_set_thread_hint(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id)
Set thread attributes according to thread type.
Definition xrt_compositor.h:1975
static XRT_NONNULL_ALL xrt_result_t xrt_swapchain_wait_image(struct xrt_swapchain *xsc, int64_t timeout_ns, uint32_t index)
Wait until image index is available for exclusive use, or until timeout_ns expires.
Definition xrt_compositor.h:730
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_equirect2(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a equirect2 layer for submission.
Definition xrt_compositor.h:1837
static XRT_NONNULL_ALL void xrt_images_destroy(struct xrt_image_native_allocator **xina_ptr)
Destroy the image allocator.
Definition xrt_compositor.h:2798
static XRT_NONNULL_FIRST void xrt_swapchain_reference(struct xrt_swapchain **dst, struct xrt_swapchain *src)
Update the reference counts on swapchain(s).
Definition xrt_compositor.h:662
static XRT_NONNULL_ALL xrt_result_t xrt_comp_create_passthrough_layer(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
Create a passthrough layer.
Definition xrt_compositor.h:1572
xrt_blend_factor
Blend factors.
Definition xrt_compositor.h:177
#define XRT_MAX_SUPPORTED_REFRESH_RATES
Max number of supported display refresh rates, artificial limit.
Definition xrt_limits.h:78
#define XRT_MAX_SWAPCHAIN_FORMATS
Max formats supported by a compositor, artificial limit.
Definition xrt_limits.h:58
static XRT_NONNULL_ALL xrt_result_t xrt_comp_layer_quad(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a quad layer for submission, the center of the quad is specified by the pose and extends outward...
Definition xrt_compositor.h:1772
static XRT_NONNULL_ALL void xrt_comp_native_destroy(struct xrt_compositor_native **xcn_ptr)
Teardown the compositor.
Definition xrt_compositor.h:2322
xrt_barrier_direction
The direction of a transition.
Definition xrt_compositor.h:562
static XRT_NONNULL_ALL xrt_result_t xrt_comp_get_reference_bounds_rect(struct xrt_compositor *xc, enum xrt_reference_space_type reference_space_type, struct xrt_vec2 *bounds)
Get the extents of the reference space's bounds rectangle.
Definition xrt_compositor.h:1935
static XRT_NONNULL_ALL xrt_result_t xrt_comp_create_semaphore(struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle, struct xrt_compositor_semaphore **out_xcsem)
Create a compositor semaphore, also returns a native handle of the semaphore which is owned by the xr...
Definition xrt_compositor.h:1542
static XRT_NONNULL_ALL xrt_result_t xrt_comp_destroy_passthrough(struct xrt_compositor *xc)
Destroy a passthrough.
Definition xrt_compositor.h:1585
xrt_layer_type
Layer type.
Definition xrt_compositor.h:78
static XRT_NONNULL_ALL xrt_result_t xrt_syscomp_notify_lost(struct xrt_system_compositor *xsc, struct xrt_compositor *xc)
Notify this client/session if the compositor lost the ability of rendering.
Definition xrt_compositor.h:2639
@ XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT
Our compositor just ignores this bit.
Definition xrt_compositor.h:531
@ XRT_SWAPCHAIN_CREATE_SAMPLE_AS_SRGB
Signals to the compositor to use the equivalent sRGB format of the UNORM swapchain.
Definition xrt_compositor.h:540
@ XRT_SWAPCHAIN_CREATE_STATIC_IMAGE
Signals that the allocator should only allocate one image.
Definition xrt_compositor.h:533
@ XRT_COMPOSITOR_FRAME_POINT_WOKE
The client woke up after waiting.
Definition xrt_compositor.h:901
@ XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SUPER_SAMPLING_BIT_FB
Quality super sampling, see XrCompositionLayerSettingsFlagsFB.
Definition xrt_compositor.h:113
@ XRT_LAYER_COMPOSITION_ADVANCED_BLENDING_BIT
This layer has advanced blending information, this bit supersedes the behavior of XRT_LAYER_COMPOSITI...
Definition xrt_compositor.h:127
@ XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SUPER_SAMPLING_BIT_FB
Normal super sampling, see XrCompositionLayerSettingsFlagsFB.
Definition xrt_compositor.h:110
@ XRT_LAYER_COMPOSITION_DEPTH_TEST
Depth testing is requested when composing this layer if this flag is set, see XrCompositionLayerDepth...
Definition xrt_compositor.h:133
@ XRT_LAYER_COMPOSITION_VIEW_SPACE_BIT
The layer is locked to the device and the pose should only be adjusted for the IPD.
Definition xrt_compositor.h:101
@ XRT_COMPOSITION_LAYER_PROCESSING_QUALITY_SHARPENING_BIT_FB
Quality sharpening, see XrCompositionLayerSettingsFlagsFB.
Definition xrt_compositor.h:119
@ XRT_COMPOSITION_LAYER_PROCESSING_NORMAL_SHARPENING_BIT_FB
Normal sharpening, see XrCompositionLayerSettingsFlagsFB.
Definition xrt_compositor.h:116
@ XRT_LAYER_COMPOSITION_INVERTED_ALPHA_BIT
This layer has inverted alpha, see XR_COMPOSITION_LAYER_INVERTED_ALPHA_BIT_EXT.
Definition xrt_compositor.h:139
@ XRT_LAYER_COMPOSITION_COLOR_BIAS_SCALE
If this flag is set the compositor should use the scale and bias from the xrt_layer_data struct.
Definition xrt_compositor.h:107
@ XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED
Multiple not supported on this layer level (IPC, compositor).
Definition xrt_results.h:108
@ XRT_SUCCESS
The operation succeeded.
Definition xrt_results.h:27
@ XRT_ERROR_NOT_IMPLEMENTED
The interface function called is not implemented by its interface.
Definition xrt_results.h:192
Definition m_space.cpp:87
Begin Session information not known until clients have created an xrt-instance such as which extensio...
Definition xrt_compositor.h:994
A 3 element HSV colour with floating point channels.
Definition xrt_defines.h:411
A 4 element colour with floating point channels.
Definition xrt_defines.h:423
Base class for a D3D11 client compositor.
Definition xrt_compositor.h:2130
Base class for a D3D12 client compositor.
Definition xrt_compositor.h:2178
Compositor fence used for synchronization.
Definition xrt_compositor.h:772
xrt_result_t(* wait)(struct xrt_compositor_fence *xcf, uint64_t timeout)
Waits on the fence with the given timeout.
Definition xrt_compositor.h:776
void(* destroy)(struct xrt_compositor_fence *xcf)
Destroys the fence.
Definition xrt_compositor.h:781
Base class for an OpenGL (ES) client compositor.
Definition xrt_compositor.h:2010
Capabilities and information about the compositor and device together.
Definition xrt_compositor.h:975
XRT_ALIGNAS(8) int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS]
Supported formats, never changes.
uint32_t format_count
Number of formats, never changes.
Definition xrt_compositor.h:977
Main compositor server interface.
Definition xrt_compositor.h:2274
struct xrt_compositor base
Base.
Definition xrt_compositor.h:2276
Compositor semaphore used for synchronization, needs to be as capable as a Vulkan pipeline semaphore.
Definition xrt_compositor.h:829
struct xrt_reference reference
Reference helper.
Definition xrt_compositor.h:833
void(* destroy)(struct xrt_compositor_semaphore *xcsem)
Destroys the semaphore.
Definition xrt_compositor.h:843
xrt_result_t(* wait)(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout_ns)
Does a CPU side wait on the semaphore to reach the given value.
Definition xrt_compositor.h:838
Base class for a Vulkan client compositor.
Definition xrt_compositor.h:2069
Common compositor client interface/base.
Definition xrt_compositor.h:1030
xrt_result_t(* layer_projection_depth)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Adds a projection layer for submission, has depth information.
Definition xrt_compositor.h:1286
void(* destroy)(struct xrt_compositor *xc)
Teardown the compositor.
Definition xrt_compositor.h:1452
xrt_result_t(* layer_commit)(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
Commits all of the submitted layers.
Definition xrt_compositor.h:1387
xrt_result_t(* create_swapchain)(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
Create a swapchain with a set of images.
Definition xrt_compositor.h:1055
xrt_result_t(* get_swapchain_create_properties)(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_create_properties *xsccp)
For a given xrt_swapchain_create_info struct returns a filled out xrt_swapchain_create_properties.
Definition xrt_compositor.h:1040
xrt_result_t(* set_thread_hint)(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id)
Set thread attributes according to thread type.
Definition xrt_compositor.h:1462
xrt_result_t(* layer_cylinder)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a cylinder layer for submission.
Definition xrt_compositor.h:1333
xrt_result_t(* end_session)(struct xrt_compositor *xc)
See xrEndSession, unlike the OpenXR one the state tracker is responsible to call discard frame before...
Definition xrt_compositor.h:1124
xrt_result_t(* discard_frame)(struct xrt_compositor *xc, int64_t frame_id)
Explicitly discard a frame.
Definition xrt_compositor.h:1230
xrt_result_t(* destroy_passthrough)(struct xrt_compositor *xc)
Destroy a passthrough.
Definition xrt_compositor.h:1108
xrt_result_t(* get_display_refresh_rate)(struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
Get the current display refresh rate.
Definition xrt_compositor.h:1416
xrt_result_t(* request_display_refresh_rate)(struct xrt_compositor *xc, float display_refresh_rate_hz)
Request system to change the display refresh rate to the requested value.
Definition xrt_compositor.h:1424
xrt_result_t(* begin_frame)(struct xrt_compositor *xc, int64_t frame_id)
See xrBeginFrame.
Definition xrt_compositor.h:1212
xrt_result_t(* layer_quad)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a quad layer for submission, the center of the quad is specified by the pose and extends outward...
Definition xrt_compositor.h:1303
xrt_result_t(* predict_frame)(struct xrt_compositor *xc, int64_t *out_frame_id, int64_t *out_wake_time_ns, int64_t *out_predicted_gpu_time_ns, int64_t *out_predicted_display_time_ns, int64_t *out_predicted_display_period_ns)
This function and mark_frame function calls are a alternative to wait_frame.
Definition xrt_compositor.h:1154
xrt_result_t(* layer_projection)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
Adds a projection layer for submissions.
Definition xrt_compositor.h:1264
xrt_result_t(* mark_frame)(struct xrt_compositor *xc, int64_t frame_id, enum xrt_compositor_frame_point point, int64_t when_ns)
This function and predict_frame function calls are a alternative to wait_frame.
Definition xrt_compositor.h:1173
xrt_result_t(* layer_equirect1)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a equirect1 layer for submission.
Definition xrt_compositor.h:1348
xrt_result_t(* import_swapchain)(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_image_native *native_images, uint32_t image_count, struct xrt_swapchain **out_xsc)
Create a swapchain from a set of native images.
Definition xrt_compositor.h:1066
xrt_result_t(* set_performance_level)(struct xrt_compositor *xc, enum xrt_perf_domain domain, enum xrt_perf_set_level level)
Set CPU/GPU performance level.
Definition xrt_compositor.h:1432
xrt_result_t(* wait_frame)(struct xrt_compositor *xc, int64_t *out_frame_id, int64_t *out_predicted_display_time, int64_t *out_predicted_display_period)
See xrWaitFrame.
Definition xrt_compositor.h:1197
xrt_result_t(* import_fence)(struct xrt_compositor *xc, xrt_graphics_sync_handle_t handle, struct xrt_compositor_fence **out_xcf)
Create a compositor fence from a native sync handle.
Definition xrt_compositor.h:1075
xrt_result_t(* layer_begin)(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
Begins layer submission.
Definition xrt_compositor.h:1248
xrt_result_t(* get_reference_bounds_rect)(struct xrt_compositor *xc, enum xrt_reference_space_type reference_space_type, struct xrt_vec2 *bounds)
Get the extents of the reference space's bounds rectangle.
Definition xrt_compositor.h:1439
xrt_result_t(* begin_session)(struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
See xrBeginSession.
Definition xrt_compositor.h:1117
xrt_result_t(* create_passthrough)(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
Create a passthrough.
Definition xrt_compositor.h:1097
xrt_result_t(* layer_equirect2)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a equirect2 layer for submission.
Definition xrt_compositor.h:1364
xrt_result_t(* create_semaphore)(struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle, struct xrt_compositor_semaphore **out_xcsem)
Create a compositor semaphore, also returns a native handle of the semaphore which is owned by the xr...
Definition xrt_compositor.h:1089
xrt_result_t(* layer_passthrough)(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
Adds a passthrough layer for submission.
Definition xrt_compositor.h:1378
xrt_result_t(* layer_cube)(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
Adds a cube layer for submission.
Definition xrt_compositor.h:1318
xrt_result_t(* create_passthrough_layer)(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
Create a passthrough layer.
Definition xrt_compositor.h:1103
xrt_result_t(* layer_commit_with_semaphore)(struct xrt_compositor *xc, struct xrt_compositor_semaphore *xcsem, uint64_t value)
Commits all of the submitted layers, with a semaphore.
Definition xrt_compositor.h:1398
Graphics usage requirements for D3D APIs.
Definition xrt_compositor.h:2141
A single HMD or input device.
Definition xrt_device.h:311
Describes a projection matrix fov.
Definition xrt_defines.h:512
Allocator for system native images, in general you do not need to free the images as they will be con...
Definition xrt_compositor.h:2737
void(* destroy)(struct xrt_image_native_allocator *xina)
Destroy the image allocator.
Definition xrt_compositor.h:2757
xrt_result_t(* images_allocate)(struct xrt_image_native_allocator *xina, const struct xrt_swapchain_create_info *xsci, size_t image_count, struct xrt_image_native *out_images)
Allocate a set of images suitable to be used to back a swapchain with the given create info propertie...
Definition xrt_compositor.h:2742
xrt_result_t(* images_free)(struct xrt_image_native_allocator *xina, size_t image_count, struct xrt_image_native *images)
Free the given images.
Definition xrt_compositor.h:2750
A single image of a swapchain based on native buffer handles.
Definition xrt_compositor.h:2200
bool use_dedicated_allocation
Is the image created with a dedicated allocation or not.
Definition xrt_compositor.h:2218
xrt_graphics_buffer_handle_t handle
Native buffer handle.
Definition xrt_compositor.h:2204
uint64_t size
Buffer size in memory.
Definition xrt_compositor.h:2213
bool is_dxgi_handle
Is the native buffer handle a DXGI handle?
Definition xrt_compositor.h:2229
Advanced blend provides explicit control over source and destination blend factors,...
Definition xrt_compositor.h:215
Chroma key parameters in HSV space.
Definition xrt_compositor.h:196
struct xrt_colour_hsv_f32 hsv_max
Maximum HSV bounds.
Definition xrt_compositor.h:200
float despill
Despill strength (0.0 = none, 1.0 = full)
Definition xrt_compositor.h:204
float curve
Power curve for alpha falloff (1.0 = linear)
Definition xrt_compositor.h:202
struct xrt_colour_hsv_f32 hsv_min
< Minimum HSV bounds
Definition xrt_compositor.h:198
All the pure data values associated with a cube layer.
Definition xrt_compositor.h:327
All the pure data values associated with a cylinder layer.
Definition xrt_compositor.h:342
All the pure data values associated with a composition layer.
Definition xrt_compositor.h:425
struct xrt_colour_rgba_f32 color_scale
Modulate the color sourced from the images.
Definition xrt_compositor.h:473
struct xrt_colour_rgba_f32 color_bias
Modulate the color sourced from the images.
Definition xrt_compositor.h:478
enum xrt_input_name name
Often XRT_INPUT_GENERIC_HEAD_POSE.
Definition xrt_compositor.h:434
enum xrt_layer_type type
Tag for compositor layer type.
Definition xrt_compositor.h:429
struct xrt_layer_depth_test_data depth_test
Depth test data.
Definition xrt_compositor.h:454
bool flip_y
Whether the main compositor should flip the direction of y when rendering.
Definition xrt_compositor.h:468
struct xrt_layer_advanced_blend_data advanced_blend
Advanced blend factors.
Definition xrt_compositor.h:483
XRT_ALIGNAS(8) int64_t timestamp
"Display no-earlier-than" timestamp for this layer.
All the pure data values associated with a depth information attached to a layer.
Definition xrt_compositor.h:273
Definition xrt_compositor.h:283
All the pure data values associated with a equirect1 layer.
Definition xrt_compositor.h:360
All the pure data values associated with a equirect2 layer.
Definition xrt_compositor.h:378
Per frame data for the layer submission calls, used in xrt_compositor::layer_begin.
Definition xrt_compositor.h:511
XRT_ALIGNAS(8) int64_t frame_id
alignas for 32 bit client support, see IPC Design and Implementation
All the pure data values associated with a passthrough layer.
Definition xrt_compositor.h:413
All the pure data values associated with a projection layer.
Definition xrt_compositor.h:259
All the pure data values associated with a projection layer with depth swapchain attached.
Definition xrt_compositor.h:296
All of the pure data values associated with a single view in a projection layer.
Definition xrt_compositor.h:245
All the pure data values associated with a quad layer.
Definition xrt_compositor.h:311
A limited unique id, it is only unique for the process it is in, so must not be used or synchronized ...
Definition xrt_defines.h:82
To transport LUIDs between different APIs.
Definition xrt_defines.h:63
Special functions to control multi session/clients.
Definition xrt_compositor.h:2424
xrt_result_t(* set_main_app_visibility)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible)
Tell this client/session if the main application is visible or not.
Definition xrt_compositor.h:2463
xrt_result_t(* notify_display_refresh_changed)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, float from_display_refresh_rate_hz, float to_display_refresh_rate_hz)
Notify this client/session if the display refresh rate has been changed.
Definition xrt_compositor.h:2484
xrt_result_t(* set_z_order)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t z_order)
Set the rendering Z order for rendering, visible has higher priority then z_order but is still saved ...
Definition xrt_compositor.h:2442
xrt_result_t(* set_state)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns)
Sets the state of the compositor, generating any events to the client if the state is actually change...
Definition xrt_compositor.h:2430
xrt_result_t(* notify_loss_pending)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, int64_t loss_time_ns)
Notify this client/session if the compositor is going to lose the ability of rendering.
Definition xrt_compositor.h:2472
xrt_result_t(* notify_lost)(struct xrt_system_compositor *xsc, struct xrt_compositor *xc)
Notify this client/session if the compositor lost the ability of rendering.
Definition xrt_compositor.h:2479
Normalized image rectangle, coordinates and size in 0 .
Definition xrt_defines.h:480
Passthrough creation info.
Definition xrt_compositor.h:931
Passthrough layer creation info.
Definition xrt_compositor.h:939
Definition xrt_compositor.h:402
Definition xrt_compositor.h:394
A pose composed of a position and orientation.
Definition xrt_defines.h:492
Image rectangle.
Definition xrt_defines.h:457
A base class for reference counted objects.
Definition xrt_defines.h:99
Used internally from producers of events to push events into session, some sinks might multiplex even...
Definition xrt_session.h:237
Session information, mostly overlay extension data.
Definition xrt_compositor.h:962
XRT_ALIGNAS(8) uint64_t flags
alignas for 32 bit client support, see IPC Design and Implementation
Specifies a sub-image in a layer.
Definition xrt_compositor.h:226
struct xrt_normalized_rect norm_rect
Normalized sub image coordinates and size.
Definition xrt_compositor.h:234
struct xrt_rect rect
The rectangle in the image to use.
Definition xrt_compositor.h:232
uint32_t image_index
Image index in the (implicit) swapchain.
Definition xrt_compositor.h:228
uint32_t array_index
Index in image array (for array textures)
Definition xrt_compositor.h:230
Swapchain creation info.
Definition xrt_compositor.h:908
Struct used to negotiate properties of a swapchain that is created outside of the compositor.
Definition xrt_compositor.h:950
enum xrt_swapchain_usage_bits extra_bits
New creation bits.
Definition xrt_compositor.h:955
uint32_t image_count
How many images the compositor want in the swapchain.
Definition xrt_compositor.h:952
Base class for a D3D11 client swapchain.
Definition xrt_compositor.h:2115
Base class for a D3D12 client swapchain.
Definition xrt_compositor.h:2163
Base class for an OpenGL (ES) client swapchain.
Definition xrt_compositor.h:1995
Base class for a swapchain that exposes a native buffer handle to be imported into a client API.
Definition xrt_compositor.h:2241
xrt_limited_unique_id_t limited_unique_id
Unique id for the swapchain, only unique for the current process, is not synchronized between service...
Definition xrt_compositor.h:2249
Base class for a Vulkan client swapchain.
Definition xrt_compositor.h:2054
Common swapchain interface/base.
Definition xrt_compositor.h:577
xrt_result_t(* wait_image)(struct xrt_swapchain *xsc, int64_t timeout_ns, uint32_t index)
Wait until image index is available for exclusive use, or until timeout_ns expires.
Definition xrt_compositor.h:633
xrt_result_t(* barrier_image)(struct xrt_swapchain *xsc, enum xrt_barrier_direction direction, uint32_t index)
Do any barrier transitions to and from the application.
Definition xrt_compositor.h:642
xrt_result_t(* dec_image_use)(struct xrt_swapchain *xsc, uint32_t index)
Decrements the use counter of a swapchain image.
Definition xrt_compositor.h:621
xrt_result_t(* release_image)(struct xrt_swapchain *xsc, uint32_t index)
See xrReleaseSwapchainImage, state tracker needs to track index.
Definition xrt_compositor.h:647
xrt_result_t(* acquire_image)(struct xrt_swapchain *xsc, uint32_t *out_index)
Obtain the index of the next image to use, without blocking on being able to write to it.
Definition xrt_compositor.h:609
struct xrt_reference reference
Reference helper.
Definition xrt_compositor.h:581
xrt_result_t(* inc_image_use)(struct xrt_swapchain *xsc, uint32_t index)
Increments the use counter of a swapchain image.
Definition xrt_compositor.h:614
void(* destroy)(struct xrt_swapchain *xsc)
dec_image_use must have been called as often as inc_image_use.
Definition xrt_compositor.h:593
uint32_t image_count
Number of images.
Definition xrt_compositor.h:588
Capabilities and information about the system compositor (and its wrapped native compositor,...
Definition xrt_compositor.h:2377
uint8_t supported_blend_mode_count
Number of meaningful elements in xrt_system_compositor_info::supported_blend_modes.
Definition xrt_compositor.h:2394
bool client_d3d_deviceLUID_valid
Whether client_d3d_deviceLUID is valid.
Definition xrt_compositor.h:2409
xrt_uuid_t client_vk_deviceUUID
The vk device suggested for Vulkan clients, never changes.
Definition xrt_compositor.h:2403
xrt_luid_t client_d3d_deviceLUID
The (Windows) LUID for the GPU device suggested for D3D clients, never changes.
Definition xrt_compositor.h:2406
bool supports_fov_mutable
Whether submitting projection layers of a differing FOV from the target FOV is supported.
Definition xrt_compositor.h:2412
xrt_uuid_t compositor_vk_deviceUUID
The vk device as used by the compositor, never changes.
Definition xrt_compositor.h:2400
uint32_t max_layers
Maximum number of composition layers supported, never changes.
Definition xrt_compositor.h:2382
The system compositor handles composition for a system.
Definition xrt_compositor.h:2502
void(* destroy)(struct xrt_system_compositor *xsc)
Teardown the system compositor.
Definition xrt_compositor.h:2543
struct xrt_multi_compositor_control * xmcc
An optional aspect/additional interface, providing multi-app control.
Definition xrt_compositor.h:2507
xrt_result_t(* create_native_compositor)(struct xrt_system_compositor *xsc, const struct xrt_session_info *xsi, struct xrt_session_event_sink *xses, struct xrt_compositor_native **out_xcn)
Create a new native compositor.
Definition xrt_compositor.h:2526
xrt_result_t(* get_view_config)(struct xrt_system_compositor *xsc, enum xrt_view_type view_type, struct xrt_view_config *out_view_config)
Gets the view configuration for the specified view type.
Definition xrt_compositor.h:2534
To transport UUIDs between different APIs.
Definition xrt_defines.h:39
A 2 element vector with single floats.
Definition xrt_defines.h:268
Holds information about the view configuration properties for a view in a system compositor.
Definition xrt_compositor.h:2337
Definition xrt_compositor.h:2354
enum xrt_view_type view_type
Which view type this is for, mono, stereo, quad_with_inset, etc...
Definition xrt_compositor.h:2356
uint32_t view_count
Must match the view_type, in the future view_types might have variable views.
Definition xrt_compositor.h:2359
static void set_state(struct u_autoexpgain *aeg, enum u_aeg_action action)
Defines the AEG state machine transitions.
Definition u_autoexpgain.c:163
Auto detect OS and certain features.
Common defines and enums for XRT.
xrt_passthrough_purpose_flags
Specify the kind of passthrough behavior the layer provides.
Definition xrt_defines.h:151
xrt_perf_domain
Domain type.
Definition xrt_defines.h:2428
xrt_view_type
View type to be rendered to by the compositor.
Definition xrt_defines.h:2417
xrt_passthrough_create_flags
Special flags for creating passthrough.
Definition xrt_defines.h:125
xrt_perf_set_level
Performance level.
Definition xrt_defines.h:2444
Native handle types.
int xrt_graphics_buffer_handle_t
The type underlying buffers shared between compositor clients and the main compositor.
Definition xrt_handles.h:252
int xrt_graphics_sync_handle_t
The type underlying synchronization primitives (semaphores, etc) shared between compositor clients an...
Definition xrt_handles.h:354
Header for limits of the XRT interfaces.
A minimal way to include Windows.h.