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