Monado OpenXR Runtime
Loading...
Searching...
No Matches
comp_vulkan.h
Go to the documentation of this file.
1// Copyright 2019-2021, Collabora, Ltd.
2// Copyright 2025-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Vulkan code for compositors.
7 * @author Jakob Bornecrantz <jakob@collabora.com>
8 * @ingroup comp_util
9 */
10
11#pragma once
12
13#include "xrt/xrt_compositor.h"
14
15#include "util/u_logging.h"
17
18#include "vk/vk_helpers.h"
20
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26
27/*!
28 * Arguments to Vulkan bundle initialisation, all args needs setting.
29 */
31{
32 //! Vulkan version that is required.
34
35 //! Function to get all Vulkan functions from.
36 PFN_vkGetInstanceProcAddr get_instance_proc_address;
37
38 //! Extensions that the instance is created with.
40
41 //! Extensions that the instance is created with.
43
44 //! Extensions that the device is created with.
46
47 //! Extensions that the device is created with.
49
50 //! Logging level to be set on the @ref vk_bundle.
52
53 //! Should we look for a queue with no graphics, only compute.
55
56 //! Should we try to enable timeline semaphores if available
58
59 //! Vulkan physical device to be selected, -1 for auto.
61
62 //! When true, select the physical device whose UUID matches @ref selected_gpu_uuid.
64
65 //! Vulkan physical device UUID to select when @ref lookup_with_uuid is true.
67
68 //! Vulkan physical device index for clients to use, -1 for auto.
70};
71
72/*!
73 * Extra results from Vulkan bundle initialisation.
74 */
76{
77 //! Vulkan physical device selected.
79
80 //! Vulkan physical device index for clients to use.
82
83 //! Selected Vulkan device UUID.
85
86 //! Selected Vulkan device UUID to suggest to clients.
88
89 //! The (Windows) LUID for the GPU device suggested for clients.
91
92 //! Whether @ref client_gpu_deviceLUID is valid (probably only on Windows)
94};
95
96/*!
97 * Fully initialises a @ref vk_bundle, by creating instance, device and queue.
98 *
99 * @ingroup comp_util
100 */
101bool
103 const struct comp_vulkan_arguments *vk_args,
104 struct comp_vulkan_results *vk_res);
105
106
107/*
108 *
109 * Format checking.
110 *
111 */
112
113/*!
114 * Struct with supported format, these are not only check for optimal flags
115 * but also the ability to import and export them.
116 */
118{
119#define FIELD(IDENT) bool has_##IDENT;
120 VK_CSCI_FORMATS(FIELD, FIELD, FIELD, FIELD)
121#undef FIELD
122
123#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER)
124 //! Is VK_FORMAT_R8G8B8A8_SRGB emulated with VK_FORMAT_R8G8B8A8_UNORM?
125 bool emulated_R8G8B8A8_SRGB;
126#endif
127};
128
129/*!
130 * Fills in a @ref comp_vulkan_formats struct with the supported formats, use
131 * @ref comp_vulkan_formats_copy_to_info to fill a compositor info struct.
132 *
133 * @ingroup comp_util
134 */
135void
136comp_vulkan_formats_check(struct vk_bundle *vk, struct comp_vulkan_formats *formats);
137
138/*!
139 * Fills in a @ref xrt_compositor_info struct with the formats listed from a
140 * @ref comp_vulkan_formats. This and @ref comp_vulkan_formats_check are split
141 * to allow the compositor to allow/deny certain formats.
142 *
143 * @ingroup comp_util
144 */
145void
147
148/*!
149 * Logs the formats at info level.
150 *
151 * @ingroup comp_util
152 */
153void
154comp_vulkan_formats_log(enum u_logging_level log_level, const struct comp_vulkan_formats *formats);
155
156
157#ifdef __cplusplus
158}
159#endif
u_logging_level
Logging level enum.
Definition u_logging.h:45
#define VK_CSCI_FORMATS(THING_COLOR, THING_DS, THING_D, THING_S)
Helper for all of the supported formats to check support for.
Definition vk_compositor_flags.h:85
void comp_vulkan_formats_copy_to_info(const struct comp_vulkan_formats *formats, struct xrt_compositor_info *info)
Fills in a xrt_compositor_info struct with the formats listed from a comp_vulkan_formats.
Definition comp_vulkan.c:481
bool comp_vulkan_init_bundle(struct vk_bundle *vk, const struct comp_vulkan_arguments *vk_args, struct comp_vulkan_results *vk_res)
Fully initialises a vk_bundle, by creating instance, device and queue.
Definition comp_vulkan.c:416
void comp_vulkan_formats_check(struct vk_bundle *vk, struct comp_vulkan_formats *formats)
Fills in a comp_vulkan_formats struct with the supported formats, use comp_vulkan_formats_copy_to_inf...
Definition comp_vulkan.c:452
void comp_vulkan_formats_log(enum u_logging_level log_level, const struct comp_vulkan_formats *formats)
Logs the formats at info level.
Definition comp_vulkan.c:499
Arguments to Vulkan bundle initialisation, all args needs setting.
Definition comp_vulkan.h:31
struct u_extension_list * optional_device_extensions
Extensions that the device is created with.
Definition comp_vulkan.h:48
bool timeline_semaphore
Should we try to enable timeline semaphores if available.
Definition comp_vulkan.h:57
int client_gpu_index
Vulkan physical device index for clients to use, -1 for auto.
Definition comp_vulkan.h:69
bool only_compute_queue
Should we look for a queue with no graphics, only compute.
Definition comp_vulkan.h:54
uint32_t required_instance_version
Vulkan version that is required.
Definition comp_vulkan.h:33
enum u_logging_level log_level
Logging level to be set on the vk_bundle.
Definition comp_vulkan.h:51
struct u_extension_list * optional_instance_extensions
Extensions that the instance is created with.
Definition comp_vulkan.h:42
struct u_extension_list * required_instance_extensions
Extensions that the instance is created with.
Definition comp_vulkan.h:39
bool lookup_with_uuid
When true, select the physical device whose UUID matches selected_gpu_uuid.
Definition comp_vulkan.h:63
PFN_vkGetInstanceProcAddr get_instance_proc_address
Function to get all Vulkan functions from.
Definition comp_vulkan.h:36
struct u_extension_list * required_device_extensions
Extensions that the device is created with.
Definition comp_vulkan.h:45
xrt_uuid_t selected_gpu_uuid
Vulkan physical device UUID to select when lookup_with_uuid is true.
Definition comp_vulkan.h:66
int selected_gpu_index
Vulkan physical device to be selected, -1 for auto.
Definition comp_vulkan.h:60
Struct with supported format, these are not only check for optimal flags but also the ability to impo...
Definition comp_vulkan.h:118
Extra results from Vulkan bundle initialisation.
Definition comp_vulkan.h:76
xrt_uuid_t client_gpu_deviceUUID
Selected Vulkan device UUID to suggest to clients.
Definition comp_vulkan.h:87
xrt_uuid_t selected_gpu_deviceUUID
Selected Vulkan device UUID.
Definition comp_vulkan.h:84
bool client_gpu_deviceLUID_valid
Whether client_gpu_deviceLUID is valid (probably only on Windows)
Definition comp_vulkan.h:93
xrt_luid_t client_gpu_deviceLUID
The (Windows) LUID for the GPU device suggested for clients.
Definition comp_vulkan.h:90
int selected_gpu_index
Vulkan physical device selected.
Definition comp_vulkan.h:78
int client_gpu_index
Vulkan physical device index for clients to use.
Definition comp_vulkan.h:81
Definition u_extension_list.cpp:33
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition vk_helpers.h:81
Capabilities and information about the compositor and device together.
Definition xrt_compositor.h:991
To transport LUIDs between different APIs.
Definition xrt_defines.h:63
To transport UUIDs between different APIs.
Definition xrt_defines.h:39
A collection of strings, like a list of extensions to enable.
Basic logging functionality.
Flags helpers for compositor swapchain images.
Common Vulkan code header.
Header declaring XRT graphics interfaces.