40#define VK_BUNDLE_MAX_QUEUES 3
56#define VK_NULL_QUEUE_PAIR \
57 XRT_C11_COMPOUND(struct vk_queue_pair) \
59 .family_index = VK_QUEUE_FAMILY_IGNORED, .index = (uint32_t)-1, \
87 VkPhysicalDevice physical_device;
88 int physical_device_index;
120#if defined(VK_KHR_video_encode_queue)
132#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_WIN32_HANDLE)
133 bool color_image_import_opaque_win32;
134 bool color_image_export_opaque_win32;
135 bool depth_image_import_opaque_win32;
136 bool depth_image_export_opaque_win32;
138 bool color_image_import_d3d11;
139 bool color_image_export_d3d11;
140 bool depth_image_import_d3d11;
141 bool depth_image_export_d3d11;
143#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
144 bool color_image_import_opaque_fd;
145 bool color_image_export_opaque_fd;
146 bool depth_image_import_opaque_fd;
147 bool depth_image_export_opaque_fd;
149#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER)
150 bool color_image_import_opaque_fd;
151 bool color_image_export_opaque_fd;
152 bool depth_image_import_opaque_fd;
153 bool depth_image_export_opaque_fd;
155 bool color_image_import_ahardwarebuffer;
156 bool color_image_export_ahardwarebuffer;
157 bool depth_image_import_ahardwarebuffer;
158 bool depth_image_export_ahardwarebuffer;
161#if defined(XRT_GRAPHICS_SYNC_HANDLE_IS_FD)
163 bool fence_opaque_fd;
165 bool binary_semaphore_sync_fd;
166 bool binary_semaphore_opaque_fd;
168 bool timeline_semaphore_sync_fd;
169 bool timeline_semaphore_opaque_fd;
170#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE)
171 bool fence_win32_handle;
173 bool binary_semaphore_d3d12_fence;
174 bool binary_semaphore_win32_handle;
176 bool timeline_semaphore_d3d12_fence;
177 bool timeline_semaphore_win32_handle;
179#error "Need port for fence sync handles checkers"
184#include "vk_helpers_h_ext.h.inc"
250 VkDebugReportCallbackEXT debug_report_cb;
252 VkPhysicalDeviceMemoryProperties device_memory_props;
255 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
256 PFN_vkCreateInstance vkCreateInstance;
257 PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
260#include "vk_helpers_h_funcs.h.inc"
266 VkDeviceMemory memory;
295#define VK_CHK_ONLY_PRINT(RET, FUNC_STR) \
297 VkResult _ret = RET; \
298 if (_ret != VK_SUCCESS) { \
299 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
319#define VK_CHK_AND_RET(RET, FUNC_STR) \
321 VkResult _ret = RET; \
322 if (_ret != VK_SUCCESS) { \
323 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
345#define VK_CHK_WITH_RET(RET, FUNC_STR, TO_RET) \
347 VkResult _ret = RET; \
348 if (_ret != VK_SUCCESS) { \
349 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
372#define VK_CHK_WITH_GOTO(RET, FUNC_STR, GOTO) \
374 VkResult _ret = RET; \
375 if (_ret != VK_SUCCESS) { \
376 vk_print_result(vk, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \
382#define XVK_CHK_AND_RET(...) U_LOG_CHK_AND_RET(vk->log_level, __VA_ARGS__)
384#define XVK_CHK_WITH_GOTO(...) U_LOG_CHK_WITH_GOTO(vk->log_level, __VA_ARGS__)
386#define XVK_CHK_WITH_RET(...) U_LOG_CHK_WITH_RET(vk->log_level, __VA_ARGS__)
388#define XVK_CHK_ONLY_PRINT(...) U_LOG_CHK_ONLY_PRINT(vk->log_level, __VA_ARGS__)
390#define XVK_CHK_ALWAYS_RET(...) U_LOG_CHK_ALWAYS_RET(vk->log_level, __VA_ARGS__)
393vk_append_to_pnext_chain(VkBaseInStructure *head, VkBaseInStructure *new_struct)
395 assert(new_struct->pNext == NULL);
397 new_struct->pNext = head->pNext;
398 head->pNext = new_struct;
408#define VK_TRACE(d, ...) U_LOG_IFL_T(d->log_level, __VA_ARGS__)
409#define VK_DEBUG(d, ...) U_LOG_IFL_D(d->log_level, __VA_ARGS__)
410#define VK_INFO(d, ...) U_LOG_IFL_I(d->log_level, __VA_ARGS__)
411#define VK_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__)
412#define VK_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__)
421#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
437#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) \
439 if ((VK)->has_EXT_debug_utils) { \
440 XRT_MAYBE_UNUSED TYPE _thing = (TYPE)(OBJ); \
441 vk_name_object(VK, VK_OBJECT_TYPE_##SUFFIX, (uint64_t)OBJ, NAME); \
448#define VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ)
467#define VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ) \
469 XRT_MAYBE_UNUSED TYPE _thing = (TYPE)(OBJ); \
475#define VK_NAME_INSTANCE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkInstance, (uintptr_t)OBJ)
476#define VK_NAME_PHYSICAL_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPhysicalDevice, PHYSICAL_DEVICE, (uintptr_t)OBJ, NAME)
477#define VK_NAME_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDevice, DEVICE, (uintptr_t)OBJ, NAME)
478#define VK_NAME_QUEUE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueue, QUEUE, (uintptr_t)OBJ, NAME)
479#define VK_NAME_COMMAND_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandBuffer, COMMAND_BUFFER, (uintptr_t)OBJ, NAME)
481#define VK_NAME_SEMAPHORE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSemaphore, SEMAPHORE, OBJ, NAME)
482#define VK_NAME_FENCE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFence, FENCE, OBJ, NAME)
483#define VK_NAME_DEVICE_MEMORY(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDeviceMemory, DEVICE_MEMORY, OBJ, NAME)
484#define VK_NAME_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBuffer, BUFFER, OBJ, NAME)
485#define VK_NAME_IMAGE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImage, IMAGE, OBJ, NAME)
486#define VK_NAME_EVENT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkEvent, EVENT, OBJ, NAME)
487#define VK_NAME_QUERY_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueryPool, QUERY_POOL, OBJ, NAME)
488#define VK_NAME_BUFFER_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBufferView, BUFFER_VIEW, OBJ, NAME)
489#define VK_NAME_IMAGE_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImageView, IMAGE_VIEW, OBJ, NAME)
490#define VK_NAME_SHADER_MODULE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkShaderModule, SHADER_MODULE, OBJ, NAME)
491#define VK_NAME_PIPELINE_CACHE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineCache, PIPELINE_CACHE, OBJ, NAME)
492#define VK_NAME_PIPELINE_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineLayout, PIPELINE_LAYOUT, OBJ, NAME)
493#define VK_NAME_RENDER_PASS(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkRenderPass, RENDER_PASS, OBJ, NAME)
494#define VK_NAME_PIPELINE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipeline, PIPELINE, OBJ, NAME)
495#define VK_NAME_DESCRIPTOR_SET_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorSetLayout, DESCRIPTOR_SET_LAYOUT, OBJ, NAME)
496#define VK_NAME_SAMPLER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSampler, SAMPLER, OBJ, NAME)
497#define VK_NAME_DESCRIPTOR_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorPool, DESCRIPTOR_POOL, OBJ, NAME)
498#define VK_NAME_DESCRIPTOR_SET(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkDescriptorSet, OBJ)
499#define VK_NAME_FRAMEBUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFramebuffer, FRAMEBUFFER, OBJ, NAME)
500#define VK_NAME_COMMAND_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandPool, COMMAND_POOL, OBJ, NAME)
502#define VK_NAME_SURFACE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkSurfaceKHR, OBJ)
503#define VK_NAME_SWAPCHAIN(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSwapchainKHR, SWAPCHAIN_KHR, OBJ, NAME)
521 const char *layer_name,
522 uint32_t *out_prop_count,
523 VkExtensionProperties **out_props);
533 uint32_t *out_physical_device_count,
534 VkPhysicalDevice **out_physical_devices);
544 VkPhysicalDevice physical_device,
545 const char *layer_name,
546 uint32_t *out_prop_count,
547 VkExtensionProperties **out_props);
559 VkPhysicalDevice physical_device,
560 uint32_t *out_prop_count,
561 VkQueueFamilyProperties **out_props);
563#if defined(VK_KHR_surface) || defined(XRT_DOXYGEN)
572 VkSurfaceKHR surface,
573 uint32_t *out_format_count,
574 VkSurfaceFormatKHR **out_formats);
583 VkSurfaceKHR surface,
584 uint32_t *out_present_mode_count,
585 VkPresentModeKHR **out_present_modes);
588#if defined(VK_KHR_swapchain) || defined(XRT_DOXYGEN)
596 VkSwapchainKHR swapchain,
597 uint32_t *out_image_count,
598 VkImage **out_images);
601#if defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(XRT_DOXYGEN)
609 VkPhysicalDevice physical_device,
610 uint32_t *out_prop_count,
611 VkDisplayPropertiesKHR **out_props);
620 VkPhysicalDevice physical_device,
621 uint32_t *out_prop_count,
622 VkDisplayPlanePropertiesKHR **out_props);
632 VkPhysicalDevice physical_device,
633 VkDisplayKHR display,
634 uint32_t *out_prop_count,
635 VkDisplayModePropertiesKHR **out_props);
722 bool shader_image_gather_extended;
723 bool shader_storage_image_write_without_format;
724 bool null_descriptor;
725 bool timeline_semaphore;
726 bool synchronization_2;
727 bool ext_fmt_resolve;
728 bool storage_buffer_8bit_access;
733 bool video_maintenance_1;
734 bool image_tiling_control;
745XRT_CHECK_RESULT VkResult
749 bool realtime_priority,
776 os_mutex_lock(&q->
mutex);
783 return os_mutex_trylock(&q->
mutex);
790 os_mutex_unlock(&q->
mutex);
799XRT_CHECK_RESULT VkResult
801 PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
803 VkPhysicalDevice physical_device,
805 uint32_t queue_family_index,
806 uint32_t queue_index,
807 bool external_fence_fd_enabled,
808 bool external_semaphore_fd_enabled,
809 bool timeline_semaphore_enabled,
810 bool image_format_list_enabled,
811 bool debug_utils_enabled,
825vk_get_memory_type(
struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFlags memory_props, uint32_t *out_type_id);
859XRT_CHECK_RESULT VkResult
862 const VkMemoryRequirements *requirements,
863 const void *pNext_for_allocate,
864 const char *caller_name,
865 VkDeviceMemory *out_mem);
888XRT_CHECK_RESULT VkResult
893 VkDeviceMemory *out_mem);
908XRT_CHECK_RESULT VkResult
910 VkDeviceMemory device_memory,
921 VkImageUsageFlags usage,
922 VkDeviceMemory *out_mem,
933 struct vk_bundle *vk, VkExtent2D
extent, VkImageUsageFlags usage, VkDeviceMemory *out_mem, VkImage *out_image);
943 VkImageTiling image_tiling,
944 VkImageUsageFlags image_usage_flags,
945 VkMemoryPropertyFlags memory_property_flags,
946 VkDeviceMemory *out_mem,
953vk_create_sampler(
struct vk_bundle *vk, VkSamplerAddressMode clamp_mode, VkSampler *out_sampler);
968 VkImageViewType type,
970 VkImageSubresourceRange subresource_range,
971 VkImageView *out_view);
977vk_create_view_swizzle(
struct vk_bundle *vk,
979 VkImageViewType type,
981 VkImageSubresourceRange subresource_range,
982 VkComponentMapping components,
983 VkImageView *out_view);
994 VkImageViewType type,
996 VkImageUsageFlags image_usage,
997 VkImageSubresourceRange subresource_range,
998 VkComponentMapping components,
999 VkImageView *out_view);
1010 VkImageViewType type,
1012 VkImageUsageFlags image_usage,
1013 VkImageSubresourceRange subresource_range,
1014 VkImageView *out_view);
1024vk_init_descriptor_pool(
struct vk_bundle *vk,
1025 const VkDescriptorPoolSize *pool_sizes,
1026 uint32_t pool_size_count,
1028 VkDescriptorPool *out_descriptor_pool);
1031vk_allocate_descriptor_sets(
struct vk_bundle *vk,
1032 VkDescriptorPool descriptor_pool,
1034 const VkDescriptorSetLayout *set_layout,
1035 VkDescriptorSet *sets);
1047 VkBufferUsageFlags usage,
1048 VkMemoryPropertyFlags properties,
1049 VkBuffer *out_buffer,
1050 VkDeviceMemory *out_mem);
1056vk_update_buffer(
struct vk_bundle *vk,
float *buffer,
size_t buffer_size, VkDeviceMemory memory);
1074 VkCommandBuffer cmd_buffer,
1076 VkAccessFlags src_access_mask,
1077 VkAccessFlags dst_access_mask,
1078 VkImageLayout old_image_layout,
1079 VkImageLayout new_image_layout,
1080 VkPipelineStageFlags src_stage_mask,
1081 VkPipelineStageFlags dst_stage_mask,
1082 VkImageSubresourceRange subresource_range);
1093 VkCommandBuffer cmd_buffer,
1095 VkAccessFlags src_access_mask,
1096 VkAccessFlags dst_access_mask,
1097 VkImageLayout old_layout,
1098 VkImageLayout new_layout,
1099 VkImageSubresourceRange subresource_range);
1101#if defined(VK_EXT_debug_utils) || defined(XRT_DOXYGEN)
1145 VkDescriptorPool *out_descriptor_pool);
1154 VkDescriptorPool descriptor_pool,
1155 VkDescriptorSetLayout descriptor_layout,
1156 VkDescriptorSet *out_descriptor_set);
1165 VkDescriptorSetLayout descriptor_set_layout,
1166 VkPipelineLayout *out_pipeline_layout);
1183 VkPipelineCache pipeline_cache,
1184 VkShaderModule shader,
1185 VkPipelineLayout pipeline_layout,
1186 const VkSpecializationInfo *specialization_info,
1187 VkPipeline *out_compute_pipeline);
1202XRT_CHECK_RESULT
bool
1215XRT_CHECK_RESULT VkResult
1233XRT_CHECK_RESULT VkResult
1253XRT_CHECK_RESULT VkResult
1256#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1263XRT_CHECK_RESULT VkResult
1264vk_create_timeline_semaphore_and_native(
struct vk_bundle *vk,
1265 VkSemaphore *out_sem,
1281XRT_CHECK_RESULT VkResult
1284#if defined(VK_KHR_timeline_semaphore) || defined(XRT_DOXYGEN)
1291XRT_CHECK_RESULT VkResult
1302#if defined(VK_EXT_calibrated_timestamps) || defined(VK_KHR_calibrated_timestamps) || defined(XRT_DOXYGEN)
1323XRT_CHECK_RESULT VkResult
1340XRT_CHECK_RESULT VkResult
1342 VkTimeDomainEXT source_domain,
1344 uint64_t *in_out_timestamps);
1360XRT_CHECK_RESULT VkResult
1362 VkTimeDomainEXT target_domain,
1364 uint64_t *in_out_timestamps);
1366#if defined(VK_EXT_present_timing) || defined(XRT_DOXYGEN)
1379XRT_CHECK_RESULT VkResult
1381 VkTimeDomainEXT source_domain,
1382 const VkSwapchainCalibratedTimestampInfoEXT *swapchain,
1384 uint64_t *in_out_timestamps);
1397XRT_CHECK_RESULT VkResult
1399 VkTimeDomainEXT target_domain,
1400 const VkSwapchainCalibratedTimestampInfoEXT *swapchain,
1402 uint64_t *in_out_timestamps);
u_logging_level
Logging level enum.
Definition u_logging.h:45
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:103
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:268
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.
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:1080
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:1320
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:231
VkResult vk_create_view_swizzle_usage(struct vk_bundle *vk, VkImage image, VkImageViewType type, VkFormat format, VkImageUsageFlags image_usage, VkImageSubresourceRange subresource_range, VkComponentMapping components, VkImageView *out_view)
Creates a swizzled image view with a specific subset of usage, useful for a mutable image where one f...
Definition vk_helpers.c:836
XRT_CHECK_RESULT VkResult vk_create_device(struct vk_bundle *vk, int forced_index, bool only_compute, bool realtime_priority, struct u_extension_list *required_device_ext_list, struct u_extension_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:929
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:1043
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:210
void vk_get_physical_device_queue_family_properties(struct vk_bundle *vk, VkPhysicalDevice physical_device, uint32_t *out_prop_count, VkQueueFamilyProperties **out_props)
Get the queue family properties of the given VkPhysicalDevice, note this function does not return a r...
Definition vk_enumerate.c:128
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:923
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:1301
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:384
XRT_CHECK_RESULT VkResult vk_convert_device_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...
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:41
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:80
XRT_CHECK_RESULT VkResult vk_convert_host_timestamps_to_swapchain(struct vk_bundle *vk, VkTimeDomainEXT target_domain, const VkSwapchainCalibratedTimestampInfoEXT *swapchain, uint32_t count, uint64_t *in_out_timestamps)
Convert host CPU timestamps into swapchain timestamps, in nanoseconds.
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
XRT_CHECK_RESULT VkResult vk_convert_timestamps_to_host(struct vk_bundle *vk, VkTimeDomainEXT source_domain, uint32_t count, uint64_t *in_out_timestamps)
Convert timestamps from an arbitrary domain into host CPU timestamps, in nanoseconds.
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:56
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:878
VkResult vk_check_required_instance_extensions(struct vk_bundle *vk, struct u_extension_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:106
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:91
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.
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:64
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:693
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:55
XRT_CHECK_RESULT VkResult vk_convert_timestamps_from_host(struct vk_bundle *vk, VkTimeDomainEXT target_domain, uint32_t count, uint64_t *in_out_timestamps)
Convert timestamps from host CPU domain into an arbitrary domain, in nanoseconds.
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.
VkResult vk_init_mutex(struct vk_bundle *vk)
Initialize mutexes in the vk_bundle.
Definition vk_bundle_init.c:1285
XRT_CHECK_RESULT VkResult vk_convert_swapchain_timestamps_to_host(struct vk_bundle *vk, VkTimeDomainEXT source_domain, const VkSwapchainCalibratedTimestampInfoEXT *swapchain, uint32_t count, uint64_t *in_out_timestamps)
Convert swapchain timestamps into host CPU timestamps, in nanoseconds.
VkResult vk_build_instance_extensions(struct vk_bundle *vk, struct u_extension_list *required_instance_ext_list, struct u_extension_list *optional_instance_ext_list, struct u_extension_list **out_instance_ext_list)
Build instance extensions from required and optional instance extensions.
Definition vk_bundle_init.c:92
Wrapper around OS threading native functions.
Definition t_rift_blobwatch.c:118
A wrapper around a native mutex.
Definition os_threading.h:69
Definition u_extension_list.cpp:33
Definition vk_helpers.h:264
Definition vk_helpers.h:63
uint32_t family_index
The queue family index.
Definition vk_helpers.h:67
VkQueue queue
The Vulkan queue handle.
Definition vk_helpers.h:65
struct os_mutex mutex
The queue mutex -.
Definition vk_helpers.h:71
uint32_t index
The queue (instance) index.
Definition vk_helpers.h:69
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition vk_helpers.h:82
uint32_t max_bound_descriptor_sets
Maximum number of descriptor sets that can be simultaneously used by a pipeline.
Definition vk_helpers.h:228
bool synchronization_2
Was synchronization2 requested, available, and enabled?
Definition vk_helpers.h:201
uint32_t max_descriptor_set_samplers
Maximum number of samplers that can be included in a pipeline layout.
Definition vk_helpers.h:231
bool timeline_semaphore
Were timeline semaphore requested, available, and enabled?
Definition vk_helpers.h:198
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:237
bool present_id
Was KHR_present_id requested, available, and enabled?
Definition vk_helpers.h:204
bool video_maintenance_1
Was KHR_video_maintenance1 requested, available, and enabled?
Definition vk_helpers.h:216
bool present_id2
Was KHR_present_id2 requested, available, and enabled?
Definition vk_helpers.h:207
uint32_t timestamp_valid_bits
Valid bits in the queue selected.
Definition vk_helpers.h:195
uint32_t max_sampler_allocation_count
Maximum number of sampler objects, as created by vkCreateSampler, which can simultaneously exist on.
Definition vk_helpers.h:225
uint32_t max_descriptor_set_sampled_images
Maximum number of sampled images that can be included in a pipeline layout.
Definition vk_helpers.h:234
uint32_t max_per_stage_descriptor_storage_images
Per stage limit on storage images.
Definition vk_helpers.h:243
bool is_tegra
Is the GPU a tegra device.
Definition vk_helpers.h:247
struct vk_bundle_queue * main_queue
Main queue for general work.
Definition vk_helpers.h:109
bool timestamp_compute_and_graphics
Are timestamps available for compute and graphics queues?
Definition vk_helpers.h:189
bool present_wait
Was KHR_present_wait requested, available, and enabled?
Definition vk_helpers.h:210
bool present_wait2
Was KHR_present_wait2 requested, available, and enabled?
Definition vk_helpers.h:213
struct vk_bundle_queue queues[3]
queues - a free list of unique queues
Definition vk_helpers.h:99
uint32_t max_per_stage_descriptor_sampled_images
Per stage limit on sampled images (includes combined).
Definition vk_helpers.h:240
bool image_tiling_control
Was EXT_image_tiling_control requested, available, and enabled?
Definition vk_helpers.h:219
float timestamp_period
Nanoseconds per gpu tick.
Definition vk_helpers.h:192
struct vk_bundle_queue * graphics_queue
Graphics queue.
Definition vk_helpers.h:118
Arguments to vk_create_descriptor_pool function.
Definition vk_helpers.h:1124
uint32_t descriptor_count
The max count of created descriptors.
Definition vk_helpers.h:1131
uint32_t uniform_per_descriptor_count
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.
Definition vk_helpers.h:1125
bool freeable
Are descriptors freeable, or must vkResetDescriptorPool be used.
Definition vk_helpers.h:1134
uint32_t sampler_per_descriptor_count
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER.
Definition vk_helpers.h:1126
uint32_t storage_image_per_descriptor_count
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE.
Definition vk_helpers.h:1127
uint32_t storage_buffer_per_descriptor_count
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER.
Definition vk_helpers.h:1128
Used to enable device features as a argument vk_create_device.
Definition vk_helpers.h:721
Definition vk_helpers.h:49
uint32_t index
The queue (instance) index.
Definition vk_helpers.h:53
uint32_t family_index
The queue family index.
Definition vk_helpers.h:51
A single image of a swapchain based on native buffer handles.
Definition xrt_compositor.h:2102
Swapchain creation info.
Definition xrt_compositor.h:882
A collection of strings, like a list of extensions to enable.
Basic logging functionality.
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_fill_in_has_instance_extensions(struct vk_bundle *vk, struct u_extension_list *ext_list)
Fills in has_* in vk_bundle given a string of prefiltered instance extensions.
Definition vk_bundle_init.c:138
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
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
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
Pretty printing various Vulkan things.
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.