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