Monado OpenXR Runtime
|
Vulkan helper structs and functions. More...
Files | |
file | vk_bundle_init.c |
Functions to init various parts of the vk_bundle. | |
file | vk_cmd.c |
Command pool helpers. | |
file | vk_cmd.h |
Command buffer helpers. | |
file | vk_cmd_pool.c |
Command pool helpers. | |
file | vk_cmd_pool.h |
Command pool helpers. | |
file | vk_compositor_flags.c |
Flags helpers for compositor swapchain images. | |
file | vk_debug.c |
Debug helper code. | |
file | vk_documentation.h |
Header with just documentation. | |
file | vk_enumerate.c |
Vulkan enumeration helpers code. | |
file | vk_function_loaders.c |
Functions to fill in the functions. | |
file | vk_helpers.c |
Common Vulkan code. | |
file | vk_helpers.h |
Common Vulkan code header. | |
file | vk_image_allocator.c |
Vulkan image allocator helper. | |
file | vk_image_allocator.h |
Vulkan image allocator helper. | |
file | vk_image_readback_to_xf_pool.c |
Pool to read back VkImages from the gpu. | |
file | vk_image_readback_to_xf_pool.h |
Pool to read back VkImages from the gpu. | |
file | vk_mini_helpers.h |
Super small defines that makes writing Vulkan code smaller. | |
file | vk_print.c |
Printing helper code. | |
file | vk_state_creators.c |
Vulkan state creators helpers. | |
file | vk_surface_info.c |
Helper for getting information from a VkSurfaceKHR. | |
file | vk_surface_info.h |
Helper for getting information from a VkSurfaceKHR. | |
file | vk_sync_objects.c |
Vulkan sync primitives code. | |
file | vk_time.c |
Vulkan timestamp helpers. | |
Data Structures | |
struct | vk_cmd_first_mip_image |
A similar struct to VkImageSubresourceRange and VkImageSubresourceLayers expect for this it's implied that it's only the first mip-level and only one array layer used for the operation. More... | |
struct | vk_cmd_copy_image_info |
Argument struct for vk_cmd_copy_image_locked. More... | |
struct | vk_cmd_blit_image_info |
Argument struct for vk_cmd_blit_image_locked. More... | |
struct | vk_cmd_blit_images_side_by_side_info |
Argument struct for vk_cmd_blit_images_side_by_side_locked. More... | |
struct | vk_cmd_pool |
Small helper to manage lock around a command pool. More... | |
struct | vk_bundle |
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code. More... | |
struct | vk_device_features |
Used to enable device features as a argument vk_create_device. More... | |
struct | vk_image |
struct | vk_image_collection |
Macros | |
#define | VK_CHK_AND_RET(RET, FUNC_STR) |
This define will error if RET is not VK_SUCCESS , printing out that the FUNC_STR string has failed, then returns RET . More... | |
#define | VK_CHK_WITH_RET(RET, FUNC_STR, TO_RET) |
This define will error if RET is not VK_SUCCESS , printing out that the FUNC_STR string has failed, then returns TO_RET . More... | |
#define | VK_CHK_WITH_GOTO(RET, FUNC_STR, GOTO) |
This define will error if RET is not VK_SUCCESS , printing out that the FUNC_STR string has failed, then goto GOTO . More... | |
#define | VK_NAME_OBJ(VK, TYPE, SUFFIX, OBJ, NAME) |
Small helper for vk_name_object that makes use of pre-process to avoid writing out long type names. More... | |
#define | VK_NAME_OBJ_DISABLED(VK, TYPE, OBJ) |
Some combinations of Vulkan implementation and types are broken, we still want type safety so we have this define. More... | |
#define | VK_CSCI_FORMATS(THING_COLOR, THING_DS, THING_D, THING_S) |
Helper for all of the supported formats to check support for. More... | |
#define | D(TYPE, THING) |
Calls vkDestroy##TYPE on THING if it is not VK_NULL_HANDLE , sets it to VK_NULL_HANDLE afterwards. More... | |
#define | DF(TYPE, THING) |
Calls vkFree##TYPE on THING` if it is not VK_NULL_HANDLE , sets it to VK_NULL_HANDLE afterwards. More... | |
Functions | |
XRT_CHECK_RESULT VkResult | vk_cmd_create_cmd_buffer_locked (struct vk_bundle *vk, VkCommandPool pool, VkCommandBuffer *out_cmd_buffer) |
Create a command buffer, the pool must be locked or ensured that only this thread is accessing it. More... | |
XRT_CHECK_RESULT VkResult | vk_cmd_create_and_begin_cmd_buffer_locked (struct vk_bundle *vk, VkCommandPool pool, VkCommandBufferUsageFlags flags, VkCommandBuffer *out_cmd_buffer) |
Create and begin a command buffer, the pool must be locked or ensured that only this thread is accessing it. More... | |
XRT_CHECK_RESULT VkResult | vk_cmd_submit_locked (struct vk_bundle *vk, uint32_t count, const VkSubmitInfo *infos, VkFence fence) |
Very small helper to submit a command buffer, the _locked suffix refers to the command pool not the queue, the queue lock will be taken during the queue submit call, then released. More... | |
XRT_CHECK_RESULT VkResult | vk_cmd_end_submit_wait_and_free_cmd_buffer_locked (struct vk_bundle *vk, VkCommandPool pool, VkCommandBuffer cmd_buffer) |
A do everything command buffer submission function, the _locked suffix refers to the command pool not the queue, the queue lock will be taken during the queue submit call, then released. More... | |
void | vk_cmd_copy_image_locked (struct vk_bundle *vk, VkCommandBuffer cmd_buffer, const struct vk_cmd_copy_image_info *info) |
Performs a copy of a image into a destination image, also does needed barrier operation needed to get images ready for transfer operations. More... | |
void | vk_cmd_blit_image_locked (struct vk_bundle *vk, VkCommandBuffer cmd_buffer, const struct vk_cmd_blit_image_info *info) |
Performs a blit of a image into a destination image, also does needed barrier operation needed to get images ready for transfer operations. More... | |
void | vk_cmd_blit_images_side_by_side_locked (struct vk_bundle *vk, VkCommandBuffer cmd_buffer, const struct vk_cmd_blit_images_side_by_side_info *info) |
Performs a blit of two images to side by side on a destination image, also does needed barrier operation needed to get images ready for transfer operations. More... | |
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. More... | |
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. More... | |
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 enabled. More... | |
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_bundle has that level enabled. More... | |
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. More... | |
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. More... | |
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 , NULL means the "base" driver physical device. More... | |
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 , not VkFormat . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
VkResult | vk_get_loader_functions (struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g) |
Can be done on a completely bare bundle. More... | |
VkResult | vk_get_instance_functions (struct vk_bundle *vk) |
Requires a instance to have been created and set on the bundle. More... | |
VkResult | vk_get_device_functions (struct vk_bundle *vk) |
Requires a device to have been created and set on the bundle. More... | |
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 extensions missing, returns VK_ERROR_EXTENSION_NOT_PRESENT if not all extensions are supported. More... | |
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. More... | |
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. More... | |
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. More... | |
VkResult | vk_init_mutex (struct vk_bundle *vk) |
Initialize mutexes in the vk_bundle. More... | |
VkResult | vk_deinit_mutex (struct vk_bundle *vk) |
De-initialize mutexes in the vk_bundle. More... | |
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 Compositor client code. More... | |
bool | vk_get_memory_type (struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFlags memory_props, uint32_t *out_type_id) |
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. More... | |
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. More... | |
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 Linux) equivalent. More... | |
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. More... | |
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 that formats. More... | |
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. More... | |
VkResult | vk_create_sampler (struct vk_bundle *vk, VkSamplerAddressMode clamp_mode, VkSampler *out_sampler) |
VkResult | vk_create_view (struct vk_bundle *vk, VkImage image, VkImageViewType type, VkFormat format, VkImageSubresourceRange subresource_range, VkImageView *out_view) |
VkResult | vk_create_view_swizzle (struct vk_bundle *vk, VkImage image, VkImageViewType type, VkFormat format, VkImageSubresourceRange subresource_range, VkComponentMapping components, VkImageView *out_view) |
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 not support all usages defined by the image. More... | |
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 the pool that cmd_buffer is from or ensure it is externally synchronized. More... | |
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, the calling code will need hold the lock for the pool that cmd_buffer is from or ensure it is externally synchronized. More... | |
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. More... | |
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, in other words will the below functions work. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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_native for more details. More... | |
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 nanoseconds, same time domain as os_monotonic_get_ns. More... | |
VkResult | vk_ic_allocate (struct vk_bundle *vk, const struct xrt_swapchain_create_info *xscci, uint32_t image_count, struct vk_image_collection *out_vkic) |
Allocates image(s) using the information specified in the swapchain create info. More... | |
VkResult | vk_ic_from_natives (struct vk_bundle *vk, const struct xrt_swapchain_create_info *xscci, struct xrt_image_native *native_images, uint32_t image_count, struct vk_image_collection *out_vkic) |
Imports and set images from the given FDs. More... | |
void | vk_ic_destroy (struct vk_bundle *vk, struct vk_image_collection *vkic) |
Free all images created on this image collection, doesn't free the struct itself so the caller needs to ensure that. More... | |
VkResult | vk_ic_get_handles (struct vk_bundle *vk, struct vk_image_collection *vkic, uint32_t max_handles, xrt_graphics_buffer_handle_t *out_handles) |
Get the native handles (FDs on desktop Linux) for the images, this is a all or nothing function. More... | |
Vulkan helper structs and functions.
#define D | ( | TYPE, | |
THING | |||
) |
#include <auxiliary/vk/vk_mini_helpers.h>
Calls vkDestroy##TYPE
on THING
if it is not VK_NULL_HANDLE
, sets it to VK_NULL_HANDLE
afterwards.
The implicit argument vk
will be used to look up the function, and vk->device
will be used as the device.
TYPE | The type of the thing to be destroyed. |
THING | Object to be destroyed. |
#define DF | ( | TYPE, | |
THING | |||
) |
#include <auxiliary/vk/vk_mini_helpers.h>
Calls vkFree##TYPE
on THING`
if it is not VK_NULL_HANDLE
, sets it to VK_NULL_HANDLE
afterwards.
The implicit argument vk
will be used to look up the function, and vk->device
will be used as the device.
TYPE | The type of the thing to be freed. |
THING | Object to be freed. |
#define VK_CHK_AND_RET | ( | RET, | |
FUNC_STR | |||
) |
#include <auxiliary/vk/vk_helpers.h>
This define will error if RET
is not VK_SUCCESS
, printing out that the FUNC_STR
string has failed, then returns RET
.
The implicit argument vk
will be used for the vk_print_result call.
Use this macro when your function returns a VkResult
.
RET | The VkResult to check. |
FUNC_STR | String literal with the function name, used for logging. |
#define VK_CHK_WITH_GOTO | ( | RET, | |
FUNC_STR, | |||
GOTO | |||
) |
#include <auxiliary/vk/vk_helpers.h>
This define will error if RET
is not VK_SUCCESS
, printing out that the FUNC_STR
string has failed, then goto GOTO
.
The implicit argument vk
will be used for the vk_print_result call.
Use this macro when your function needs to goto
some cleanup code and return from there.
RET | The VkResult to check. |
FUNC_STR | String literal with the function name, used for logging. |
GOTO | Label to jump to, upon error |
#define VK_CHK_WITH_RET | ( | RET, | |
FUNC_STR, | |||
TO_RET | |||
) |
#include <auxiliary/vk/vk_helpers.h>
This define will error if RET
is not VK_SUCCESS
, printing out that the FUNC_STR
string has failed, then returns TO_RET
.
The implicit argument vk
will be used for the vk_print_result call.
Use this macro when your function doesn't return a VkResult
.
RET | The VkResult to check. |
FUNC_STR | String literal with the function name, used for logging. |
TO_RET | Value to return, upon error |
#define VK_CSCI_FORMATS | ( | THING_COLOR, | |
THING_DS, | |||
THING_D, | |||
THING_S | |||
) |
#include <auxiliary/vk/vk_helpers.h>
Helper for all of the supported formats to check support for.
These are the available formats we will expose to our clients.
In order of what we prefer. Start with a SRGB format that works on both OpenGL and Vulkan. The two linear formats that works on both OpenGL and Vulkan. A SRGB format that only works on Vulkan. The last two formats should not be used as they are linear but doesn't have enough bits to express it without resulting in banding.
The format VK_FORMAT_A2B10G10R10_UNORM_PACK32 is not listed since 10 bits are not considered enough to do linear colors without banding. If there was a sRGB variant of it then we would have used it instead but there isn't. Since it's not a popular format it's best not to list it rather then listing it and people falling into the trap. The absolute minimum is R11G11B10, but is a really weird format so we are not exposing it.
CSCI = Compositor SwapChain Images.
#define VK_NAME_OBJ | ( | VK, | |
TYPE, | |||
SUFFIX, | |||
OBJ, | |||
NAME | |||
) |
#include <auxiliary/vk/vk_helpers.h>
Small helper for vk_name_object that makes use of pre-process to avoid writing out long type names.
#define VK_NAME_OBJ_DISABLED | ( | VK, | |
TYPE, | |||
OBJ | |||
) |
#include <auxiliary/vk/vk_helpers.h>
Some combinations of Vulkan implementation and types are broken, we still want type safety so we have this define.
Examples of broken combinations:
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Allocate memory for an image and bind it to that image.
Handles the following steps:
If this fails, it cleans up the VkDeviceMemory.
vk | Vulkan bundle |
image | The VkImage to allocate for and bind. |
requirements | Memory requirements used for finding the memory type and the size. |
pNext_for_allocate | (Optional) a pointer to use in the pNext chain of VkMemoryAllocateInfo. |
caller_name | Used for error printing, this function is called from various sources and takes next chains that could influence the result of various calls inside of it. Since it's up to this function to print any errors it will add the caller name to error messages. |
out_mem | Output parameter: will be set to the allocated memory if everything succeeds. Not modified if there is an error. |
out_size | (Optional) pointer to receive the value of VkMemoryRequirements::size. |
If this fails, you may want to destroy your VkImage as well, since this routine is usually used in combination with vkCreateImage.
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Only requires vk_get_loader_functions to have been called.
References u_string_list::u_string_list_create_from_list(), u_string_list::u_string_list_get_data(), u_string_list::u_string_list_get_size(), and vk_enumerate_instance_extensions_properties().
#include <auxiliary/vk/vk_helpers.h>
Is there a good likelihood that the import/export of a timeline semaphore will succeed, in other words will the below functions work.
References vk_bundle::timeline_semaphore.
VkResult vk_check_required_instance_extensions | ( | struct vk_bundle * | vk, |
struct u_string_list * | required_instance_ext_list | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Check if the required instance extensions are supported, if not print error message with all extensions missing, returns VK_ERROR_EXTENSION_NOT_PRESENT if not all extensions are supported.
References vk_enumerate_instance_extensions_properties().
void vk_cmd_blit_image_locked | ( | struct vk_bundle * | vk, |
VkCommandBuffer | cmd_buffer, | ||
const struct vk_cmd_blit_image_info * | info | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Performs a blit of a image into a destination image, also does needed barrier operation needed to get images ready for transfer operations.
Images will be left in the layout and pipeline needed for transfers.
References ARRAY_SIZE.
void vk_cmd_blit_images_side_by_side_locked | ( | struct vk_bundle * | vk, |
VkCommandBuffer | cmd_buffer, | ||
const struct vk_cmd_blit_images_side_by_side_info * | info | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Performs a blit of two images to side by side on a destination image, also does needed barrier operation needed to get images ready for transfer operations.
Images will be left in the layout and pipeline needed for transfers.
References ARRAY_SIZE, vk_cmd_blit_images_side_by_side_info::src, and vk_cmd_blit_images_side_by_side_info::src_stage_mask.
void vk_cmd_copy_image_locked | ( | struct vk_bundle * | vk, |
VkCommandBuffer | cmd_buffer, | ||
const struct vk_cmd_copy_image_info * | info | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Performs a copy of a image into a destination image, also does needed barrier operation needed to get images ready for transfer operations.
Images will be left in the layout and pipeline needed for transfers.
References ARRAY_SIZE.
XRT_CHECK_RESULT VkResult vk_cmd_create_and_begin_cmd_buffer_locked | ( | struct vk_bundle * | vk, |
VkCommandPool | pool, | ||
VkCommandBufferUsageFlags | flags, | ||
VkCommandBuffer * | out_cmd_buffer | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Create and begin a command buffer, the pool must be locked or ensured that only this thread is accessing it.
References vk_cmd_create_cmd_buffer_locked().
XRT_CHECK_RESULT VkResult vk_cmd_create_cmd_buffer_locked | ( | struct vk_bundle * | vk, |
VkCommandPool | pool, | ||
VkCommandBuffer * | out_cmd_buffer | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Create a command buffer, the pool must be locked or ensured that only this thread is accessing it.
Referenced by vk_cmd_create_and_begin_cmd_buffer_locked().
XRT_CHECK_RESULT VkResult vk_cmd_end_submit_wait_and_free_cmd_buffer_locked | ( | struct vk_bundle * | vk, |
VkCommandPool | pool, | ||
VkCommandBuffer | cmd_buffer | ||
) |
#include <auxiliary/vk/vk_cmd.h>
A do everything command buffer submission function, the _locked
suffix refers to the command pool not the queue, the queue lock will be taken during the queue submit call, then released.
The pool must be locked or ensured that only this thread is accessing it.
cmd_buffer
to the queue, along with the fence.cmd_buffer
. Referenced by vk_cmd_pool::vk_cmd_pool_end_submit_wait_and_free_cmd_buffer_locked().
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Inserts a image barrier command specifically for GPU commands, doesn't take any locks, the calling code will need hold the lock for the pool that cmd_buffer is from or ensure it is externally synchronized.
References vk_cmd_image_barrier_locked().
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Inserts a image barrier command, doesn't take any locks, the calling code will need hold the lock for the pool that cmd_buffer is from or ensure it is externally synchronized.
Referenced by vk_cmd_image_barrier_gpu_locked().
void vk_cmd_insert_label | ( | struct vk_bundle * | vk, |
VkCommandBuffer | cmd_buffer, | ||
const char * | name | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Uses VK_EXT_debug_utils to insert debug label into a VkCommandBuffer.
In the vk_debug.c file.
XRT_CHECK_RESULT VkResult vk_cmd_submit_locked | ( | struct vk_bundle * | vk, |
uint32_t | count, | ||
const VkSubmitInfo * | infos, | ||
VkFence | fence | ||
) |
#include <auxiliary/vk/vk_cmd.h>
Very small helper to submit a command buffer, the _locked
suffix refers to the command pool not the queue, the queue lock will be taken during the queue submit call, then released.
The pool must be locked or ensured that only this thread is accessing it.
References os_mutex::os_mutex_lock(), and os_mutex::os_mutex_unlock().
Referenced by vk_cmd_pool::vk_cmd_pool_submit(), and vk_cmd_pool::vk_cmd_pool_submit_cmd_buffer_locked().
XRT_CHECK_RESULT VkResult vk_convert_timestamps_to_host_ns | ( | struct vk_bundle * | vk, |
uint32_t | count, | ||
uint64_t * | in_out_timestamps | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Convert timestamps in GPU ticks (as return by VkQueryPool timestamp queries) into host CPU nanoseconds, same time domain as os_monotonic_get_ns.
Note the timestamp needs to be in the past and not to old, this is because not all GPU has full 64 bit timer resolution. For instance a Intel GPU "only" have 36 bits of valid timestamp and a tick period 83.3333 nanosecond, equating to an epoch of 5726 seconds before overflowing. The function can handle overflows happening between the given timestamps and when it is called but only for one such epoch overflow, any more will only be treated as one such overflow. So timestamps needs to be converted reasonably soon after they have been captured.
vk | The Vulkan bundle. | |
count | Number of timestamps to be converted. | |
[in,out] | in_out_timestamps | Array of timestamps to be converted, done in place. |
Referenced by render_resources::render_resources_get_timestamps().
XRT_CHECK_RESULT VkResult vk_create_and_submit_fence_native | ( | struct vk_bundle * | vk, |
xrt_graphics_sync_handle_t * | out_native | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan fence, submits it to the default VkQueue and return its native graphics sync handle.
In case of error, out_native is not touched by the function.
See vk_create_fence_sync_from_native for ownership semantics on import.
References XRT_GRAPHICS_SYNC_HANDLE_INVALID.
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a VkDevice and initialises the VkQueue.
XRT_CHECK_RESULT VkResult vk_create_fence_sync_from_native | ( | struct vk_bundle * | vk, |
xrt_graphics_sync_handle_t | native, | ||
VkFence * | out_fence | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan fence from a native graphics sync handle.
In case of error, ownership is never transferred and the caller should close the handle themselves.
In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the native
handle may have transferred, a reference may have been added, or the Vulkan object may rely on the caller to keep the native handle alive until the Vulkan object is destroyed. Which option applies depends on the particular native handle type used.
See the corresponding Vulkan specification text: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#synchronization-fences-importing
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Helper to create a VkImage, with more options for tiling and memory storage.
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan device memory and image from a native graphics buffer handle.
In case of error, ownership is never transferred and the caller should close the handle themselves.
In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the image_native
handle may have transferred, a reference may have been added, or the Vulkan objects may rely on the caller to keep the native handle alive until the Vulkan objects are destroyed. Which option applies depends on the particular native handle type used.
See the corresponding specification texts:
References U_LOG_E, vk_csci_get_image_external_handle_type(), vk_csci_get_image_external_support(), and vk_csci_get_image_usage_flags().
VkResult vk_create_image_mutable_rgba | ( | struct vk_bundle * | vk, |
VkExtent2D | extent, | ||
VkImageUsageFlags | usage, | ||
VkDeviceMemory * | out_mem, | ||
VkImage * | out_image | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Helper to create a mutable RG88B8A8 VkImage that specializes in the two UNORM and SRGB variants of that formats.
VkResult vk_create_image_simple | ( | struct vk_bundle * | vk, |
VkExtent2D | extent, | ||
VkFormat | format, | ||
VkImageUsageFlags | usage, | ||
VkDeviceMemory * | out_mem, | ||
VkImage * | out_image | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Helper to create a VkImage.
XRT_CHECK_RESULT VkResult vk_create_semaphore_and_native | ( | struct vk_bundle * | vk, |
VkSemaphore * | out_sem, | ||
xrt_graphics_sync_handle_t * | out_native | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan semaphore and a native graphics sync handle.
In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the native
handle may have transferred, a reference may have been added, or the Vulkan object may rely on the caller to keep the native handle alive until the Vulkan object is destroyed. Which option applies depends on the particular native handle type used.
In case of error, neither out_sem
and out_native
is not touched by the function so the caller only becomes responsible for the output on success.
See the corresponding Vulkan specification text: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-semaphores
XRT_CHECK_RESULT VkResult vk_create_semaphore_from_native | ( | struct vk_bundle * | vk, |
xrt_graphics_sync_handle_t | native, | ||
VkSemaphore * | out_sem | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan semaphore from a native graphics sync handle.
In case of error, ownership is never transferred and the caller should close the handle themselves.
In case of success, the underlying Vulkan functionality's ownership semantics apply: ownership of the native
handle may have transferred, a reference may have been added, or the Vulkan object may rely on the caller to keep the native handle alive until the Vulkan object is destroyed. Which option applies depends on the particular native handle type used.
XRT_CHECK_RESULT VkResult vk_create_timeline_semaphore_from_native | ( | struct vk_bundle * | vk, |
xrt_graphics_sync_handle_t | native, | ||
VkSemaphore * | out_sem | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a Vulkan timeline semaphore from a native graphics sync handle, see vk_create_semaphore_from_native for more details.
VkResult vk_create_view_usage | ( | struct vk_bundle * | vk, |
VkImage | image, | ||
VkImageViewType | type, | ||
VkFormat | format, | ||
VkImageUsageFlags | image_usage, | ||
VkImageSubresourceRange | subresource_range, | ||
VkImageView * | out_view | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Creates a image with a specific subset of usage, useful for a mutable images where one format might not support all usages defined by the image.
VkResult vk_deinit_mutex | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
De-initialize mutexes in the vk_bundle.
References os_mutex::os_mutex_destroy().
VkResult vk_enumerate_display_mode_properties | ( | struct vk_bundle * | vk, |
VkPhysicalDevice | physical_device, | ||
VkDisplayKHR | display, | ||
uint32_t * | out_prop_count, | ||
VkDisplayModePropertiesKHR ** | out_props | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the mode properties of the given VkDisplayKHR
, which belongs to the given VkPhysicalDevice
.
VkResult vk_enumerate_instance_extensions_properties | ( | struct vk_bundle * | vk, |
const char * | layer_name, | ||
uint32_t * | out_prop_count, | ||
VkExtensionProperties ** | out_props | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Return the VkExtensionProperties
of the given layer_name
, NULL means the "base" driver instance.
Referenced by vk_build_instance_extensions(), and vk_check_required_instance_extensions().
VkResult vk_enumerate_physical_device_display_properties | ( | struct vk_bundle * | vk, |
VkPhysicalDevice | physical_device, | ||
uint32_t * | out_prop_count, | ||
VkDisplayPropertiesKHR ** | out_props | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the display properties of 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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the extension properties of the given VkPhysicalDevice
for the named layer_name
, NULL means the "base" driver physical device.
VkResult vk_enumerate_physical_devices | ( | struct vk_bundle * | vk, |
uint32_t * | out_physical_device_count, | ||
VkPhysicalDevice ** | out_physical_devices | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the physical devices of the VkInstance
that has been opened on the given vk_bundle.
VkResult vk_enumerate_physical_display_plane_properties | ( | struct vk_bundle * | vk, |
VkPhysicalDevice | physical_device, | ||
uint32_t * | out_prop_count, | ||
VkDisplayPlanePropertiesKHR ** | out_props | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the display plane properties of the given VkPhysicalDevice
.
VkResult vk_enumerate_surface_formats | ( | struct vk_bundle * | vk, |
VkSurfaceKHR | surface, | ||
uint32_t * | out_format_count, | ||
VkSurfaceFormatKHR ** | out_formats | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the surface formats of the given VkSurfaceKHR
, returns a list of VkSurfaceFormatKHR
, not VkFormat
.
Referenced by vk_surface_info_fill_in().
VkResult vk_enumerate_surface_present_modes | ( | struct vk_bundle * | vk, |
VkSurfaceKHR | surface, | ||
uint32_t * | out_present_mode_count, | ||
VkPresentModeKHR ** | out_present_modes | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the present modes of the given VkSurfaceKHR
.
Referenced by vk_surface_info_fill_in().
VkResult vk_enumerate_swapchain_images | ( | struct vk_bundle * | vk, |
VkSwapchainKHR | swapchain, | ||
uint32_t * | out_image_count, | ||
VkImage ** | out_images | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Enumerate the images of the given VkSwapchainKHR
.
VkResult vk_get_device_functions | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
Requires a device to have been created and set on the bundle.
VkResult vk_get_instance_functions | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
Requires a instance to have been created and set on the bundle.
VkResult vk_get_loader_functions | ( | struct vk_bundle * | vk, |
PFN_vkGetInstanceProcAddr | g | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Can be done on a completely bare bundle.
Referenced by comp_vulkan_init_bundle().
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Given a DeviceMemory handle created to be exportable, outputs the native buffer type (FD on desktop Linux) equivalent.
Caller assumes ownership of handle which should be unreferenced with u_graphics_buffer_unref when no longer needed.
vk | Vulkan bundle | |
device_memory | The memory to get the handle of | |
[out] | out_handle | A pointer to the handle to populate |
Referenced by vk_ic_get_handles().
VkResult vk_ic_allocate | ( | struct vk_bundle * | vk, |
const struct xrt_swapchain_create_info * | xscci, | ||
uint32_t | image_count, | ||
struct vk_image_collection * | out_vkic | ||
) |
#include <auxiliary/vk/vk_image_allocator.h>
Allocates image(s) using the information specified in the swapchain create info.
References ARRAY_SIZE, vk_image_collection::images, and U_LOG_E.
void vk_ic_destroy | ( | struct vk_bundle * | vk, |
struct vk_image_collection * | vkic | ||
) |
#include <auxiliary/vk/vk_image_allocator.h>
Free all images created on this image collection, doesn't free the struct itself so the caller needs to ensure that.
VkResult vk_ic_from_natives | ( | struct vk_bundle * | vk, |
const struct xrt_swapchain_create_info * | xscci, | ||
struct xrt_image_native * | native_images, | ||
uint32_t | image_count, | ||
struct vk_image_collection * | out_vkic | ||
) |
#include <auxiliary/vk/vk_image_allocator.h>
Imports and set images from the given FDs.
References ARRAY_SIZE, xrt_image_native::handle, vk_image_collection::images, and xrt_image_native::is_dxgi_handle.
VkResult vk_ic_get_handles | ( | struct vk_bundle * | vk, |
struct vk_image_collection * | vkic, | ||
uint32_t | max_handles, | ||
xrt_graphics_buffer_handle_t * | out_handles | ||
) |
#include <auxiliary/vk/vk_image_allocator.h>
Get the native handles (FDs on desktop Linux) for the images, this is a all or nothing function.
The ownership is transferred from the images to the caller so it is responsible for them to be closed just like with vkGetMemoryFdKHR.
References vk_image_collection::images, and vk_get_native_handle_from_device_memory().
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Initialize a bundle with objects given to us by client code, used by client_vk_compositor in Compositor client code.
VkResult vk_init_mutex | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
Initialize mutexes in the vk_bundle.
Not required for all uses, but a precondition for some.
References os_mutex::os_mutex_init().
void vk_name_object | ( | struct vk_bundle * | vk, |
VkObjectType | type, | ||
uint64_t | object, | ||
const char * | name | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Uses VK_EXT_debug_utils to set a name for an object, for easier debugging.
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 | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Print device information to the logger at the given logging level, if the vk_bundle has that level enabled.
void vk_print_opened_device_info | ( | struct vk_bundle * | vk, |
enum u_logging_level | log_level | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Print device information about the device that bundle manages at the given logging level if the vk_bundle has that level enabled.
void vk_print_result | ( | struct vk_bundle * | vk, |
const char * | file, | ||
int | line, | ||
const char * | calling_func, | ||
VkResult | ret, | ||
const char * | called_func | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Print the result of a function, info level if ret == VK_SUCCESS
and error level otherwise.
Also prints file and line.
References U_LOGGING_ERROR, and U_LOGGING_INFO.
VkResult vk_select_physical_device | ( | struct vk_bundle * | vk, |
int | forced_index | ||
) |
#include <auxiliary/vk/vk_helpers.h>
Setup the physical device, this is called by vk_create_device but has uses for outside of that.