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