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