The open source OpenXR runtime
at prediction-2 121 lines 2.7 kB view raw
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 29struct client_vk_compositor; 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 */ 39struct client_vk_swapchain 40{ 41 struct xrt_swapchain_vk base; 42 43 //! Owning reference to the backing native swapchain. 44 struct xrt_swapchain_native *xscn; 45 46 //! Non-owning reference to our parent compositor. 47 struct client_vk_compositor *c; 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 */ 65struct client_vk_compositor 66{ 67 struct xrt_compositor_vk base; 68 69 //! Owning reference to the backing native compositor 70 struct xrt_compositor_native *xcn; 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 */ 103struct client_vk_compositor * 104client_vk_compositor_create(struct xrt_compositor_native *xcn, 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