Monado OpenXR Runtime
vk_helpers.h
Go to the documentation of this file.
1// Copyright 2019-2024, Collabora, Ltd.
2// Copyright 2024-2025, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Common Vulkan code header.
7 *
8 * Note that some sections of this are generated
9 * by `scripts/generate_vk_helpers.py` - lists of functions
10 * and of optional extensions to check for. In those,
11 * please update the script and run it, instead of editing
12 * directly in this file. The generated parts are delimited
13 * by special comments.
14 *
15 * @author Jakob Bornecrantz <jakob@collabora.com>
16 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
17 * @author Moshi Turner <moshiturner@protonmail.com>
18 * @author Korcan Hussein <korcan.hussein@collabora.com>
19 * @ingroup aux_vk
20 */
21
22#pragma once
23
24#include "xrt/xrt_compiler.h"
25#include "xrt/xrt_compositor.h"
27#include "xrt/xrt_handles.h"
28#include "util/u_logging.h"
29#include "util/u_string_list.h"
30#include "os/os_threading.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define VK_BUNDLE_MAX_QUEUES 2
37
38/*
39 *
40 * Structs
41 *
42 */
43
45{
46 //! The queue family index
47 uint32_t family_index;
48 //! The queue (instance) index
49 uint32_t index;
50};
51
52#define VK_NULL_QUEUE_PAIR \
53 XRT_C11_COMPOUND(struct vk_queue_pair) \
54 { \
55 .family_index = VK_QUEUE_FAMILY_IGNORED, .index = (uint32_t)-1, \
56 }
57
59{
60 //! The Vulkan queue handle
61 VkQueue queue;
62 //! The queue family index
63 uint32_t family_index;
64 //! The queue (instance) index
65 uint32_t index;
66 //! The queue mutex - @see vk_queue_lock, vk_queue_unlock
68};
69
70/*!
71 * A bundle of Vulkan functions and objects, used by both @ref comp and @ref
72 * comp_client. Note that they both have different instances of the object, and
73 * thus different VkInstance, etc.
74 *
75 * @ingroup aux_vk
76 */
78{
79 enum u_logging_level log_level;
80
81 VkInstance instance;
82 uint32_t version;
83 VkPhysicalDevice physical_device;
84 int physical_device_index;
85 VkDevice device;
86
87 /*!
88 * @brief queues - a free list of **unique** queues
89 *
90 * One per uniquely identifiable vk queue (family x instance index),
91 * duplicate entries must not be stored.
92 *
93 * Should not be used directly, @see main_queue, encode_queue
94 */
95 struct vk_bundle_queue queues[VK_BUNDLE_MAX_QUEUES];
96
97 struct vk_bundle_queue *main_queue;
98#if defined(VK_KHR_video_encode_queue)
99 struct vk_bundle_queue *encode_queue;
100#endif
101
102 struct
103 {
104#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_WIN32_HANDLE)
105 bool color_image_import_opaque_win32;
106 bool color_image_export_opaque_win32;
107 bool depth_image_import_opaque_win32;
108 bool depth_image_export_opaque_win32;
109
110 bool color_image_import_d3d11;
111 bool color_image_export_d3d11;
112 bool depth_image_import_d3d11;
113 bool depth_image_export_d3d11;
114
115#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
116 bool color_image_import_opaque_fd;
117 bool color_image_export_opaque_fd;
118 bool depth_image_import_opaque_fd;
119 bool depth_image_export_opaque_fd;
120
121#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER)
122 bool color_image_import_opaque_fd;
123 bool color_image_export_opaque_fd;
124 bool depth_image_import_opaque_fd;
125 bool depth_image_export_opaque_fd;
126
127 bool color_image_import_ahardwarebuffer;
128 bool color_image_export_ahardwarebuffer;
129 bool depth_image_import_ahardwarebuffer;
130 bool depth_image_export_ahardwarebuffer;
131#endif
132
133#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
134 bool fence_sync_fd;
135 bool fence_opaque_fd;
136
137 bool binary_semaphore_sync_fd;
138 bool binary_semaphore_opaque_fd;
139
140 bool timeline_semaphore_sync_fd;
141 bool timeline_semaphore_opaque_fd;
142#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
143 bool fence_win32_handle;
144
145 bool binary_semaphore_d3d12_fence;
146 bool binary_semaphore_win32_handle;
147
148 bool timeline_semaphore_d3d12_fence;
149 bool timeline_semaphore_win32_handle;
150#else
151#error "Need port for fence sync handles checkers"
152#endif
153 } external;
154
155 // beginning of GENERATED instance extension code - do not modify - used by scripts
156 bool has_KHR_external_memory_capabilities;
157 bool has_KHR_portability_enumeration;
158 bool has_EXT_display_surface_counter;
159 bool has_EXT_swapchain_colorspace;
160 bool has_EXT_debug_utils;
161 // end of GENERATED instance extension code - do not modify - used by scripts
162
163 // beginning of GENERATED device extension code - do not modify - used by scripts
164 bool has_KHR_8bit_storage;
165 bool has_KHR_external_fence_fd;
166 bool has_KHR_external_memory;
167 bool has_KHR_external_semaphore_fd;
168 bool has_KHR_format_feature_flags2;
169 bool has_KHR_global_priority;
170 bool has_KHR_image_format_list;
171 bool has_KHR_maintenance1;
172 bool has_KHR_maintenance2;
173 bool has_KHR_maintenance3;
174 bool has_KHR_maintenance4;
175 bool has_KHR_present_wait;
176 bool has_KHR_portability_subset;
177 bool has_KHR_synchronization2;
178 bool has_KHR_timeline_semaphore;
179 bool has_KHR_video_maintenance1;
180 bool has_EXT_calibrated_timestamps;
181 bool has_EXT_display_control;
182 bool has_EXT_external_memory_dma_buf;
183 bool has_EXT_external_memory_host;
184 bool has_EXT_global_priority;
185 bool has_EXT_image_drm_format_modifier;
186 bool has_EXT_metal_objects;
187 bool has_EXT_robustness2;
188 bool has_ANDROID_external_format_resolve;
189 bool has_GOOGLE_display_timing;
190 // end of GENERATED device extension code - do not modify - used by scripts
191
192 struct
193 {
194 //! Are timestamps available for compute and graphics queues?
196
197 //! Nanoseconds per gpu tick.
199
200 //! Valid bits in the queue selected.
202
203 //! Were timeline semaphore requested, available, and enabled?
205
206 //! Was synchronization2 requested, available, and enabled?
208
209 //! Was KHR_present_wait requested, available, and enabled?
211
212 //! Was KHR_video_maintenance1 requested, available, and enabled?
214 } features;
215
216 struct
217 {
218 //! Maximum number of sampler objects, as created by vkCreateSampler, which can simultaneously exist on
220
221 //! Maximum number of descriptor sets that can be simultaneously used by a pipeline.
223
224 //! Maximum number of samplers that can be included in a pipeline layout.
226
227 //! Maximum number of sampled images that can be included in a pipeline layout.
229
230 //! Maximum number of samplers that can be accessible to a single shader stage in a pipeline layout.
232
233 //! Per stage limit on sampled images (includes combined).
235
236 //! Per stage limit on storage images.
238 } limits;
239
240 //! Is the GPU a tegra device.
242
243
244 VkDebugReportCallbackEXT debug_report_cb;
245
246 VkPhysicalDeviceMemoryProperties device_memory_props;
247
248 // Loader functions
249 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
250 PFN_vkCreateInstance vkCreateInstance;
251 PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
252
253 // beginning of GENERATED instance loader code - do not modify - used by scripts
254 PFN_vkDestroyInstance vkDestroyInstance;
255 PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
256 PFN_vkCreateDevice vkCreateDevice;
257 PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
258
259 PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
260 PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
261
262 PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
263 PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
264 PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2;
265 PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2;
266 PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
267 PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
268 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
269 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
270 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
271 PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
272 PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
273 PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2;
274 PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2;
275 PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
276 PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR;
277 PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR;
278 PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
279 PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
280
281#if defined(VK_EXT_calibrated_timestamps)
282 PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT;
283
284#endif // defined(VK_EXT_calibrated_timestamps)
285
286#if defined(VK_USE_PLATFORM_DISPLAY_KHR)
287 PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
288 PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
289 PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
290 PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
291 PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
292 PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT;
293
294#endif // defined(VK_USE_PLATFORM_DISPLAY_KHR)
295
296#if defined(VK_USE_PLATFORM_XCB_KHR)
297 PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
298
299#endif // defined(VK_USE_PLATFORM_XCB_KHR)
300
301#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
302 PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
303
304#endif // defined(VK_USE_PLATFORM_WAYLAND_KHR)
305
306#if defined(VK_USE_PLATFORM_WAYLAND_KHR) && defined(VK_EXT_acquire_drm_display)
307 PFN_vkAcquireDrmDisplayEXT vkAcquireDrmDisplayEXT;
308 PFN_vkGetDrmDisplayEXT vkGetDrmDisplayEXT;
309
310#endif // defined(VK_USE_PLATFORM_WAYLAND_KHR) && defined(VK_EXT_acquire_drm_display)
311
312#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT)
313 PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT;
314 PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT;
315
316#endif // defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT)
317
318#if defined(VK_USE_PLATFORM_ANDROID_KHR)
319 PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
320
321#endif // defined(VK_USE_PLATFORM_ANDROID_KHR)
322
323#if defined(VK_USE_PLATFORM_WIN32_KHR)
324 PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
325
326#endif // defined(VK_USE_PLATFORM_WIN32_KHR)
327
328#if defined(VK_USE_PLATFORM_METAL_EXT)
329 PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
330
331#endif // defined(VK_USE_PLATFORM_METAL_EXT)
332
333#if defined(VK_EXT_display_surface_counter)
334 PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT;
335
336#endif // defined(VK_EXT_display_surface_counter)
337
338#if defined(VK_EXT_debug_utils)
339 PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
340 PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT;
341 PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
342#endif // defined(VK_EXT_debug_utils)
343
344 // end of GENERATED instance loader code - do not modify - used by scripts
345
346 // beginning of GENERATED device loader code - do not modify - used by scripts
347 PFN_vkDestroyDevice vkDestroyDevice;
348 PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
349 PFN_vkAllocateMemory vkAllocateMemory;
350 PFN_vkFreeMemory vkFreeMemory;
351 PFN_vkMapMemory vkMapMemory;
352 PFN_vkUnmapMemory vkUnmapMemory;
353
354 PFN_vkCreateBuffer vkCreateBuffer;
355 PFN_vkDestroyBuffer vkDestroyBuffer;
356 PFN_vkBindBufferMemory vkBindBufferMemory;
357
358 PFN_vkCreateImage vkCreateImage;
359 PFN_vkDestroyImage vkDestroyImage;
360 PFN_vkBindImageMemory vkBindImageMemory;
361
362 PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
363 PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
364 PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
365 PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2;
366 PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
367
368 PFN_vkCreateImageView vkCreateImageView;
369 PFN_vkDestroyImageView vkDestroyImageView;
370
371 PFN_vkCreateSampler vkCreateSampler;
372 PFN_vkDestroySampler vkDestroySampler;
373
374 PFN_vkCreateShaderModule vkCreateShaderModule;
375 PFN_vkDestroyShaderModule vkDestroyShaderModule;
376
377 PFN_vkCreateQueryPool vkCreateQueryPool;
378 PFN_vkDestroyQueryPool vkDestroyQueryPool;
379 PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
380
381 PFN_vkCreateCommandPool vkCreateCommandPool;
382 PFN_vkDestroyCommandPool vkDestroyCommandPool;
383 PFN_vkResetCommandPool vkResetCommandPool;
384
385 PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
386 PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
387 PFN_vkCmdBeginQuery vkCmdBeginQuery;
388 PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
389 PFN_vkCmdEndQuery vkCmdEndQuery;
390 PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
391 PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
392 PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
393 PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
394 PFN_vkCmdSetScissor vkCmdSetScissor;
395 PFN_vkCmdSetViewport vkCmdSetViewport;
396 PFN_vkCmdClearColorImage vkCmdClearColorImage;
397 PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
398 PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
399 PFN_vkCmdBindPipeline vkCmdBindPipeline;
400 PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
401 PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
402 PFN_vkCmdDraw vkCmdDraw;
403 PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
404 PFN_vkCmdDispatch vkCmdDispatch;
405 PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
406 PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
407 PFN_vkCmdCopyImage vkCmdCopyImage;
408 PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
409 PFN_vkCmdBlitImage vkCmdBlitImage;
410 PFN_vkCmdPushConstants vkCmdPushConstants;
411 PFN_vkEndCommandBuffer vkEndCommandBuffer;
412 PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
413
414 PFN_vkCreateRenderPass vkCreateRenderPass;
415 PFN_vkDestroyRenderPass vkDestroyRenderPass;
416
417 PFN_vkCreateFramebuffer vkCreateFramebuffer;
418 PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
419
420 PFN_vkCreatePipelineCache vkCreatePipelineCache;
421 PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
422
423 PFN_vkResetDescriptorPool vkResetDescriptorPool;
424 PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
425 PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
426
427 PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
428 PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
429
430 PFN_vkCreateComputePipelines vkCreateComputePipelines;
431 PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
432 PFN_vkDestroyPipeline vkDestroyPipeline;
433
434 PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
435 PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
436
437 PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
438 PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
439 PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
440
441 PFN_vkGetDeviceQueue vkGetDeviceQueue;
442 PFN_vkQueueSubmit vkQueueSubmit;
443 PFN_vkQueueWaitIdle vkQueueWaitIdle;
444
445 PFN_vkCreateSemaphore vkCreateSemaphore;
446#if defined(VK_KHR_timeline_semaphore)
447 PFN_vkSignalSemaphoreKHR vkSignalSemaphore;
448 PFN_vkWaitSemaphoresKHR vkWaitSemaphores;
449 PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValue;
450#endif // defined(VK_KHR_timeline_semaphore)
451
452 PFN_vkDestroySemaphore vkDestroySemaphore;
453
454 PFN_vkCreateFence vkCreateFence;
455 PFN_vkWaitForFences vkWaitForFences;
456 PFN_vkGetFenceStatus vkGetFenceStatus;
457 PFN_vkDestroyFence vkDestroyFence;
458 PFN_vkResetFences vkResetFences;
459
460 PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
461 PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
462 PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
463 PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
464 PFN_vkQueuePresentKHR vkQueuePresentKHR;
465
466#if defined(VK_USE_PLATFORM_WIN32_KHR)
467 PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR;
468 PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR;
469 PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR;
470 PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR;
471 PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR;
472
473#endif // defined(VK_USE_PLATFORM_WIN32_KHR)
474
475#if !defined(VK_USE_PLATFORM_WIN32_KHR)
476 PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR;
477 PFN_vkGetFenceFdKHR vkGetFenceFdKHR;
478 PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
479 PFN_vkImportFenceFdKHR vkImportFenceFdKHR;
480 PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
481
482#endif // !defined(VK_USE_PLATFORM_WIN32_KHR)
483
484#if defined(VK_USE_PLATFORM_METAL_EXT)
485 PFN_vkExportMetalObjectsEXT vkExportMetalObjectsEXT;
486
487#endif // defined(VK_USE_PLATFORM_METAL_EXT)
488
489#if defined(VK_USE_PLATFORM_ANDROID_KHR)
490 PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
491 PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
492
493#endif // defined(VK_USE_PLATFORM_ANDROID_KHR)
494
495#if defined(VK_EXT_external_memory_host)
496 PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
497
498#endif // defined(VK_EXT_external_memory_host)
499
500#if defined(VK_EXT_calibrated_timestamps)
501 PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT;
502
503#endif // defined(VK_EXT_calibrated_timestamps)
504
505 PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE;
506
507#if defined(VK_EXT_display_control)
508 PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT;
509 PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT;
510 PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT;
511
512#endif // defined(VK_EXT_display_control)
513
514#if defined(VK_EXT_image_drm_format_modifier)
515 PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT;
516
517#endif // defined(VK_EXT_image_drm_format_modifier)
518
519#if defined(VK_EXT_debug_utils)
520 PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT;
521 PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT;
522 PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT;
523 PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT;
524 PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT;
525 PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT;
526 PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT;
527 PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT;
528
529#endif // defined(VK_EXT_debug_utils)
530
531#if defined(VK_KHR_present_wait)
532 PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
533#endif // defined(VK_KHR_present_wait)
534
535 // end of GENERATED device loader code - do not modify - used by scripts
536};
537
539{
540 VkBuffer handle;
541 VkDeviceMemory memory;
542 uint32_t size;
543 void *data;
544};
545
546
547/*
548 *
549 * Helper defines.
550 *
551 */
552
553/*!
554 * This define will print if `RET` is not `VK_SUCCESS`, printing out that the
555 * @p FUNC_STR string has failed. The implicit argument @p vk will be used for
556 * the @ref vk_print_result call.
557 *
558 * Use this when you need to do special things after an error,
559 * but still want to pirnt the pretty message about the failure.
560 *
561 * @param RET The @p VkResult to check.
562 * @param FUNC_STR String literal with the function name, used for logging.
563 *
564 * @ingroup aux_vk
565 *
566 * @see VK_CHK_AND_RET
567 * @see VK_CHK_WITH_RET
568 * @see VK_CHK_WITH_GOTO
569 */
570#define VK_CHK_ONLY_PRINT(RET, FUNC_STR) \
571 do { \
572 VkResult _ret = RET; \
573 if (_ret != VK_SUCCESS) { \
574 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
575 } \
576 } while (false)
577
578/*!
579 * This define will error if `RET` is not `VK_SUCCESS`, printing out that the
580 * @p FUNC_STR string has failed, then returns @p RET. The implicit argument
581 * @p vk will be used for the @ref vk_print_result call.
582 *
583 * Use this macro when your function returns a `VkResult`.
584 *
585 * @param RET The @p VkResult to check.
586 * @param FUNC_STR String literal with the function name, used for logging.
587 *
588 * @ingroup aux_vk
589 *
590 * @see VK_CHK_ONLY_PRINT
591 * @see VK_CHK_WITH_RET
592 * @see VK_CHK_WITH_GOTO
593 */
594#define VK_CHK_AND_RET(RET, FUNC_STR) \
595 do { \
596 VkResult _ret = RET; \
597 if (_ret != VK_SUCCESS) { \
598 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
599 return _ret; \
600 } \
601 } while (false)
602
603/*!
604 * This define will error if @p RET is not @p VK_SUCCESS, printing out that the
605 * @p FUNC_STR string has failed, then returns @p TO_RET. The implicit argument
606 * @p vk will be used for the @ref vk_print_result call.
607 *
608 * Use this macro when your function doesn't return a `VkResult`.
609 *
610 * @param RET The @p VkResult to check.
611 * @param FUNC_STR String literal with the function name, used for logging.
612 * @param TO_RET Value to return, upon error
613 *
614 * @ingroup aux_vk
615 *
616 * @see VK_CHK_ONLY_PRINT
617 * @see VK_CHK_AND_RET
618 * @see VK_CHK_WITH_GOTO
619 */
620#define VK_CHK_WITH_RET(RET, FUNC_STR, TO_RET) \
621 do { \
622 VkResult _ret = RET; \
623 if (_ret != VK_SUCCESS) { \
624 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
625 return TO_RET; \
626 } \
627 } while (false)
628
629/*!
630 * This define will error if @p RET is not @p VK_SUCCESS, printing out that the
631 * @p FUNC_STR string has failed, then goto @p GOTO. The implicit argument @p vk
632 * will be used for the @ref vk_print_result call.
633 *
634 * Use this macro when your function needs to `goto` some cleanup code and
635 * return from there.
636 *
637 * @param RET The @p VkResult to check.
638 * @param FUNC_STR String literal with the function name, used for logging.
639 * @param GOTO Label to jump to, upon error
640 *
641 * @ingroup aux_vk
642 *
643 * @see VK_CHK_ONLY_PRINT
644 * @see VK_CHK_AND_RET
645 * @see VK_CHK_WITH_RET
646 */
647#define VK_CHK_WITH_GOTO(RET, FUNC_STR, GOTO) \
648 do { \
649 VkResult _ret = RET; \
650 if (_ret != VK_SUCCESS) { \
651 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
652 goto GOTO; \
653 } \
654 } while (false)
655
656//! For xrt_result_t, see @ref VK_CHK_AND_RET.
657#define XVK_CHK_AND_RET(...) U_LOG_CHK_AND_RET(vk->log_level, __VA_ARGS__)
658//! For xrt_result_t, see @ref VK_CHK_WITH_GOTO.
659#define XVK_CHK_WITH_GOTO(...) U_LOG_CHK_WITH_GOTO(vk->log_level, __VA_ARGS__)
660//! For xrt_result_t, see @ref VK_CHK_WITH_RET.
661#define XVK_CHK_WITH_RET(...) U_LOG_CHK_WITH_RET(vk->log_level, __VA_ARGS__)
662//! For xrt_result_t, see @ref VK_CHK_ONLY_PRINT.
663#define XVK_CHK_ONLY_PRINT(...) U_LOG_CHK_ONLY_PRINT(vk->log_level, __VA_ARGS__)
664//! For xrt_result_t, see @ref VK_CHK_ALWAYS_RET.
665#define XVK_CHK_ALWAYS_RET(...) U_LOG_CHK_ALWAYS_RET(vk->log_level, __VA_ARGS__)
666
667static inline void
668vk_append_to_pnext_chain(VkBaseInStructure *head, VkBaseInStructure *new_struct)
669{
670 assert(new_struct->pNext == NULL);
671 // Insert ourselves between head and its previous pNext
672 new_struct->pNext = head->pNext;
673 head->pNext = new_struct;
674}
675
676/*
677 *
678 * String helper functions.
679 *
680 */
681
682XRT_CHECK_RESULT const char *
683vk_result_string(VkResult code);
684
685XRT_CHECK_RESULT const char *
686vk_object_type_string(VkObjectType type);
687
688XRT_CHECK_RESULT const char *
689vk_physical_device_type_string(VkPhysicalDeviceType device_type);
690
691XRT_CHECK_RESULT const char *
692vk_format_string(VkFormat code);
693
694XRT_CHECK_RESULT const char *
695vk_sharing_mode_string(VkSharingMode code);
696
697XRT_CHECK_RESULT const char *
698vk_present_mode_string(VkPresentModeKHR code);
699
700XRT_CHECK_RESULT const char *
701vk_color_space_string(VkColorSpaceKHR code);
702
703XRT_CHECK_RESULT const char *
704vk_power_state_string(VkDisplayPowerStateEXT code);
705
706
707/*
708 *
709 * Flag bits string functions.
710 *
711 */
712
713/*!
714 * Returns the format feature flag if one valid bit is set,
715 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
716 */
717XRT_CHECK_RESULT const char *
718vk_format_feature_flag_string(VkFormatFeatureFlagBits bits, bool null_on_unknown);
719
720/*!
721 * Returns the image usage flag if one valid bit is set,
722 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
723 */
724XRT_CHECK_RESULT const char *
725vk_image_usage_flag_string(VkImageUsageFlagBits bits, bool null_on_unknown);
726
727/*!
728 * Returns the composite alpha flag if one valid bit is set,
729 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
730 */
731XRT_CHECK_RESULT const char *
732vk_composite_alpha_flag_string(VkCompositeAlphaFlagBitsKHR bits, bool null_on_unknown);
733
734/*!
735 * Returns the surface transform flag if one valid bit is set,
736 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
737 */
738XRT_CHECK_RESULT const char *
739vk_surface_transform_flag_string(VkSurfaceTransformFlagBitsKHR bits, bool null_on_unknown);
740
741#ifdef VK_KHR_display
742/*!
743 * Returns the display plane alpha flag if one valid bit is set,
744 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
745 */
746XRT_CHECK_RESULT const char *
747vk_display_plane_alpha_flag_string(VkDisplayPlaneAlphaFlagBitsKHR bits, bool null_on_unknown);
748#endif
749
750/*!
751 * Returns xrt swapchain_usage flag if one valid bit is set,
752 * if multiple bits are set, will return 'MULTIPLE BIT SET'.
753 */
754XRT_CHECK_RESULT const char *
755xrt_swapchain_usage_flag_string(enum xrt_swapchain_usage_bits bits, bool null_on_unknown);
756
757
758/*
759 *
760 * Function and helpers.
761 *
762 */
763
764#define VK_TRACE(d, ...) U_LOG_IFL_T(d->log_level, __VA_ARGS__)
765#define VK_DEBUG(d, ...) U_LOG_IFL_D(d->log_level, __VA_ARGS__)
766#define VK_INFO(d, ...) U_LOG_IFL_I(d->log_level, __VA_ARGS__)
767#define VK_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__)
768#define VK_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__)
769
770
771/*
772 *
773 * Debug helper functions, in the vk_debug.c file.
774 *
775 */
776
777#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
778
779/*!
780 * Uses VK_EXT_debug_utils to set a name for an object, for easier debugging.
781 *
782 * @ingroup aux_vk
783 */
784void
785vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name);
786
787/*!
788 * Small helper for @ref vk_name_object that makes use of pre-process to avoid
789 * writing out long type names.
790 *
791 * @ingroup aux_vk
792 */
793#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) \
794 do { \
795 if ((VK)->has_EXT_debug_utils) { \
796 XRT_MAYBE_UNUSED TYPE _thing = (TYPE)(OBJ); \
797 vk_name_object(VK, VK_OBJECT_TYPE_##SUFFIX, (uint64_t)OBJ, NAME); \
798 } \
799 } while (false)
800
801
802#else
803
804#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ)
805
806#endif
807
808/*!
809 * Some combinations of Vulkan implementation and types are broken, we still
810 * want type safety so we have this define. Examples of broken combinations:
811 *
812 * 1. Both Mesa and the Vulkan loader didn't support setting names on the
813 * VkInstance, loader got support in 1.3.261 and Mesa hasn't as of writing.
814 * 2. For Mesa drivers we can not name VkSurfaceKHR objects on some systems as
815 * it causes memory corruption, asserts, crashes or functions failing. This
816 * is as of writing broken on the 23.2.1 release, fixed in main and scheduled
817 * for the 23.2.2 release.
818 * 3. Mesa RADV leaks the name strings for VkDescriptorSet objects for pools
819 * that we use the reset function.
820 *
821 * @ingroup aux_vk
822 */
823#define VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ) \
824 do { \
825 XRT_MAYBE_UNUSED TYPE _thing = (TYPE)(OBJ); \
826 } while (false)
827
828
829// clang-format off
830// VK_DEFINE_HANDLE types are always pointers
831#define VK_NAME_INSTANCE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkInstance, (uintptr_t)OBJ)
832#define VK_NAME_PHYSICAL_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPhysicalDevice, PHYSICAL_DEVICE, (uintptr_t)OBJ, NAME)
833#define VK_NAME_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDevice, DEVICE, (uintptr_t)OBJ, NAME)
834#define VK_NAME_QUEUE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueue, QUEUE, (uintptr_t)OBJ, NAME)
835#define VK_NAME_COMMAND_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandBuffer, COMMAND_BUFFER, (uintptr_t)OBJ, NAME)
836// VK_DEFINE_NON_DISPATCHABLE_HANDLE types are pointers in 64-bits and uint64_t in 32-bits
837#define VK_NAME_SEMAPHORE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSemaphore, SEMAPHORE, OBJ, NAME)
838#define VK_NAME_FENCE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFence, FENCE, OBJ, NAME)
839#define VK_NAME_DEVICE_MEMORY(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDeviceMemory, DEVICE_MEMORY, OBJ, NAME)
840#define VK_NAME_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBuffer, BUFFER, OBJ, NAME)
841#define VK_NAME_IMAGE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImage, IMAGE, OBJ, NAME)
842#define VK_NAME_EVENT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkEvent, EVENT, OBJ, NAME)
843#define VK_NAME_QUERY_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueryPool, QUERY_POOL, OBJ, NAME)
844#define VK_NAME_BUFFER_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBufferView, BUFFER_VIEW, OBJ, NAME)
845#define VK_NAME_IMAGE_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImageView, IMAGE_VIEW, OBJ, NAME)
846#define VK_NAME_SHADER_MODULE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkShaderModule, SHADER_MODULE, OBJ, NAME)
847#define VK_NAME_PIPELINE_CACHE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineCache, PIPELINE_CACHE, OBJ, NAME)
848#define VK_NAME_PIPELINE_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineLayout, PIPELINE_LAYOUT, OBJ, NAME)
849#define VK_NAME_RENDER_PASS(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkRenderPass, RENDER_PASS, OBJ, NAME)
850#define VK_NAME_PIPELINE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipeline, PIPELINE, OBJ, NAME)
851#define VK_NAME_DESCRIPTOR_SET_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorSetLayout, DESCRIPTOR_SET_LAYOUT, OBJ, NAME)
852#define VK_NAME_SAMPLER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSampler, SAMPLER, OBJ, NAME)
853#define VK_NAME_DESCRIPTOR_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorPool, DESCRIPTOR_POOL, OBJ, NAME)
854#define VK_NAME_DESCRIPTOR_SET(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkDescriptorSet, OBJ)
855#define VK_NAME_FRAMEBUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFramebuffer, FRAMEBUFFER, OBJ, NAME)
856#define VK_NAME_COMMAND_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandPool, COMMAND_POOL, OBJ, NAME)
857
858#define VK_NAME_SURFACE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkSurfaceKHR, OBJ)
859#define VK_NAME_SWAPCHAIN(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSwapchainKHR, SWAPCHAIN_KHR, OBJ, NAME)
860// clang-format on
861
862
863/*
864 *
865 * Printing helpers, in the vk_print.c file.
866 *
867 */
868
869/*!
870 * Print the result of a function, info level if ret == `VK_SUCCESS` and error
871 * level otherwise. Also prints file and line.
872 *
873 * @ingroup aux_vk
874 */
875void
877 struct vk_bundle *vk, const char *file, int line, const char *calling_func, VkResult ret, const char *called_func);
878
879/*!
880 * Print device information to the logger at the given logging level,
881 * if the vk_bundle has that level enabled.
882 *
883 * @ingroup aux_vk
884 */
885void
887 enum u_logging_level log_level,
888 const VkPhysicalDeviceProperties *pdp,
889 uint32_t gpu_index,
890 const char *title);
891
892/*!
893 * Print device information about the device that bundle manages at the given
894 * logging level if the vk_bundle has that level enabled.
895 *
896 * @ingroup aux_vk
897 */
898void
899vk_print_opened_device_info(struct vk_bundle *vk, enum u_logging_level log_level);
900
901/*!
902 * Print device features to the logger at the given logging level, if the
903 * vk_bundle has that level enabled.
904 */
905void
906vk_print_features_info(struct vk_bundle *vk, enum u_logging_level log_level);
907
908/*!
909 * Print external handle features to the logger at the given logging level,
910 * if the vk_bundle has that level enabled.
911 */
912void
914
915/*!
916 * Print a @p VkSwapchainCreateInfoKHR, used to log during creation.
917 */
918void
919vk_print_swapchain_create_info(struct vk_bundle *vk, VkSwapchainCreateInfoKHR *i, enum u_logging_level log_level);
920
921#ifdef VK_KHR_display
922/*!
923 * Print a @p VkDisplaySurfaceCreateInfoKHR, used to log during creation.
924 */
925void
926vk_print_display_surface_create_info(struct vk_bundle *vk,
927 VkDisplaySurfaceCreateInfoKHR *i,
928 enum u_logging_level log_level);
929#endif
930
931/*!
932 * Print queue info to the logger at the given logging level,
933 * if the vk_bundle has that level enabled.
934 */
935void
936vk_print_queues_info(const struct vk_bundle *vk, enum u_logging_level log_level);
937
938
939/*
940 *
941 * Enumeration helpers, in the vk_enumerate.c file.
942 *
943 */
944
945/*!
946 * Return the @p VkExtensionProperties of the given @p layer_name, NULL means
947 * the "base" driver instance.
948 *
949 * @ingroup aux_vk
950 */
951VkResult
953 const char *layer_name,
954 uint32_t *out_prop_count,
955 VkExtensionProperties **out_props);
956
957/*!
958 * Enumerate the physical devices of the @p VkInstance that has been opened on
959 * the given @ref vk_bundle.
960 *
961 * @ingroup aux_vk
962 */
963VkResult
965 uint32_t *out_physical_device_count,
966 VkPhysicalDevice **out_physical_devices);
967
968/*!
969 * Enumerate the extension properties of the given @p VkPhysicalDevice for the
970 * named @p layer_name, NULL means the "base" driver physical device.
971 *
972 * @ingroup aux_vk
973 */
974VkResult
976 VkPhysicalDevice physical_device,
977 const char *layer_name,
978 uint32_t *out_prop_count,
979 VkExtensionProperties **out_props);
980
981#if defined(VK_KHR_surface) || defined(XRT_DOXYGEN)
982/*!
983 * Enumerate the surface formats of the given @p VkSurfaceKHR,
984 * returns a list of @p VkSurfaceFormatKHR, not @p VkFormat.
985 *
986 * @ingroup aux_vk
987 */
988VkResult
990 VkSurfaceKHR surface,
991 uint32_t *out_format_count,
992 VkSurfaceFormatKHR **out_formats);
993
994/*!
995 * Enumerate the present modes of the given @p VkSurfaceKHR.
996 *
997 * @ingroup aux_vk
998 */
999VkResult
1001 VkSurfaceKHR surface,
1002 uint32_t *out_present_mode_count,
1003 VkPresentModeKHR **out_present_modes);
1004#endif
1005
1006#if defined(VK_KHR_swapchain) || defined(XRT_DOXYGEN)
1007/*!
1008 * Enumerate the images of the given @p VkSwapchainKHR.
1009 *
1010 * @ingroup aux_vk
1011 */
1012VkResult
1014 VkSwapchainKHR swapchain,
1015 uint32_t *out_image_count,
1016 VkImage **out_images);
1017#endif
1018
1019#if defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(XRT_DOXYGEN)
1020/*!
1021 * Enumerate the display properties of the given @p VkPhysicalDevice.
1022 *
1023 * @ingroup aux_vk
1024 */
1025VkResult
1027 VkPhysicalDevice physical_device,
1028 uint32_t *out_prop_count,
1029 VkDisplayPropertiesKHR **out_props);
1030
1031/*!
1032 * Enumerate the display plane properties of the given @p VkPhysicalDevice.
1033 *
1034 * @ingroup aux_vk
1035 */
1036VkResult
1038 VkPhysicalDevice physical_device,
1039 uint32_t *out_prop_count,
1040 VkDisplayPlanePropertiesKHR **out_props);
1041
1042/*!
1043 * Enumerate the mode properties of the given @p VkDisplayKHR, which belongs
1044 * to the given @p VkPhysicalDevice.
1045 *
1046 * @ingroup aux_vk
1047 */
1048VkResult
1050 VkPhysicalDevice physical_device,
1051 VkDisplayKHR display,
1052 uint32_t *out_prop_count,
1053 VkDisplayModePropertiesKHR **out_props);
1054#endif
1055
1056
1057/*
1058 *
1059 * Struct init functions, in the vk_function_loaders.c file.
1060 *
1061 */
1062
1063/*!
1064 * Can be done on a completely bare bundle.
1065 *
1066 * @ingroup aux_vk
1067 */
1068VkResult
1069vk_get_loader_functions(struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g);
1070
1071/*!
1072 * Requires a instance to have been created and set on the bundle.
1073 *
1074 * @ingroup aux_vk
1075 */
1076VkResult
1078
1079/*!
1080 * Requires a device to have been created and set on the bundle.
1081 *
1082 * @ingroup aux_vk
1083 */
1084VkResult
1086
1087
1088/*
1089 *
1090 * Bundle init functions, in the vk_bundle_init.c file.
1091 *
1092 */
1093
1094/*!
1095 * Check if the required instance extensions are supported, if not print error
1096 * message with all extensions missing, returns VK_ERROR_EXTENSION_NOT_PRESENT
1097 * if not all extensions are supported.
1098 *
1099 * @ingroup aux_vk
1100 */
1101VkResult
1102vk_check_required_instance_extensions(struct vk_bundle *vk, struct u_string_list *required_instance_ext_list);
1103
1104/*!
1105 * Only requires @ref vk_get_loader_functions to have been called.
1106 *
1107 * @ingroup aux_vk
1108 */
1109struct u_string_list *
1111 struct u_string_list *required_instance_ext_list,
1112 struct u_string_list *optional_instance_ext_list);
1113
1114/*!
1115 * Fills in has_* in vk_bundle given a string of prefiltered instance extensions
1116 */
1117void
1118vk_fill_in_has_instance_extensions(struct vk_bundle *vk, struct u_string_list *ext_list);
1119
1120/*!
1121 * Setup the physical device, this is called by vk_create_device but has uses
1122 * for outside of that.
1123 *
1124 * @ingroup aux_vk
1125 */
1126VkResult
1127vk_select_physical_device(struct vk_bundle *vk, int forced_index);
1128
1129/*!
1130 * Used to enable device features as a argument @ref vk_create_device.
1131 *
1132 * @ingroup aux_vk
1133 */
1135{
1136 bool shader_image_gather_extended;
1137 bool shader_storage_image_write_without_format;
1138 bool null_descriptor;
1139 bool timeline_semaphore;
1140 bool synchronization_2;
1141 bool ext_fmt_resolve;
1142 bool storage_buffer_8bit_access;
1143 bool present_wait;
1144 bool video_maintenance_1;
1145};
1146
1147/*!
1148 * Creates a VkDevice and initialises the VkQueue.
1149 *
1150 * The @p vk_bundle must have been zero initialized, have the instance functions
1151 * loaded and a valid instance.
1152 *
1153 * @ingroup aux_vk
1154 */
1155XRT_CHECK_RESULT VkResult
1156vk_create_device(struct vk_bundle *vk,
1157 int forced_index,
1158 bool only_compute,
1159 VkQueueGlobalPriorityEXT global_priority,
1160 struct u_string_list *required_device_ext_list,
1161 struct u_string_list *optional_device_ext_list,
1162 const struct vk_device_features *optional_device_features);
1163
1164/*!
1165 * @brief Initialize mutexes in the @ref vk_bundle.
1166 *
1167 * Not required for all uses, but a precondition for some.
1168 *
1169 * @ingroup aux_vk
1170 */
1171VkResult
1172vk_init_mutex(struct vk_bundle *vk);
1173
1174/*!
1175 * @brief De-initialize mutexes in the @ref vk_bundle.
1176 *
1177 * @ingroup aux_vk
1178 */
1179VkResult
1180vk_deinit_mutex(struct vk_bundle *vk);
1181
1182static inline void
1183vk_queue_lock(struct vk_bundle_queue *q)
1184{
1185 assert(q != NULL);
1186 os_mutex_lock(&q->mutex);
1187}
1188
1189static inline int
1190vk_queue_trylock(struct vk_bundle_queue *q)
1191{
1192 assert(q != NULL);
1193 return os_mutex_trylock(&q->mutex);
1194}
1195
1196static inline void
1197vk_queue_unlock(struct vk_bundle_queue *q)
1198{
1199 assert(q != NULL);
1201}
1202
1203/*!
1204 * Initialize a bundle with objects given to us by client code,
1205 * used by @ref client_vk_compositor in @ref comp_client.
1206 *
1207 * @ingroup aux_vk
1208 */
1209XRT_CHECK_RESULT VkResult
1210vk_init_from_given(struct vk_bundle *vk,
1211 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
1212 VkInstance instance,
1213 VkPhysicalDevice physical_device,
1214 VkDevice device,
1215 uint32_t queue_family_index,
1216 uint32_t queue_index,
1217 bool external_fence_fd_enabled,
1218 bool external_semaphore_fd_enabled,
1219 bool timeline_semaphore_enabled,
1220 bool image_format_list_enabled,
1221 bool debug_utils_enabled,
1222 enum u_logging_level log_level);
1223
1224
1225/*
1226 *
1227 * Other functions.
1228 *
1229 */
1230
1231/*!
1232 * @ingroup aux_vk
1233 */
1234bool
1235vk_get_memory_type(struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFlags memory_props, uint32_t *out_type_id);
1236
1237/*!
1238 * Allocate memory for an image and bind it to that image.
1239 *
1240 * Handles the following steps:
1241 *
1242 * - calling vkGetImageMemoryRequirements
1243 * - comparing against the max_size
1244 * - getting the memory type (as dictated by the VkMemoryRequirements and
1245 * VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
1246 * - calling vkAllocateMemory
1247 * - calling vkBindImageMemory
1248 * - calling vkDestroyMemory in case of an error.
1249 *
1250 * If this fails, it cleans up the VkDeviceMemory.
1251 *
1252 * @param vk Vulkan bundle
1253 * @param image The VkImage to allocate for and bind.
1254 * @param requirements Memory requirements used for finding the memory type and the size.
1255 * @param pNext_for_allocate (Optional) a pointer to use in the pNext chain of
1256 * VkMemoryAllocateInfo.
1257 * @param caller_name Used for error printing, this function is called from
1258 * various sources and takes next chains that could influence the result
1259 * of various calls inside of it. Since it's up to this function to print
1260 * any errors it will add the caller name to error messages.
1261 * @param out_mem Output parameter: will be set to the allocated memory if
1262 * everything succeeds. Not modified if there is an error.
1263 *
1264 * If this fails, you may want to destroy your VkImage as well, since this
1265 * routine is usually used in combination with vkCreateImage.
1266 *
1267 * @ingroup aux_vk
1268 */
1269XRT_CHECK_RESULT VkResult
1271 VkImage image,
1272 const VkMemoryRequirements *requirements,
1273 const void *pNext_for_allocate,
1274 const char *caller_name,
1275 VkDeviceMemory *out_mem);
1276
1277/*!
1278 *
1279 * @brief Creates a Vulkan device memory and image from a native graphics buffer handle.
1280 *
1281 * In case of error, ownership is never transferred and the caller should close the handle themselves.
1282 *
1283 * In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the @p image_native
1284 * handle may have transferred, a reference may have been added, or the Vulkan objects may rely on the caller to keep
1285 * the native handle alive until the Vulkan objects are destroyed. Which option applies depends on the particular native
1286 * handle type used.
1287 *
1288 * See the corresponding specification texts:
1289 *
1290 * - Windows:
1291 * https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkImportMemoryWin32HandleInfoKHR
1292 * - Linux: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkImportMemoryFdInfoKHR
1293 * - Android:
1294 * https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkImportAndroidHardwareBufferInfoANDROID
1295 *
1296 * @ingroup aux_vk
1297 */
1298XRT_CHECK_RESULT VkResult
1300 const struct xrt_swapchain_create_info *info,
1301 struct xrt_image_native *image_native,
1302 VkImage *out_image,
1303 VkDeviceMemory *out_mem);
1304
1305/*!
1306 * Given a DeviceMemory handle created to be exportable, outputs the native buffer type (FD on desktop Linux)
1307 * equivalent.
1308 *
1309 * Caller assumes ownership of handle which should be unreferenced with @ref u_graphics_buffer_unref when no longer
1310 * needed.
1311 *
1312 * @param vk Vulkan bundle
1313 * @param device_memory The memory to get the handle of
1314 * @param[out] out_handle A pointer to the handle to populate
1315 *
1316 * @ingroup aux_vk
1317 */
1318XRT_CHECK_RESULT VkResult
1320 VkDeviceMemory device_memory,
1321 xrt_graphics_buffer_handle_t *out_handle);
1322
1323/*!
1324 * @ingroup aux_vk
1325 * Helper to create a VkImage
1326 */
1327VkResult
1329 VkExtent2D extent,
1330 VkFormat format,
1331 VkImageUsageFlags usage,
1332 VkDeviceMemory *out_mem,
1333 VkImage *out_image);
1334
1335/*!
1336 * Helper to create a mutable RG88B8A8 VkImage that specializes in the two
1337 * UNORM and SRGB variants of that formats.
1338 *
1339 * @ingroup aux_vk
1340 */
1341VkResult
1343 struct vk_bundle *vk, VkExtent2D extent, VkImageUsageFlags usage, VkDeviceMemory *out_mem, VkImage *out_image);
1344
1345/*!
1346 * @ingroup aux_vk
1347 * Helper to create a VkImage, with more options for tiling and memory storage.
1348 */
1349VkResult
1351 VkExtent3D extent,
1352 VkFormat format,
1353 VkImageTiling image_tiling,
1354 VkImageUsageFlags image_usage_flags,
1355 VkMemoryPropertyFlags memory_property_flags,
1356 VkDeviceMemory *out_mem,
1357 VkImage *out_image);
1358
1359/*!
1360 * @ingroup aux_vk
1361 */
1362VkResult
1363vk_create_sampler(struct vk_bundle *vk, VkSamplerAddressMode clamp_mode, VkSampler *out_sampler);
1364
1365
1366/*
1367 *
1368 * Helpers for creating ímage views.
1369 *
1370 */
1371
1372/*!
1373 * @ingroup aux_vk
1374 */
1375VkResult
1376vk_create_view(struct vk_bundle *vk,
1377 VkImage image,
1378 VkImageViewType type,
1379 VkFormat format,
1380 VkImageSubresourceRange subresource_range,
1381 VkImageView *out_view);
1382
1383/*!
1384 * @ingroup aux_vk
1385 */
1386VkResult
1387vk_create_view_swizzle(struct vk_bundle *vk,
1388 VkImage image,
1389 VkImageViewType type,
1390 VkFormat format,
1391 VkImageSubresourceRange subresource_range,
1392 VkComponentMapping components,
1393 VkImageView *out_view);
1394
1395/*!
1396 * Creates a image with a specific subset of usage, useful for a mutable images
1397 * where one format might not support all usages defined by the image.
1398 *
1399 * @ingroup aux_vk
1400 */
1401VkResult
1403 VkImage image,
1404 VkImageViewType type,
1405 VkFormat format,
1406 VkImageUsageFlags image_usage,
1407 VkImageSubresourceRange subresource_range,
1408 VkImageView *out_view);
1409
1410
1411/*
1412 *
1413 * Helpers for creating descriptor pools and sets.
1414 *
1415 */
1416
1417bool
1418vk_init_descriptor_pool(struct vk_bundle *vk,
1419 const VkDescriptorPoolSize *pool_sizes,
1420 uint32_t pool_size_count,
1421 uint32_t set_count,
1422 VkDescriptorPool *out_descriptor_pool);
1423
1424bool
1425vk_allocate_descriptor_sets(struct vk_bundle *vk,
1426 VkDescriptorPool descriptor_pool,
1427 uint32_t count,
1428 const VkDescriptorSetLayout *set_layout,
1429 VkDescriptorSet *sets);
1430
1431
1432/*
1433 *
1434 * Helpers for creating buffers.
1435 *
1436 */
1437
1438bool
1439vk_buffer_init(struct vk_bundle *vk,
1440 VkDeviceSize size,
1441 VkBufferUsageFlags usage,
1442 VkMemoryPropertyFlags properties,
1443 VkBuffer *out_buffer,
1444 VkDeviceMemory *out_mem);
1445
1446void
1447vk_buffer_destroy(struct vk_buffer *self, struct vk_bundle *vk);
1448
1449bool
1450vk_update_buffer(struct vk_bundle *vk, float *buffer, size_t buffer_size, VkDeviceMemory memory);
1451
1452
1453/*
1454 *
1455 * Helpers for writing command buffers, in the vk_helpers.c file.
1456 *
1457 */
1458
1459/*!
1460 * Inserts a image barrier command, doesn't take any locks, the calling code
1461 * will need hold the lock for the pool that cmd_buffer is from or ensure it is
1462 * externally synchronized.
1463 *
1464 * @ingroup aux_vk
1465 */
1466void
1468 VkCommandBuffer cmd_buffer,
1469 VkImage image,
1470 VkAccessFlags src_access_mask,
1471 VkAccessFlags dst_access_mask,
1472 VkImageLayout old_image_layout,
1473 VkImageLayout new_image_layout,
1474 VkPipelineStageFlags src_stage_mask,
1475 VkPipelineStageFlags dst_stage_mask,
1476 VkImageSubresourceRange subresource_range);
1477
1478/*!
1479 * Inserts a image barrier command specifically for GPU commands, doesn't take
1480 * any locks, the calling code will need hold the lock for the pool that
1481 * cmd_buffer is from or ensure it is externally synchronized.
1482 *
1483 * @ingroup aux_vk
1484 */
1485void
1487 VkCommandBuffer cmd_buffer,
1488 VkImage image,
1489 VkAccessFlags src_access_mask,
1490 VkAccessFlags dst_access_mask,
1491 VkImageLayout old_layout,
1492 VkImageLayout new_layout,
1493 VkImageSubresourceRange subresource_range);
1494
1495#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
1496/*!
1497 * Uses VK_EXT_debug_utils to insert debug label into a VkCommandBuffer.
1498 *
1499 * In the vk_debug.c file.
1500 *
1501 * @ingroup aux_vk
1502 */
1503void
1504vk_cmd_insert_label(struct vk_bundle *vk, VkCommandBuffer cmd_buffer, const char *name);
1505#endif
1506
1507
1508/*
1509 *
1510 * State creation helpers, in the vk_state_creators.c file.
1511 *
1512 */
1513
1514/*!
1515 * Arguments to @ref vk_create_descriptor_pool function.
1516 */
1518{
1519 uint32_t uniform_per_descriptor_count; //!< VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
1520 uint32_t sampler_per_descriptor_count; //!< VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
1521 uint32_t storage_image_per_descriptor_count; //!< VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
1522 uint32_t storage_buffer_per_descriptor_count; //!< VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
1523
1524 //! The max count of created descriptors.
1526
1527 //! Are descriptors freeable, or must vkResetDescriptorPool be used.
1529};
1530
1531/*!
1532 * Creates a descriptor pool, made for a single layout.
1533 *
1534 * Does error logging.
1535 */
1536VkResult
1538 const struct vk_descriptor_pool_info *info,
1539 VkDescriptorPool *out_descriptor_pool);
1540
1541/*!
1542 * Creates a descriptor set.
1543 *
1544 * Does error logging.
1545 */
1546VkResult
1548 VkDescriptorPool descriptor_pool,
1549 VkDescriptorSetLayout descriptor_layout,
1550 VkDescriptorSet *out_descriptor_set);
1551
1552/*!
1553 * Creates a pipeline layout from a single descriptor set layout.
1554 *
1555 * Does error logging.
1556 */
1557VkResult
1559 VkDescriptorSetLayout descriptor_set_layout,
1560 VkPipelineLayout *out_pipeline_layout);
1561
1562/*!
1563 * Creates a pipeline cache.
1564 *
1565 * Does error logging.
1566 */
1567VkResult
1568vk_create_pipeline_cache(struct vk_bundle *vk, VkPipelineCache *out_pipeline_cache);
1569
1570/*!
1571 * Creates a compute pipeline, assumes entry function is called 'main'.
1572 *
1573 * Does error logging.
1574 */
1575VkResult
1577 VkPipelineCache pipeline_cache,
1578 VkShaderModule shader,
1579 VkPipelineLayout pipeline_layout,
1580 const VkSpecializationInfo *specialization_info,
1581 VkPipeline *out_compute_pipeline);
1582
1583
1584/*
1585 *
1586 * Compositor buffer and swapchain image flags helpers, in the vk_compositor_flags.c file.
1587 *
1588 */
1589
1590/*!
1591 * Return the extern handle type that a buffer should be created with.
1592 *
1593 * cb = Compositor Buffer.
1594 */
1595VkExternalMemoryHandleTypeFlags
1597
1598/*!
1599 * Helper for all of the supported formats to check support for.
1600 *
1601 * These are the available formats we will expose to our clients.
1602 *
1603 * In order of what we prefer. Start with a SRGB format that works on
1604 * both OpenGL and Vulkan. The two linear formats that works on both
1605 * OpenGL and Vulkan. A SRGB format that only works on Vulkan. The last
1606 * two formats should not be used as they are linear but doesn't have
1607 * enough bits to express it without resulting in banding.
1608 *
1609 * The format VK_FORMAT_A2B10G10R10_UNORM_PACK32 is not listed since
1610 * 10 bits are not considered enough to do linear colors without
1611 * banding. If there was a sRGB variant of it then we would have used it
1612 * instead but there isn't. Since it's not a popular format it's best
1613 * not to list it rather then listing it and people falling into the
1614 * trap. The absolute minimum is R11G11B10, but is a really weird format
1615 * so we are not exposing it.
1616 *
1617 * CSCI = Compositor SwapChain Images.
1618 *
1619 * @ingroup aux_vk
1620 */
1621#define VK_CSCI_FORMATS(THING_COLOR, THING_DS, THING_D, THING_S) \
1622 /* color formats */ \
1623 THING_COLOR(R16G16B16A16_UNORM) /* OGL VK */ \
1624 THING_COLOR(R16G16B16A16_SFLOAT) /* OGL VK */ \
1625 THING_COLOR(R16G16B16_UNORM) /* OGL VK - Uncommon. */ \
1626 THING_COLOR(R16G16B16_SFLOAT) /* OGL VK - Uncommon. */ \
1627 THING_COLOR(R8G8B8A8_SRGB) /* OGL VK */ \
1628 THING_COLOR(B8G8R8A8_SRGB) /* VK */ \
1629 THING_COLOR(R8G8B8_SRGB) /* OGL VK - Uncommon. */ \
1630 THING_COLOR(R8G8B8A8_UNORM) /* OGL VK - Bad color precision. */ \
1631 THING_COLOR(B8G8R8A8_UNORM) /* VK - Bad color precision. */ \
1632 THING_COLOR(R8G8B8_UNORM) /* OGL VK - Uncommon. Bad color precision. */ \
1633 THING_COLOR(B8G8R8_UNORM) /* VK - Uncommon. Bad color precision. */ \
1634 THING_COLOR(R5G6B5_UNORM_PACK16) /* OLG VK - Bad color precision. */ \
1635 THING_COLOR(R32_SFLOAT) /* OGL VK */ \
1636 /* depth formats */ \
1637 THING_D(D32_SFLOAT) /* OGL VK */ \
1638 THING_D(D16_UNORM) /* OGL VK */ \
1639 THING_D(X8_D24_UNORM_PACK32) /* OGL VK */ \
1640 /* depth stencil formats */ \
1641 THING_DS(D24_UNORM_S8_UINT) /* OGL VK */ \
1642 THING_DS(D32_SFLOAT_S8_UINT) /* OGL VK */ \
1643 /* stencil format */ \
1644 THING_S(S8_UINT)
1645
1646/*!
1647 * Returns the access flags for the compositor to app barriers.
1648 *
1649 * CSCI = Compositor SwapChain Images.
1650 */
1651VkAccessFlags
1653
1654/*!
1655 * Return the optimal layout for this format, this is the layout as given to the
1656 * app so is bound to the OpenXR spec.
1657 *
1658 * CSCI = Compositor SwapChain Images.
1659 */
1660VkImageLayout
1661vk_csci_get_barrier_optimal_layout(VkFormat format);
1662
1663/*!
1664 * Return the barrier aspect mask for this format, this is intended for the
1665 * barriers that flush the data out before and after transfers between the
1666 * application and compositor.
1667 *
1668 * CSCI = Compositor SwapChain Images.
1669 */
1670VkImageAspectFlags
1671vk_csci_get_barrier_aspect_mask(VkFormat format);
1672
1673/*!
1674 * Returns the usage bits for a given selected format and usage.
1675 *
1676 * For color formats always adds:
1677 * * `VK_IMAGE_USAGE_SAMPLED_BIT` for compositor reading in shaders.
1678 *
1679 * For depth & stencil formats always adds:
1680 * * `VK_IMAGE_USAGE_SAMPLED_BIT` for compositor reading in shaders.
1681 *
1682 * For depth formats always adds:
1683 * * `VK_IMAGE_USAGE_SAMPLED_BIT` for compositor reading in shaders.
1684 *
1685 * For stencil formats always adds:
1686 * * `VK_IMAGE_USAGE_SAMPLED_BIT` for compositor reading in shaders.
1687 *
1688 * CSCI = Compositor SwapChain Images.
1689 */
1690VkImageUsageFlags
1691vk_csci_get_image_usage_flags(struct vk_bundle *vk, VkFormat format, enum xrt_swapchain_usage_bits bits);
1692
1693/*!
1694 * For images views created by the compositor to sample the images, what aspect
1695 * should be set. For color it's the color, for depth and stencil it's only
1696 * depth as both are disallowed by the Vulkan spec, for depth only depth, and
1697 * for stencil only it's stencil.
1698 *
1699 * CSCI = Compositor SwapChain Images.
1700 */
1701VkImageAspectFlags
1703
1704/*!
1705 * Return the extern handle type that a image should be created with.
1706 *
1707 * CSCI = Compositor SwapChain Images.
1708 */
1709VkExternalMemoryHandleTypeFlags
1711
1712/*!
1713 * Get whether a given image can be imported/exported for a handle type.
1714 *
1715 * CSCI = Compositor SwapChain Images.
1716 */
1717void
1719 VkFormat image_format,
1720 enum xrt_swapchain_usage_bits bits,
1721 VkExternalMemoryHandleTypeFlags handle_type,
1722 bool *out_importable,
1723 bool *out_exportable);
1724
1725/*!
1726 * Verify if a format is supported for a specific usage
1727 *
1728 * CSCI = Compositor SwapChain Images.
1729 */
1730bool
1731vk_csci_is_format_supported(struct vk_bundle *vk, VkFormat format, enum xrt_swapchain_usage_bits xbits);
1732
1733/*
1734 *
1735 * Sync objects, in the vk_sync_objects.c file.
1736 *
1737 */
1738
1739/*!
1740 * Is there a good likelihood that the import/export of a timeline semaphore
1741 * will succeed, in other words will the below functions work.
1742 *
1743 * @ingroup aux_vk
1744 */
1745XRT_CHECK_RESULT bool
1747
1748/*!
1749 * @brief Creates a Vulkan fence, submits it to the default VkQueue and return
1750 * its native graphics sync handle.
1751 *
1752 * In case of error, out_native is not touched by the function.
1753 *
1754 * See @ref vk_create_fence_sync_from_native for ownership semantics on import.
1755 *
1756 * @ingroup aux_vk
1757 */
1758XRT_CHECK_RESULT VkResult
1760
1761/*!
1762 * @brief Creates a Vulkan fence from a native graphics sync handle.
1763 *
1764 * In case of error, ownership is never transferred and the caller should close the handle themselves.
1765 *
1766 * In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the @p native
1767 * handle may have transferred, a reference may have been added, or the Vulkan object may rely on the caller to keep the
1768 * native handle alive until the Vulkan object is destroyed. Which option applies depends on the particular native
1769 * handle type used.
1770 *
1771 * See the corresponding Vulkan specification text:
1772 * https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fences-importing
1773 *
1774 * @ingroup aux_vk
1775 */
1776XRT_CHECK_RESULT VkResult
1777vk_create_fence_sync_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkFence *out_fence);
1778
1779/*!
1780 * Creates a Vulkan semaphore and a native graphics sync handle.
1781 *
1782 * In case of success, the underlying Vulkan functionality's ownership semantics
1783 * apply: ownership of the @p native handle may have transferred, a reference
1784 * may have been added, or the Vulkan object may rely on the caller to keep the
1785 * native handle alive until the Vulkan object is destroyed. Which option
1786 * applies depends on the particular native handle type used.
1787 *
1788 * In case of error, neither @p out_sem and @p out_native is not touched by the
1789 * function so the caller only becomes responsible for the output on success.
1790 *
1791 * See the corresponding Vulkan specification text:
1792 * https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-semaphores
1793 *
1794 * @ingroup aux_vk
1795 */
1796XRT_CHECK_RESULT VkResult
1797vk_create_semaphore_and_native(struct vk_bundle *vk, VkSemaphore *out_sem, xrt_graphics_sync_handle_t *out_native);
1798
1799#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1800/*
1801 * Creates a Vulkan timeline semaphore and a native graphics sync
1802 * handle, see @ref vk_create_semaphore_and_native for more details.
1803 *
1804 * @ingroup aux_vk
1805 */
1806XRT_CHECK_RESULT VkResult
1807vk_create_timeline_semaphore_and_native(struct vk_bundle *vk,
1808 VkSemaphore *out_sem,
1809 xrt_graphics_sync_handle_t *out_native);
1810#endif
1811
1812/*!
1813 * @brief Creates a Vulkan semaphore from a native graphics sync handle.
1814 *
1815 * In case of error, ownership is never transferred and the caller should close the handle themselves.
1816 *
1817 * In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the @p native
1818 * handle may have transferred, a reference may have been added, or the Vulkan object may rely on the caller to keep the
1819 * native handle alive until the Vulkan object is destroyed. Which option applies depends on the particular native
1820 * handle type used.
1821 *
1822 * @ingroup aux_vk
1823 */
1824XRT_CHECK_RESULT VkResult
1825vk_create_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkSemaphore *out_sem);
1826
1827#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1828/*!
1829 * @brief Creates a Vulkan timeline semaphore from a native graphics sync
1830 * handle, see @ref vk_create_semaphore_from_native for more details.
1831 *
1832 * @ingroup aux_vk
1833 */
1834XRT_CHECK_RESULT VkResult
1836#endif
1837
1838
1839/*
1840 *
1841 * Time function(s), in the vk_time.c file.
1842 *
1843 */
1844
1845#if defined(VK_EXT_calibrated_timestamps) || defined(XRT_DOXYGEN)
1846/*!
1847 * Convert timestamps in GPU ticks (as return by VkQueryPool timestamp queries)
1848 * into host CPU nanoseconds, same time domain as @ref os_monotonic_get_ns.
1849 *
1850 * Note the timestamp needs to be in the past and not to old, this is because
1851 * not all GPU has full 64 bit timer resolution. For instance a Intel GPU "only"
1852 * have 36 bits of valid timestamp and a tick period 83.3333 nanosecond,
1853 * equating to an epoch of 5726 seconds before overflowing. The function can
1854 * handle overflows happening between the given timestamps and when it is called
1855 * but only for one such epoch overflow, any more will only be treated as one
1856 * such overflow. So timestamps needs to be converted reasonably soon after they
1857 * have been captured.
1858 *
1859 * @param vk The Vulkan bundle.
1860 * @param count Number of timestamps to be converted.
1861 * @param[in,out] in_out_timestamps Array of timestamps to be converted, done in place.
1862 *
1863 * @ingroup aux_vk
1864 */
1865XRT_CHECK_RESULT VkResult
1866vk_convert_timestamps_to_host_ns(struct vk_bundle *vk, uint32_t count, uint64_t *in_out_timestamps);
1867#endif
1868
1869
1870#ifdef __cplusplus
1871}
1872#endif
u_logging_level
Logging level enum.
Definition: u_logging.h:45
static void os_mutex_lock(struct os_mutex *om)
Lock.
Definition: os_threading.h:97
static int os_mutex_trylock(struct os_mutex *om)
Try to lock, but do not block.
Definition: os_threading.h:109
static void os_mutex_unlock(struct os_mutex *om)
Unlock.
Definition: os_threading.h:121
VkResult vk_enumerate_display_mode_properties(struct vk_bundle *vk, VkPhysicalDevice physical_device, VkDisplayKHR display, uint32_t *out_prop_count, VkDisplayModePropertiesKHR **out_props)
Enumerate the mode properties of the given VkDisplayKHR, which belongs to the given VkPhysicalDevice.
VkResult vk_enumerate_physical_device_extension_properties(struct vk_bundle *vk, VkPhysicalDevice physical_device, const char *layer_name, uint32_t *out_prop_count, VkExtensionProperties **out_props)
Enumerate the extension properties of the given VkPhysicalDevice for the named layer_name,...
Definition: vk_enumerate.c:102
VkResult vk_create_image_advanced(struct vk_bundle *vk, VkExtent3D extent, VkFormat format, VkImageTiling image_tiling, VkImageUsageFlags image_usage_flags, VkMemoryPropertyFlags memory_property_flags, VkDeviceMemory *out_mem, VkImage *out_image)
Helper to create a VkImage, with more options for tiling and memory storage.
Definition: vk_helpers.c:973
VkResult vk_enumerate_physical_display_plane_properties(struct vk_bundle *vk, VkPhysicalDevice physical_device, uint32_t *out_prop_count, VkDisplayPlanePropertiesKHR **out_props)
Enumerate the display plane properties of the given VkPhysicalDevice.
XRT_CHECK_RESULT VkResult vk_create_device(struct vk_bundle *vk, int forced_index, bool only_compute, VkQueueGlobalPriorityEXT global_priority, struct u_string_list *required_device_ext_list, struct u_string_list *optional_device_ext_list, const struct vk_device_features *optional_device_features)
Creates a VkDevice and initialises the VkQueue.
Definition: vk_bundle_init.c:1346
void vk_cmd_image_barrier_gpu_locked(struct vk_bundle *vk, VkCommandBuffer cmd_buffer, VkImage image, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImageSubresourceRange subresource_range)
Inserts a image barrier command specifically for GPU commands, doesn't take any locks,...
Definition: vk_helpers.c:1728
XRT_CHECK_RESULT VkResult vk_init_from_given(struct vk_bundle *vk, PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, uint32_t queue_family_index, uint32_t queue_index, bool external_fence_fd_enabled, bool external_semaphore_fd_enabled, bool timeline_semaphore_enabled, bool image_format_list_enabled, bool debug_utils_enabled, enum u_logging_level log_level)
Initialize a bundle with objects given to us by client code, used by client_vk_compositor in Composit...
Definition: vk_bundle_init.c:1686
VkResult vk_create_image_mutable_rgba(struct vk_bundle *vk, VkExtent2D extent, VkImageUsageFlags usage, VkDeviceMemory *out_mem, VkImage *out_image)
Helper to create a mutable RG88B8A8 VkImage that specializes in the two UNORM and SRGB variants of th...
Definition: vk_helpers.c:936
XRT_CHECK_RESULT VkResult vk_convert_timestamps_to_host_ns(struct vk_bundle *vk, uint32_t count, uint64_t *in_out_timestamps)
Convert timestamps in GPU ticks (as return by VkQueryPool timestamp queries) into host CPU nanosecond...
XRT_CHECK_RESULT VkResult vk_create_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkSemaphore *out_sem)
Creates a Vulkan semaphore from a native graphics sync handle.
Definition: vk_sync_objects.c:461
void vk_cmd_image_barrier_locked(struct vk_bundle *vk, VkCommandBuffer cmd_buffer, VkImage image, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_image_layout, VkImageLayout new_image_layout, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkImageSubresourceRange subresource_range)
Inserts a image barrier command, doesn't take any locks, the calling code will need hold the lock for...
Definition: vk_helpers.c:1691
VkResult vk_enumerate_physical_device_display_properties(struct vk_bundle *vk, VkPhysicalDevice physical_device, uint32_t *out_prop_count, VkDisplayPropertiesKHR **out_props)
Enumerate the display properties of the given VkPhysicalDevice.
XRT_CHECK_RESULT VkResult vk_create_timeline_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkSemaphore *out_sem)
Creates a Vulkan timeline semaphore from a native graphics sync handle, see vk_create_semaphore_from_...
VkResult vk_create_image_simple(struct vk_bundle *vk, VkExtent2D extent, VkFormat format, VkImageUsageFlags usage, VkDeviceMemory *out_mem, VkImage *out_image)
Helper to create a VkImage.
Definition: vk_helpers.c:915
VkResult vk_select_physical_device(struct vk_bundle *vk, int forced_index)
Setup the physical device, this is called by vk_create_device but has uses for outside of that.
Definition: vk_bundle_init.c:1340
void vk_print_device_info(struct vk_bundle *vk, enum u_logging_level log_level, const VkPhysicalDeviceProperties *pdp, uint32_t gpu_index, const char *title)
Print device information to the logger at the given logging level, if the vk_bundle has that level en...
Definition: vk_print.c:100
VkResult vk_enumerate_swapchain_images(struct vk_bundle *vk, VkSwapchainKHR swapchain, uint32_t *out_image_count, VkImage **out_images)
Enumerate the images of the given VkSwapchainKHR.
VkResult vk_deinit_mutex(struct vk_bundle *vk)
De-initialize mutexes in the vk_bundle.
Definition: vk_bundle_init.c:1667
XRT_CHECK_RESULT VkResult vk_create_semaphore_and_native(struct vk_bundle *vk, VkSemaphore *out_sem, xrt_graphics_sync_handle_t *out_native)
Creates a Vulkan semaphore and a native graphics sync handle.
Definition: vk_sync_objects.c:282
XRT_CHECK_RESULT VkResult vk_create_and_submit_fence_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t *out_native)
Creates a Vulkan fence, submits it to the default VkQueue and return its native graphics sync handle.
Definition: vk_sync_objects.c:105
VkResult vk_enumerate_surface_present_modes(struct vk_bundle *vk, VkSurfaceKHR surface, uint32_t *out_present_mode_count, VkPresentModeKHR **out_present_modes)
Enumerate the present modes of the given VkSurfaceKHR.
XRT_CHECK_RESULT VkResult vk_create_image_from_native(struct vk_bundle *vk, const struct xrt_swapchain_create_info *info, struct xrt_image_native *image_native, VkImage *out_image, VkDeviceMemory *out_mem)
Creates a Vulkan device memory and image from a native graphics buffer handle.
Definition: vk_helpers.c:1076
VkResult vk_get_loader_functions(struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g)
Can be done on a completely bare bundle.
Definition: vk_function_loaders.c:43
XRT_CHECK_RESULT bool vk_can_import_and_export_timeline_semaphore(struct vk_bundle *vk)
Is there a good likelihood that the import/export of a timeline semaphore will succeed,...
Definition: vk_sync_objects.c:77
VkResult vk_enumerate_physical_devices(struct vk_bundle *vk, uint32_t *out_physical_device_count, VkPhysicalDevice **out_physical_devices)
Enumerate the physical devices of the VkInstance that has been opened on the given vk_bundle.
Definition: vk_enumerate.c:79
XRT_CHECK_RESULT VkResult vk_create_fence_sync_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkFence *out_fence)
Creates a Vulkan fence from a native graphics sync handle.
Definition: vk_sync_objects.c:338
VkResult vk_enumerate_instance_extensions_properties(struct vk_bundle *vk, const char *layer_name, uint32_t *out_prop_count, VkExtensionProperties **out_props)
Return the VkExtensionProperties of the given layer_name, NULL means the "base" driver instance.
Definition: vk_enumerate.c:55
VkResult vk_create_view_usage(struct vk_bundle *vk, VkImage image, VkImageViewType type, VkFormat format, VkImageUsageFlags image_usage, VkImageSubresourceRange subresource_range, VkImageView *out_view)
Creates a image with a specific subset of usage, useful for a mutable images where one format might n...
Definition: vk_helpers.c:1513
struct u_string_list * vk_build_instance_extensions(struct vk_bundle *vk, struct u_string_list *required_instance_ext_list, struct u_string_list *optional_instance_ext_list)
Only requires vk_get_loader_functions to have been called.
Definition: vk_bundle_init.c:128
XRT_CHECK_RESULT VkResult vk_alloc_and_bind_image_memory(struct vk_bundle *vk, VkImage image, const VkMemoryRequirements *requirements, const void *pNext_for_allocate, const char *caller_name, VkDeviceMemory *out_mem)
Allocate memory for an image and bind it to that image.
Definition: vk_helpers.c:807
VkResult vk_enumerate_surface_formats(struct vk_bundle *vk, VkSurfaceKHR surface, uint32_t *out_format_count, VkSurfaceFormatKHR **out_formats)
Enumerate the surface formats of the given VkSurfaceKHR, returns a list of VkSurfaceFormatKHR,...
void vk_name_object(struct vk_bundle *vk, VkObjectType type, uint64_t object, const char *name)
Uses VK_EXT_debug_utils to set a name for an object, for easier debugging.
void vk_print_opened_device_info(struct vk_bundle *vk, enum u_logging_level log_level)
Print device information about the device that bundle manages at the given logging level if the vk_bu...
Definition: vk_print.c:128
VkResult vk_check_required_instance_extensions(struct vk_bundle *vk, struct u_string_list *required_instance_ext_list)
Check if the required instance extensions are supported, if not print error message with all extensio...
Definition: vk_bundle_init.c:74
VkResult vk_get_device_functions(struct vk_bundle *vk)
Requires a device to have been created and set on the bundle.
Definition: vk_function_loaders.c:157
XRT_CHECK_RESULT VkResult vk_get_native_handle_from_device_memory(struct vk_bundle *vk, VkDeviceMemory device_memory, xrt_graphics_buffer_handle_t *out_handle)
Given a DeviceMemory handle created to be exportable, outputs the native buffer type (FD on desktop L...
Definition: vk_helpers.c:1370
VkResult vk_get_instance_functions(struct vk_bundle *vk)
Requires a instance to have been created and set on the bundle.
Definition: vk_function_loaders.c:57
void vk_cmd_insert_label(struct vk_bundle *vk, VkCommandBuffer cmd_buffer, const char *name)
Uses VK_EXT_debug_utils to insert debug label into a VkCommandBuffer.
void vk_print_result(struct vk_bundle *vk, const char *file, int line, const char *calling_func, VkResult ret, const char *called_func)
Print the result of a function, info level if ret == VK_SUCCESS and error level otherwise.
Definition: vk_print.c:74
VkResult vk_init_mutex(struct vk_bundle *vk)
Initialize mutexes in the vk_bundle.
Definition: vk_bundle_init.c:1651
xrt_swapchain_usage_bits
Usage of the swapchain images.
Definition: xrt_compositor.h:510
Wrapper around OS threading native functions.
A wrapper around a native mutex.
Definition: os_threading.h:66
Definition: u_string_list.cpp:19
Definition: vk_helpers.h:539
Definition: vk_helpers.h:59
uint32_t family_index
The queue family index.
Definition: vk_helpers.h:63
VkQueue queue
The Vulkan queue handle.
Definition: vk_helpers.h:61
struct os_mutex mutex
The queue mutex -.
Definition: vk_helpers.h:67
uint32_t index
The queue (instance) index.
Definition: vk_helpers.h:65
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition: vk_helpers.h:78
uint32_t max_bound_descriptor_sets
Maximum number of descriptor sets that can be simultaneously used by a pipeline.
Definition: vk_helpers.h:222
bool synchronization_2
Was synchronization2 requested, available, and enabled?
Definition: vk_helpers.h:207
uint32_t max_descriptor_set_samplers
Maximum number of samplers that can be included in a pipeline layout.
Definition: vk_helpers.h:225
bool timeline_semaphore
Were timeline semaphore requested, available, and enabled?
Definition: vk_helpers.h:204
uint32_t max_per_stage_descriptor_samplers
Maximum number of samplers that can be accessible to a single shader stage in a pipeline layout.
Definition: vk_helpers.h:231
bool video_maintenance_1
Was KHR_video_maintenance1 requested, available, and enabled?
Definition: vk_helpers.h:213
struct vk_bundle_queue queues[2]
queues - a free list of unique queues
Definition: vk_helpers.h:95
uint32_t timestamp_valid_bits
Valid bits in the queue selected.
Definition: vk_helpers.h:201
uint32_t max_sampler_allocation_count
Maximum number of sampler objects, as created by vkCreateSampler, which can simultaneously exist on.
Definition: vk_helpers.h:219
uint32_t max_descriptor_set_sampled_images
Maximum number of sampled images that can be included in a pipeline layout.
Definition: vk_helpers.h:228
uint32_t max_per_stage_descriptor_storage_images
Per stage limit on storage images.
Definition: vk_helpers.h:237
bool is_tegra
Is the GPU a tegra device.
Definition: vk_helpers.h:241
bool timestamp_compute_and_graphics
Are timestamps available for compute and graphics queues?
Definition: vk_helpers.h:195
bool present_wait
Was KHR_present_wait requested, available, and enabled?
Definition: vk_helpers.h:210
uint32_t max_per_stage_descriptor_sampled_images
Per stage limit on sampled images (includes combined).
Definition: vk_helpers.h:234
float timestamp_period
Nanoseconds per gpu tick.
Definition: vk_helpers.h:198
Arguments to vk_create_descriptor_pool function.
Definition: vk_helpers.h:1518
uint32_t descriptor_count
The max count of created descriptors.
Definition: vk_helpers.h:1525
uint32_t uniform_per_descriptor_count
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.
Definition: vk_helpers.h:1519
bool freeable
Are descriptors freeable, or must vkResetDescriptorPool be used.
Definition: vk_helpers.h:1528
uint32_t sampler_per_descriptor_count
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER.
Definition: vk_helpers.h:1520
uint32_t storage_image_per_descriptor_count
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE.
Definition: vk_helpers.h:1521
uint32_t storage_buffer_per_descriptor_count
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER.
Definition: vk_helpers.h:1522
Used to enable device features as a argument vk_create_device.
Definition: vk_helpers.h:1135
Definition: vk_helpers.h:45
uint32_t index
The queue (instance) index.
Definition: vk_helpers.h:49
uint32_t family_index
The queue family index.
Definition: vk_helpers.h:47
A single image of a swapchain based on native buffer handles.
Definition: xrt_compositor.h:2161
Swapchain creation info.
Definition: xrt_compositor.h:871
Basic logging functionality.
A collection of strings, like a list of extensions to enable.
VkImageAspectFlags vk_csci_get_barrier_aspect_mask(VkFormat format)
Return the barrier aspect mask for this format, this is intended for the barriers that flush the data...
Definition: vk_compositor_flags.c:131
VkResult vk_create_descriptor_set(struct vk_bundle *vk, VkDescriptorPool descriptor_pool, VkDescriptorSetLayout descriptor_layout, VkDescriptorSet *out_descriptor_set)
Creates a descriptor set.
Definition: vk_state_creators.c:88
void vk_print_external_handles_info(struct vk_bundle *vk, enum u_logging_level log_level)
Print external handle features to the logger at the given logging level, if the vk_bundle has that le...
Definition: vk_print.c:152
VkExternalMemoryHandleTypeFlags vk_cb_get_buffer_external_handle_type(struct vk_bundle *vk)
Return the extern handle type that a buffer should be created with.
Definition: vk_compositor_flags.c:65
void vk_fill_in_has_instance_extensions(struct vk_bundle *vk, struct u_string_list *ext_list)
Fills in has_* in vk_bundle given a string of prefiltered instance extensions.
Definition: vk_bundle_init.c:179
XRT_CHECK_RESULT const char * vk_surface_transform_flag_string(VkSurfaceTransformFlagBitsKHR bits, bool null_on_unknown)
Returns the surface transform flag if one valid bit is set, if multiple bits are set,...
Definition: vk_helpers.c:698
bool vk_csci_is_format_supported(struct vk_bundle *vk, VkFormat format, enum xrt_swapchain_usage_bits xbits)
Verify if a format is supported for a specific usage.
Definition: vk_compositor_flags.c:344
XRT_CHECK_RESULT const char * xrt_swapchain_usage_flag_string(enum xrt_swapchain_usage_bits bits, bool null_on_unknown)
Returns xrt swapchain_usage flag if one valid bit is set, if multiple bits are set,...
Definition: vk_helpers.c:743
VkExternalMemoryHandleTypeFlags vk_csci_get_image_external_handle_type(struct vk_bundle *vk, struct xrt_image_native *xin)
Return the extern handle type that a image should be created with.
Definition: vk_compositor_flags.c:214
void vk_print_queues_info(const struct vk_bundle *vk, enum u_logging_level log_level)
Print queue info to the logger at the given logging level, if the vk_bundle has that level enabled.
Definition: vk_print.c:307
VkResult vk_create_pipeline_cache(struct vk_bundle *vk, VkPipelineCache *out_pipeline_cache)
Creates a pipeline cache.
Definition: vk_state_creators.c:147
VkResult vk_create_descriptor_pool(struct vk_bundle *vk, const struct vk_descriptor_pool_info *info, VkDescriptorPool *out_descriptor_pool)
Creates a descriptor pool, made for a single layout.
Definition: vk_state_creators.c:16
void vk_print_swapchain_create_info(struct vk_bundle *vk, VkSwapchainCreateInfoKHR *i, enum u_logging_level log_level)
Print a VkSwapchainCreateInfoKHR, used to log during creation.
Definition: vk_print.c:253
XRT_CHECK_RESULT const char * vk_image_usage_flag_string(VkImageUsageFlagBits bits, bool null_on_unknown)
Returns the image usage flag if one valid bit is set, if multiple bits are set, will return 'MULTIPLE...
Definition: vk_helpers.c:627
VkAccessFlags vk_csci_get_barrier_access_mask(enum xrt_swapchain_usage_bits bits)
Returns the access flags for the compositor to app barriers.
Definition: vk_compositor_flags.c:79
XRT_CHECK_RESULT const char * vk_format_feature_flag_string(VkFormatFeatureFlagBits bits, bool null_on_unknown)
Returns the format feature flag if one valid bit is set, if multiple bits are set,...
Definition: vk_helpers.c:607
void vk_csci_get_image_external_support(struct vk_bundle *vk, VkFormat image_format, enum xrt_swapchain_usage_bits bits, VkExternalMemoryHandleTypeFlags handle_type, bool *out_importable, bool *out_exportable)
Get whether a given image can be imported/exported for a handle type.
Definition: vk_compositor_flags.c:229
XRT_CHECK_RESULT const char * vk_composite_alpha_flag_string(VkCompositeAlphaFlagBitsKHR bits, bool null_on_unknown)
Returns the composite alpha flag if one valid bit is set, if multiple bits are set,...
Definition: vk_helpers.c:679
VkResult vk_create_compute_pipeline(struct vk_bundle *vk, VkPipelineCache pipeline_cache, VkShaderModule shader, VkPipelineLayout pipeline_layout, const VkSpecializationInfo *specialization_info, VkPipeline *out_compute_pipeline)
Creates a compute pipeline, assumes entry function is called 'main'.
Definition: vk_state_creators.c:172
void vk_print_features_info(struct vk_bundle *vk, enum u_logging_level log_level)
Print device features to the logger at the given logging level, if the vk_bundle has that level enabl...
Definition: vk_print.c:137
VkImageLayout vk_csci_get_barrier_optimal_layout(VkFormat format)
Return the optimal layout for this format, this is the layout as given to the app so is bound to the ...
Definition: vk_compositor_flags.c:112
VkImageUsageFlags vk_csci_get_image_usage_flags(struct vk_bundle *vk, VkFormat format, enum xrt_swapchain_usage_bits bits)
Returns the usage bits for a given selected format and usage.
Definition: vk_compositor_flags.c:177
VkResult vk_create_pipeline_layout(struct vk_bundle *vk, VkDescriptorSetLayout descriptor_set_layout, VkPipelineLayout *out_pipeline_layout)
Creates a pipeline layout from a single descriptor set layout.
Definition: vk_state_creators.c:118
VkImageAspectFlags vk_csci_get_image_view_aspect(VkFormat format, enum xrt_swapchain_usage_bits bits)
For images views created by the compositor to sample the images, what aspect should be set.
Definition: vk_compositor_flags.c:154
Header holding common defines.
Header declaring XRT graphics interfaces.
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:252
int xrt_graphics_sync_handle_t
The type underlying synchronization primitives (semaphores, etc) shared between compositor clients an...
Definition: xrt_handles.h:354
Include all of the Vulkan headers in one place, and cope with any "messy" includes implied by it.