Monado OpenXR Runtime
comp_vk_client.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 Vulkan client side glue to compositor header.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
8 * @author Korcan Hussein <korcan.hussein@collabora.com>
9 * @ingroup comp_client
10 */
11
12#pragma once
13
14#include "vk/vk_helpers.h"
15#include "vk/vk_cmd_pool.h"
16#include "xrt/xrt_gfx_vk.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
23/*
24 *
25 * Structs
26 *
27 */
28
30
31/*!
32 * Wraps the real compositor swapchain providing a Vulkan based interface.
33 *
34 * Almost a one to one mapping to a OpenXR swapchain.
35 *
36 * @ingroup comp_client
37 * @implements xrt_swapchain_vk
38 */
40{
42
43 //! Owning reference to the backing native swapchain.
45
46 //! Non-owning reference to our parent compositor.
48
49 // Memory
50 VkDeviceMemory mems[XRT_MAX_SWAPCHAIN_IMAGES];
51
52 // Prerecorded swapchain image ownership/layout transition barriers
53 VkCommandBuffer acquire[XRT_MAX_SWAPCHAIN_IMAGES];
54 VkCommandBuffer release[XRT_MAX_SWAPCHAIN_IMAGES];
55};
56
57/*!
58 * @class client_vk_compositor
59 *
60 * Wraps the real compositor providing a Vulkan based interface.
61 *
62 * @ingroup comp_client
63 * @implements xrt_compositor_vk
64 */
66{
68
69 //! Owning reference to the backing native compositor
71
72 struct
73 {
74 VkSemaphore semaphore;
75 struct xrt_compositor_semaphore *xcsem;
76 uint64_t value;
77 } sync;
78
79 struct vk_bundle vk;
80
81 struct vk_cmd_pool pool;
82
83 bool renderdoc_enabled;
84 VkCommandBuffer dcb;
85};
86
87
88/*
89 *
90 * Functions and helpers.
91 *
92 */
93
94
95/*!
96 * Create a new client_vk_compositor.
97 *
98 * Takes ownership of provided xcn.
99 *
100 * @public @memberof client_vk_compositor
101 * @see xrt_compositor_native
102 */
105 VkInstance instance,
106 PFN_vkGetInstanceProcAddr getProc,
107 VkPhysicalDevice physicalDevice,
108 VkDevice device,
109 bool external_fence_fd_enabled,
110 bool external_semaphore_fd_enabled,
111 bool timeline_semaphore_enabled,
112 bool image_format_list_enabled,
113 bool debug_utils_enabled,
114 bool renderdoc_enabled,
115 uint32_t queueFamilyIndex,
116 uint32_t queueIndex);
117
118
119#ifdef __cplusplus
120}
121#endif
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition: xrt_limits.h:34
Wraps the real compositor providing a Vulkan based interface.
Definition: comp_vk_client.h:66
struct xrt_compositor_native * xcn
Owning reference to the backing native compositor.
Definition: comp_vk_client.h:70
struct client_vk_compositor * client_vk_compositor_create(struct xrt_compositor_native *xcn, VkInstance instance, PFN_vkGetInstanceProcAddr getProc, VkPhysicalDevice physicalDevice, VkDevice device, bool external_fence_fd_enabled, bool external_semaphore_fd_enabled, bool timeline_semaphore_enabled, bool image_format_list_enabled, bool debug_utils_enabled, bool renderdoc_enabled, uint32_t queueFamilyIndex, uint32_t queueIndex)
Create a new client_vk_compositor.
Definition: comp_vk_client.c:812
Wraps the real compositor swapchain providing a Vulkan based interface.
Definition: comp_vk_client.h:40
struct client_vk_compositor * c
Non-owning reference to our parent compositor.
Definition: comp_vk_client.h:47
struct xrt_swapchain_native * xscn
Owning reference to the backing native swapchain.
Definition: comp_vk_client.h:44
Definition: u_worker.c:49
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition: vk_helpers.h:50
Small helper to manage lock around a command pool.
Definition: vk_cmd_pool.h:33
Main compositor server interface.
Definition: xrt_compositor.h:2224
Compositor semaphore used for synchronization, needs to be as capable as a Vulkan pipeline semaphore.
Definition: xrt_compositor.h:788
Base class for a Vulkan client compositor.
Definition: xrt_compositor.h:2019
struct xrt_compositor base
Base.
Definition: xrt_compositor.h:2021
Base class for a swapchain that exposes a native buffer handle to be imported into a client API.
Definition: xrt_compositor.h:2191
Base class for a Vulkan client swapchain.
Definition: xrt_compositor.h:2004
struct xrt_swapchain base
Base.
Definition: xrt_compositor.h:2006
Command pool helpers.
Common Vulkan code header.
Header defining an XRT graphics provider.