36#define VK_BUNDLE_MAX_QUEUES 2
52#define VK_NULL_QUEUE_PAIR \
53 XRT_C11_COMPOUND(struct vk_queue_pair) \
55 .family_index = VK_QUEUE_FAMILY_IGNORED, .index = (uint32_t)-1, \
83 VkPhysicalDevice physical_device;
84 int physical_device_index;
98#if defined(VK_KHR_video_encode_queue)
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;
110 bool color_image_import_d3d11;
111 bool color_image_export_d3d11;
112 bool depth_image_import_d3d11;
113 bool depth_image_export_d3d11;
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;
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;
127 bool color_image_import_ahardwarebuffer;
128 bool color_image_export_ahardwarebuffer;
129 bool depth_image_import_ahardwarebuffer;
130 bool depth_image_export_ahardwarebuffer;
133#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
135 bool fence_opaque_fd;
137 bool binary_semaphore_sync_fd;
138 bool binary_semaphore_opaque_fd;
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;
145 bool binary_semaphore_d3d12_fence;
146 bool binary_semaphore_win32_handle;
148 bool timeline_semaphore_d3d12_fence;
149 bool timeline_semaphore_win32_handle;
151#error "Need port for fence sync handles checkers"
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;
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;
244 VkDebugReportCallbackEXT debug_report_cb;
246 VkPhysicalDeviceMemoryProperties device_memory_props;
249 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
250 PFN_vkCreateInstance vkCreateInstance;
251 PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
254 PFN_vkDestroyInstance vkDestroyInstance;
255 PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
256 PFN_vkCreateDevice vkCreateDevice;
257 PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
259 PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
260 PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
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;
281#if defined(VK_EXT_calibrated_timestamps)
282 PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT;
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;
296#if defined(VK_USE_PLATFORM_XCB_KHR)
297 PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
301#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
302 PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
306#if defined(VK_USE_PLATFORM_WAYLAND_KHR) && defined(VK_EXT_acquire_drm_display)
307 PFN_vkAcquireDrmDisplayEXT vkAcquireDrmDisplayEXT;
308 PFN_vkGetDrmDisplayEXT vkGetDrmDisplayEXT;
312#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT)
313 PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT;
314 PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT;
318#if defined(VK_USE_PLATFORM_ANDROID_KHR)
319 PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
323#if defined(VK_USE_PLATFORM_WIN32_KHR)
324 PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
328#if defined(VK_USE_PLATFORM_METAL_EXT)
329 PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
333#if defined(VK_EXT_display_surface_counter)
334 PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT;
338#if defined(VK_EXT_debug_utils)
339 PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
340 PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT;
341 PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
347 PFN_vkDestroyDevice vkDestroyDevice;
348 PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
349 PFN_vkAllocateMemory vkAllocateMemory;
350 PFN_vkFreeMemory vkFreeMemory;
351 PFN_vkMapMemory vkMapMemory;
352 PFN_vkUnmapMemory vkUnmapMemory;
354 PFN_vkCreateBuffer vkCreateBuffer;
355 PFN_vkDestroyBuffer vkDestroyBuffer;
356 PFN_vkBindBufferMemory vkBindBufferMemory;
358 PFN_vkCreateImage vkCreateImage;
359 PFN_vkDestroyImage vkDestroyImage;
360 PFN_vkBindImageMemory vkBindImageMemory;
362 PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
363 PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
364 PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
365 PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2;
366 PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
368 PFN_vkCreateImageView vkCreateImageView;
369 PFN_vkDestroyImageView vkDestroyImageView;
371 PFN_vkCreateSampler vkCreateSampler;
372 PFN_vkDestroySampler vkDestroySampler;
374 PFN_vkCreateShaderModule vkCreateShaderModule;
375 PFN_vkDestroyShaderModule vkDestroyShaderModule;
377 PFN_vkCreateQueryPool vkCreateQueryPool;
378 PFN_vkDestroyQueryPool vkDestroyQueryPool;
379 PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
381 PFN_vkCreateCommandPool vkCreateCommandPool;
382 PFN_vkDestroyCommandPool vkDestroyCommandPool;
383 PFN_vkResetCommandPool vkResetCommandPool;
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;
414 PFN_vkCreateRenderPass vkCreateRenderPass;
415 PFN_vkDestroyRenderPass vkDestroyRenderPass;
417 PFN_vkCreateFramebuffer vkCreateFramebuffer;
418 PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
420 PFN_vkCreatePipelineCache vkCreatePipelineCache;
421 PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
423 PFN_vkResetDescriptorPool vkResetDescriptorPool;
424 PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
425 PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
427 PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
428 PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
430 PFN_vkCreateComputePipelines vkCreateComputePipelines;
431 PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
432 PFN_vkDestroyPipeline vkDestroyPipeline;
434 PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
435 PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
437 PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
438 PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
439 PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
441 PFN_vkGetDeviceQueue vkGetDeviceQueue;
442 PFN_vkQueueSubmit vkQueueSubmit;
443 PFN_vkQueueWaitIdle vkQueueWaitIdle;
445 PFN_vkCreateSemaphore vkCreateSemaphore;
446#if defined(VK_KHR_timeline_semaphore)
447 PFN_vkSignalSemaphoreKHR vkSignalSemaphore;
448 PFN_vkWaitSemaphoresKHR vkWaitSemaphores;
449 PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValue;
452 PFN_vkDestroySemaphore vkDestroySemaphore;
454 PFN_vkCreateFence vkCreateFence;
455 PFN_vkWaitForFences vkWaitForFences;
456 PFN_vkGetFenceStatus vkGetFenceStatus;
457 PFN_vkDestroyFence vkDestroyFence;
458 PFN_vkResetFences vkResetFences;
460 PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
461 PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
462 PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
463 PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
464 PFN_vkQueuePresentKHR vkQueuePresentKHR;
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;
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;
484#if defined(VK_USE_PLATFORM_METAL_EXT)
485 PFN_vkExportMetalObjectsEXT vkExportMetalObjectsEXT;
489#if defined(VK_USE_PLATFORM_ANDROID_KHR)
490 PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
491 PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
495#if defined(VK_EXT_external_memory_host)
496 PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
500#if defined(VK_EXT_calibrated_timestamps)
501 PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT;
505 PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE;
507#if defined(VK_EXT_display_control)
508 PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT;
509 PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT;
510 PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT;
514#if defined(VK_EXT_image_drm_format_modifier)
515 PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT;
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;
531#if defined(VK_KHR_present_wait)
532 PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
541 VkDeviceMemory memory;
570#define VK_CHK_ONLY_PRINT(RET, FUNC_STR) \
572 VkResult _ret = RET; \
573 if (_ret != VK_SUCCESS) { \
574 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
594#define VK_CHK_AND_RET(RET, FUNC_STR) \
596 VkResult _ret = RET; \
597 if (_ret != VK_SUCCESS) { \
598 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
620#define VK_CHK_WITH_RET(RET, FUNC_STR, TO_RET) \
622 VkResult _ret = RET; \
623 if (_ret != VK_SUCCESS) { \
624 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
647#define VK_CHK_WITH_GOTO(RET, FUNC_STR, GOTO) \
649 VkResult _ret = RET; \
650 if (_ret != VK_SUCCESS) { \
651 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
657#define XVK_CHK_AND_RET(...) U_LOG_CHK_AND_RET(vk->log_level, __VA_ARGS__)
659#define XVK_CHK_WITH_GOTO(...) U_LOG_CHK_WITH_GOTO(vk->log_level, __VA_ARGS__)
661#define XVK_CHK_WITH_RET(...) U_LOG_CHK_WITH_RET(vk->log_level, __VA_ARGS__)
663#define XVK_CHK_ONLY_PRINT(...) U_LOG_CHK_ONLY_PRINT(vk->log_level, __VA_ARGS__)
665#define XVK_CHK_ALWAYS_RET(...) U_LOG_CHK_ALWAYS_RET(vk->log_level, __VA_ARGS__)
668vk_append_to_pnext_chain(VkBaseInStructure *head, VkBaseInStructure *new_struct)
670 assert(new_struct->pNext == NULL);
672 new_struct->pNext = head->pNext;
673 head->pNext = new_struct;
682XRT_CHECK_RESULT
const char *
683vk_result_string(VkResult code);
685XRT_CHECK_RESULT
const char *
686vk_object_type_string(VkObjectType type);
688XRT_CHECK_RESULT
const char *
689vk_physical_device_type_string(VkPhysicalDeviceType device_type);
691XRT_CHECK_RESULT
const char *
692vk_format_string(VkFormat code);
694XRT_CHECK_RESULT
const char *
695vk_sharing_mode_string(VkSharingMode code);
697XRT_CHECK_RESULT
const char *
698vk_present_mode_string(VkPresentModeKHR code);
700XRT_CHECK_RESULT
const char *
701vk_color_space_string(VkColorSpaceKHR code);
703XRT_CHECK_RESULT
const char *
704vk_power_state_string(VkDisplayPowerStateEXT code);
717XRT_CHECK_RESULT
const char *
724XRT_CHECK_RESULT
const char *
731XRT_CHECK_RESULT
const char *
738XRT_CHECK_RESULT
const char *
746XRT_CHECK_RESULT
const char *
747vk_display_plane_alpha_flag_string(VkDisplayPlaneAlphaFlagBitsKHR bits,
bool null_on_unknown);
754XRT_CHECK_RESULT
const char *
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__)
777#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
793#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) \
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); \
804#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ)
823#define VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ) \
825 XRT_MAYBE_UNUSED TYPE _thing = (TYPE)(OBJ); \
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)
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)
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)
877 struct vk_bundle *vk,
const char *file,
int line,
const char *calling_func, VkResult ret,
const char *called_func);
888 const VkPhysicalDeviceProperties *pdp,
926vk_print_display_surface_create_info(
struct vk_bundle *vk,
927 VkDisplaySurfaceCreateInfoKHR *i,
953 const char *layer_name,
954 uint32_t *out_prop_count,
955 VkExtensionProperties **out_props);
965 uint32_t *out_physical_device_count,
966 VkPhysicalDevice **out_physical_devices);
976 VkPhysicalDevice physical_device,
977 const char *layer_name,
978 uint32_t *out_prop_count,
979 VkExtensionProperties **out_props);
981#if defined(VK_KHR_surface) || defined(XRT_DOXYGEN)
990 VkSurfaceKHR surface,
991 uint32_t *out_format_count,
992 VkSurfaceFormatKHR **out_formats);
1001 VkSurfaceKHR surface,
1002 uint32_t *out_present_mode_count,
1003 VkPresentModeKHR **out_present_modes);
1006#if defined(VK_KHR_swapchain) || defined(XRT_DOXYGEN)
1014 VkSwapchainKHR swapchain,
1015 uint32_t *out_image_count,
1016 VkImage **out_images);
1019#if defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(XRT_DOXYGEN)
1027 VkPhysicalDevice physical_device,
1028 uint32_t *out_prop_count,
1029 VkDisplayPropertiesKHR **out_props);
1038 VkPhysicalDevice physical_device,
1039 uint32_t *out_prop_count,
1040 VkDisplayPlanePropertiesKHR **out_props);
1050 VkPhysicalDevice physical_device,
1051 VkDisplayKHR display,
1052 uint32_t *out_prop_count,
1053 VkDisplayModePropertiesKHR **out_props);
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;
1144 bool video_maintenance_1;
1155XRT_CHECK_RESULT VkResult
1159 VkQueueGlobalPriorityEXT global_priority,
1209XRT_CHECK_RESULT VkResult
1211 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
1212 VkInstance instance,
1213 VkPhysicalDevice physical_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,
1235vk_get_memory_type(
struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFlags memory_props, uint32_t *out_type_id);
1269XRT_CHECK_RESULT VkResult
1272 const VkMemoryRequirements *requirements,
1273 const void *pNext_for_allocate,
1274 const char *caller_name,
1275 VkDeviceMemory *out_mem);
1298XRT_CHECK_RESULT VkResult
1303 VkDeviceMemory *out_mem);
1318XRT_CHECK_RESULT VkResult
1320 VkDeviceMemory device_memory,
1331 VkImageUsageFlags usage,
1332 VkDeviceMemory *out_mem,
1333 VkImage *out_image);
1343 struct vk_bundle *vk, VkExtent2D extent, VkImageUsageFlags usage, VkDeviceMemory *out_mem, VkImage *out_image);
1353 VkImageTiling image_tiling,
1354 VkImageUsageFlags image_usage_flags,
1355 VkMemoryPropertyFlags memory_property_flags,
1356 VkDeviceMemory *out_mem,
1357 VkImage *out_image);
1363vk_create_sampler(
struct vk_bundle *vk, VkSamplerAddressMode clamp_mode, VkSampler *out_sampler);
1378 VkImageViewType type,
1380 VkImageSubresourceRange subresource_range,
1381 VkImageView *out_view);
1387vk_create_view_swizzle(
struct vk_bundle *vk,
1389 VkImageViewType type,
1391 VkImageSubresourceRange subresource_range,
1392 VkComponentMapping components,
1393 VkImageView *out_view);
1404 VkImageViewType type,
1406 VkImageUsageFlags image_usage,
1407 VkImageSubresourceRange subresource_range,
1408 VkImageView *out_view);
1418vk_init_descriptor_pool(
struct vk_bundle *vk,
1419 const VkDescriptorPoolSize *pool_sizes,
1420 uint32_t pool_size_count,
1422 VkDescriptorPool *out_descriptor_pool);
1425vk_allocate_descriptor_sets(
struct vk_bundle *vk,
1426 VkDescriptorPool descriptor_pool,
1428 const VkDescriptorSetLayout *set_layout,
1429 VkDescriptorSet *sets);
1441 VkBufferUsageFlags usage,
1442 VkMemoryPropertyFlags properties,
1443 VkBuffer *out_buffer,
1444 VkDeviceMemory *out_mem);
1450vk_update_buffer(
struct vk_bundle *vk,
float *buffer,
size_t buffer_size, VkDeviceMemory memory);
1468 VkCommandBuffer cmd_buffer,
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);
1487 VkCommandBuffer cmd_buffer,
1489 VkAccessFlags src_access_mask,
1490 VkAccessFlags dst_access_mask,
1491 VkImageLayout old_layout,
1492 VkImageLayout new_layout,
1493 VkImageSubresourceRange subresource_range);
1495#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
1539 VkDescriptorPool *out_descriptor_pool);
1548 VkDescriptorPool descriptor_pool,
1549 VkDescriptorSetLayout descriptor_layout,
1550 VkDescriptorSet *out_descriptor_set);
1559 VkDescriptorSetLayout descriptor_set_layout,
1560 VkPipelineLayout *out_pipeline_layout);
1577 VkPipelineCache pipeline_cache,
1578 VkShaderModule shader,
1579 VkPipelineLayout pipeline_layout,
1580 const VkSpecializationInfo *specialization_info,
1581 VkPipeline *out_compute_pipeline);
1595VkExternalMemoryHandleTypeFlags
1621#define VK_CSCI_FORMATS(THING_COLOR, THING_DS, THING_D, THING_S) \
1623 THING_COLOR(R16G16B16A16_UNORM) \
1624 THING_COLOR(R16G16B16A16_SFLOAT) \
1625 THING_COLOR(R16G16B16_UNORM) \
1626 THING_COLOR(R16G16B16_SFLOAT) \
1627 THING_COLOR(R8G8B8A8_SRGB) \
1628 THING_COLOR(B8G8R8A8_SRGB) \
1629 THING_COLOR(R8G8B8_SRGB) \
1630 THING_COLOR(R8G8B8A8_UNORM) \
1631 THING_COLOR(B8G8R8A8_UNORM) \
1632 THING_COLOR(R8G8B8_UNORM) \
1633 THING_COLOR(B8G8R8_UNORM) \
1634 THING_COLOR(R5G6B5_UNORM_PACK16) \
1635 THING_COLOR(R32_SFLOAT) \
1637 THING_D(D32_SFLOAT) \
1638 THING_D(D16_UNORM) \
1639 THING_D(X8_D24_UNORM_PACK32) \
1641 THING_DS(D24_UNORM_S8_UINT) \
1642 THING_DS(D32_SFLOAT_S8_UINT) \
1709VkExternalMemoryHandleTypeFlags
1719 VkFormat image_format,
1721 VkExternalMemoryHandleTypeFlags handle_type,
1722 bool *out_importable,
1723 bool *out_exportable);
1745XRT_CHECK_RESULT
bool
1758XRT_CHECK_RESULT VkResult
1776XRT_CHECK_RESULT VkResult
1796XRT_CHECK_RESULT VkResult
1799#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1806XRT_CHECK_RESULT VkResult
1807vk_create_timeline_semaphore_and_native(
struct vk_bundle *vk,
1808 VkSemaphore *out_sem,
1824XRT_CHECK_RESULT VkResult
1827#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1834XRT_CHECK_RESULT VkResult
1845#if defined(VK_EXT_calibrated_timestamps) || defined(XRT_DOXYGEN)
1865XRT_CHECK_RESULT VkResult
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.
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.