Monado OpenXR Runtime
|
Common Vulkan code header. More...
#include "xrt/xrt_compiler.h"
#include "xrt/xrt_compositor.h"
#include "xrt/xrt_vulkan_includes.h"
#include "xrt/xrt_handles.h"
#include "util/u_logging.h"
#include "util/u_string_list.h"
#include "os/os_threading.h"
Go to the source code of this file.
Data Structures | |
struct | vk_bundle |
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code. More... | |
struct | vk_buffer |
struct | vk_device_features |
Used to enable device features as a argument vk_create_device. More... | |
struct | vk_descriptor_pool_info |
Arguments to vk_create_descriptor_pool function. More... | |
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_TRACE(d, ...) U_LOG_IFL_T(d->log_level, __VA_ARGS__) |
#define | VK_DEBUG(d, ...) U_LOG_IFL_D(d->log_level, __VA_ARGS__) |
#define | VK_INFO(d, ...) U_LOG_IFL_I(d->log_level, __VA_ARGS__) |
#define | VK_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__) |
#define | VK_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__) |
#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_NAME_INSTANCE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkInstance, (uintptr_t)OBJ) |
#define | VK_NAME_PHYSICAL_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPhysicalDevice, PHYSICAL_DEVICE, (uintptr_t)OBJ, NAME) |
#define | VK_NAME_DEVICE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDevice, DEVICE, (uintptr_t)OBJ, NAME) |
#define | VK_NAME_QUEUE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueue, QUEUE, (uintptr_t)OBJ, NAME) |
#define | VK_NAME_COMMAND_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandBuffer, COMMAND_BUFFER, (uintptr_t)OBJ, NAME) |
#define | VK_NAME_SEMAPHORE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSemaphore, SEMAPHORE, OBJ, NAME) |
#define | VK_NAME_FENCE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFence, FENCE, OBJ, NAME) |
#define | VK_NAME_DEVICE_MEMORY(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDeviceMemory, DEVICE_MEMORY, OBJ, NAME) |
#define | VK_NAME_BUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBuffer, BUFFER, OBJ, NAME) |
#define | VK_NAME_IMAGE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImage, IMAGE, OBJ, NAME) |
#define | VK_NAME_EVENT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkEvent, EVENT, OBJ, NAME) |
#define | VK_NAME_QUERY_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkQueryPool, QUERY_POOL, OBJ, NAME) |
#define | VK_NAME_BUFFER_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkBufferView, BUFFER_VIEW, OBJ, NAME) |
#define | VK_NAME_IMAGE_VIEW(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkImageView, IMAGE_VIEW, OBJ, NAME) |
#define | VK_NAME_SHADER_MODULE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkShaderModule, SHADER_MODULE, OBJ, NAME) |
#define | VK_NAME_PIPELINE_CACHE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineCache, PIPELINE_CACHE, OBJ, NAME) |
#define | VK_NAME_PIPELINE_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipelineLayout, PIPELINE_LAYOUT, OBJ, NAME) |
#define | VK_NAME_RENDER_PASS(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkRenderPass, RENDER_PASS, OBJ, NAME) |
#define | VK_NAME_PIPELINE(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkPipeline, PIPELINE, OBJ, NAME) |
#define | VK_NAME_DESCRIPTOR_SET_LAYOUT(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorSetLayout, DESCRIPTOR_SET_LAYOUT, OBJ, NAME) |
#define | VK_NAME_SAMPLER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSampler, SAMPLER, OBJ, NAME) |
#define | VK_NAME_DESCRIPTOR_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkDescriptorPool, DESCRIPTOR_POOL, OBJ, NAME) |
#define | VK_NAME_DESCRIPTOR_SET(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkDescriptorSet, OBJ) |
#define | VK_NAME_FRAMEBUFFER(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkFramebuffer, FRAMEBUFFER, OBJ, NAME) |
#define | VK_NAME_COMMAND_POOL(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkCommandPool, COMMAND_POOL, OBJ, NAME) |
#define | VK_NAME_SURFACE(VK, OBJ, NAME) VK_NAME_OBJ_DISABLED(VK, VkSurfaceKHR, OBJ) |
#define | VK_NAME_SWAPCHAIN(VK, OBJ, NAME) VK_NAME_OBJ(VK, VkSwapchainKHR, SWAPCHAIN_KHR, OBJ, NAME) |
#define | VK_CSCI_FORMATS(THING_COLOR, THING_DS, THING_D, THING_S) |
Helper for all of the supported formats to check support for. More... | |
Functions | |
XRT_CHECK_RESULT const char * | vk_result_string (VkResult code) |
XRT_CHECK_RESULT const char * | vk_object_type_string (VkObjectType type) |
XRT_CHECK_RESULT const char * | vk_physical_device_type_string (VkPhysicalDeviceType device_type) |
XRT_CHECK_RESULT const char * | vk_format_string (VkFormat code) |
XRT_CHECK_RESULT const char * | vk_sharing_mode_string (VkSharingMode code) |
XRT_CHECK_RESULT const char * | vk_present_mode_string (VkPresentModeKHR code) |
XRT_CHECK_RESULT const char * | vk_color_space_string (VkColorSpaceKHR code) |
XRT_CHECK_RESULT const char * | vk_power_state_string (VkDisplayPowerStateEXT code) |
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, will return 'MULTIPLE BIT SET'. More... | |
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 BIT SET'. More... | |
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, will return 'MULTIPLE BIT SET'. More... | |
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, will return 'MULTIPLE BIT SET'. More... | |
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, will return 'MULTIPLE BIT SET'. 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... | |
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 enabled. More... | |
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 level enabled. More... | |
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. 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... | |
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. 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... | |
bool | vk_init_descriptor_pool (struct vk_bundle *vk, const VkDescriptorPoolSize *pool_sizes, uint32_t pool_size_count, uint32_t set_count, VkDescriptorPool *out_descriptor_pool) |
bool | vk_allocate_descriptor_sets (struct vk_bundle *vk, VkDescriptorPool descriptor_pool, uint32_t count, const VkDescriptorSetLayout *set_layout, VkDescriptorSet *sets) |
bool | vk_buffer_init (struct vk_bundle *vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer *out_buffer, VkDeviceMemory *out_mem) |
void | vk_buffer_destroy (struct vk_buffer *self, struct vk_bundle *vk) |
bool | vk_update_buffer (struct vk_bundle *vk, float *buffer, size_t buffer_size, VkDeviceMemory memory) |
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... | |
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. More... | |
VkResult | vk_create_descriptor_set (struct vk_bundle *vk, VkDescriptorPool descriptor_pool, VkDescriptorSetLayout descriptor_layout, VkDescriptorSet *out_descriptor_set) |
Creates a descriptor set. More... | |
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. More... | |
VkResult | vk_create_pipeline_cache (struct vk_bundle *vk, VkPipelineCache *out_pipeline_cache) |
Creates a pipeline cache. More... | |
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'. More... | |
VkExternalMemoryHandleTypeFlags | vk_cb_get_buffer_external_handle_type (struct vk_bundle *vk) |
Return the extern handle type that a buffer should be created with. More... | |
VkAccessFlags | vk_csci_get_barrier_access_mask (enum xrt_swapchain_usage_bits bits) |
Returns the access flags for the compositor to app barriers. More... | |
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 OpenXR spec. More... | |
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 out before and after transfers between the application and compositor. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. 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_timeline_semaphore_and_native (struct vk_bundle *vk, VkSemaphore *out_sem, xrt_graphics_sync_handle_t *out_native) |
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... | |
Common Vulkan code header.
Note that some sections of this are generated by scripts/generate_vk_helpers.py
- lists of functions and of optional extensions to check for. In those, please update the script and run it, instead of editing directly in this file. The generated parts are delimited by special comments.
VkExternalMemoryHandleTypeFlags vk_cb_get_buffer_external_handle_type | ( | struct vk_bundle * | vk | ) |
Return the extern handle type that a buffer should be created with.
cb = Compositor Buffer.
Referenced by render_buffer_init_exportable().
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, will return 'MULTIPLE BIT SET'.
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'.
Does error logging.
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.
Does error logging.
References ARRAY_SIZE, vk_descriptor_pool_info::descriptor_count, vk_descriptor_pool_info::freeable, vk_descriptor_pool_info::sampler_per_descriptor_count, vk_descriptor_pool_info::storage_buffer_per_descriptor_count, vk_descriptor_pool_info::storage_image_per_descriptor_count, and vk_descriptor_pool_info::uniform_per_descriptor_count.
VkResult vk_create_descriptor_set | ( | struct vk_bundle * | vk, |
VkDescriptorPool | descriptor_pool, | ||
VkDescriptorSetLayout | descriptor_layout, | ||
VkDescriptorSet * | out_descriptor_set | ||
) |
VkResult vk_create_pipeline_cache | ( | struct vk_bundle * | vk, |
VkPipelineCache * | out_pipeline_cache | ||
) |
Creates a pipeline cache.
Does error logging.
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.
Does error logging.
VkAccessFlags vk_csci_get_barrier_access_mask | ( | enum xrt_swapchain_usage_bits | bits | ) |
Returns the access flags for the compositor to app barriers.
CSCI = Compositor SwapChain Images.
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 out before and after transfers between the application and compositor.
CSCI = Compositor SwapChain Images.
References VK_CSCI_FORMATS.
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 OpenXR spec.
CSCI = Compositor SwapChain Images.
References VK_CSCI_FORMATS.
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.
CSCI = Compositor SwapChain Images.
References xrt_image_native::is_dxgi_handle.
Referenced by vk_create_image_from_native().
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.
CSCI = Compositor SwapChain Images.
References vk_csci_get_image_usage_flags().
Referenced by vk_create_image_from_native().
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.
For color formats always adds:
VK_IMAGE_USAGE_SAMPLED_BIT
for compositor reading in shaders.For depth & stencil formats always adds:
VK_IMAGE_USAGE_SAMPLED_BIT
for compositor reading in shaders.For depth formats always adds:
VK_IMAGE_USAGE_SAMPLED_BIT
for compositor reading in shaders.For stencil formats always adds:
VK_IMAGE_USAGE_SAMPLED_BIT
for compositor reading in shaders.CSCI = Compositor SwapChain Images.
Referenced by vk_create_image_from_native(), and vk_csci_get_image_external_support().
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.
For color it's the color, for depth and stencil it's only depth as both are disallowed by the Vulkan spec, for depth only depth, and for stencil only it's stencil.
CSCI = Compositor SwapChain Images.
References VK_CSCI_FORMATS.
Referenced by do_post_create_vulkan_setup().
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.
CSCI = Compositor SwapChain Images.
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.
References u_string_list::u_string_list_get_data(), and u_string_list::u_string_list_get_size().
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, will return 'MULTIPLE BIT SET'.
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 BIT SET'.
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 level enabled.
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 enabled.
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.
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, will return 'MULTIPLE BIT SET'.
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, will return 'MULTIPLE BIT SET'.