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