Monado OpenXR Runtime
|
Vulkan helper structs and functions. More...
Files | |
file | vk_documentation.h |
Header with just documentation. | |
file | vk_helpers.c |
Common Vulkan code. | |
file | vk_helpers.h |
Common Vulkan code header. | |
Data Structures | |
struct | vk_bundle |
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code. More... | |
Functions | |
void | vk_init_validation_callback (struct vk_bundle *vk) |
void | vk_destroy_validation_callback (struct vk_bundle *vk) |
VkResult | vk_get_loader_functions (struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g) |
VkResult | vk_get_instance_functions (struct vk_bundle *vk) |
VkResult | vk_init_cmd_pool (struct vk_bundle *vk) |
VkResult | vk_create_device (struct vk_bundle *vk, int forced_index) |
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) |
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) |
VkResult | vk_alloc_and_bind_image_memory (struct vk_bundle *vk, VkImage image, size_t max_size, const void *pNext_for_allocate, VkDeviceMemory *out_mem, VkDeviceSize *out_size) |
Allocate memory for an image and bind it to that image. More... | |
VkResult | vk_create_image_from_fd (struct vk_bundle *vk, enum xrt_swapchain_usage_bits swapchain_usage, int64_t format, uint32_t width, uint32_t height, uint32_t array_size, uint32_t mip_count, struct xrt_image_fd *image_fd, VkImage *out_image, VkDeviceMemory *out_mem) |
VkResult | vk_create_image_simple (struct vk_bundle *vk, uint32_t width, uint32_t height, VkFormat format, VkDeviceMemory *out_mem, VkImage *out_image) |
VkResult | vk_create_sampler (struct vk_bundle *vk, VkSampler *out_sampler) |
VkResult | vk_create_view (struct vk_bundle *vk, VkImage image, VkFormat format, VkImageSubresourceRange subresource_range, VkImageView *out_view) |
VkResult | vk_init_cmd_buffer (struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer) |
VkResult | vk_set_image_layout (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) |
VkResult | vk_submit_cmd_buffer (struct vk_bundle *vk, VkCommandBuffer cmd_buffer) |
Vulkan helper structs and functions.
VkResult vk_alloc_and_bind_image_memory | ( | struct vk_bundle * | vk, |
VkImage | image, | ||
size_t | max_size, | ||
const void * | pNext_for_allocate, | ||
VkDeviceMemory * | out_mem, | ||
VkDeviceSize * | out_size | ||
) |
#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. |
max_size | The maximum value you'll allow for VkMemoryRequirements::size. Pass SIZE_MAX if you will accept any size that works. |
pNext_for_allocate | (Optional) a pointer to use in the pNext chain of VkMemoryAllocateInfo. |
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.
References vk_bundle::device, VK_ERROR, vk_get_memory_type(), vk_result_string(), vk_bundle::vkAllocateMemory, vk_bundle::vkBindImageMemory, vk_bundle::vkFreeMemory, and vk_bundle::vkGetImageMemoryRequirements.
Referenced by vk_create_image_from_fd(), and vk_create_image_simple().
VkResult vk_create_device | ( | struct vk_bundle * | vk, |
int | forced_index | ||
) |
#include <auxiliary/vk/vk_helpers.h>
VkResult vk_create_image_from_fd | ( | struct vk_bundle * | vk, |
enum xrt_swapchain_usage_bits | swapchain_usage, | ||
int64_t | format, | ||
uint32_t | width, | ||
uint32_t | height, | ||
uint32_t | array_size, | ||
uint32_t | mip_count, | ||
struct xrt_image_fd * | image_fd, | ||
VkImage * | out_image, | ||
VkDeviceMemory * | out_mem | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::device, xrt_image_fd::fd, xrt_image_fd::size, vk_alloc_and_bind_image_memory(), VK_ERROR, vk_result_string(), vk_bundle::vkCreateImage, vk_bundle::vkDestroyImage, XRT_SWAPCHAIN_USAGE_COLOR, XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL, XRT_SWAPCHAIN_USAGE_SAMPLED, XRT_SWAPCHAIN_USAGE_TRANSFER_DST, XRT_SWAPCHAIN_USAGE_TRANSFER_SRC, and XRT_SWAPCHAIN_USAGE_UNORDERED_ACCESS.
VkResult vk_create_image_simple | ( | struct vk_bundle * | vk, |
uint32_t | width, | ||
uint32_t | height, | ||
VkFormat | format, | ||
VkDeviceMemory * | out_mem, | ||
VkImage * | out_image | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::device, vk_alloc_and_bind_image_memory(), VK_ERROR, vk_result_string(), vk_bundle::vkCreateImage, and vk_bundle::vkDestroyImage.
VkResult vk_create_sampler | ( | struct vk_bundle * | vk, |
VkSampler * | out_sampler | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::device, VK_ERROR, vk_result_string(), and vk_bundle::vkCreateSampler.
VkResult vk_create_view | ( | struct vk_bundle * | vk, |
VkImage | image, | ||
VkFormat | format, | ||
VkImageSubresourceRange | subresource_range, | ||
VkImageView * | out_view | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::device, VK_ERROR, vk_result_string(), and vk_bundle::vkCreateImageView.
void vk_destroy_validation_callback | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::debug_report_cb, vk_bundle::instance, and vk_bundle::vkDestroyDebugReportCallbackEXT.
VkResult vk_get_instance_functions | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
References GET_INS_PROC, vk_bundle::vkAcquireXlibDisplayEXT, vk_bundle::vkCreateDebugReportCallbackEXT, vk_bundle::vkCreateDevice, vk_bundle::vkCreateDisplayPlaneSurfaceKHR, vk_bundle::vkCreateWaylandSurfaceKHR, vk_bundle::vkCreateXcbSurfaceKHR, vk_bundle::vkDestroyDebugReportCallbackEXT, vk_bundle::vkDestroyInstance, vk_bundle::vkDestroySurfaceKHR, vk_bundle::vkEnumeratePhysicalDevices, vk_bundle::vkGetDeviceProcAddr, vk_bundle::vkGetDisplayModePropertiesKHR, vk_bundle::vkGetDisplayPlaneCapabilitiesKHR, vk_bundle::vkGetPhysicalDeviceDisplayPlanePropertiesKHR, vk_bundle::vkGetPhysicalDeviceDisplayPropertiesKHR, vk_bundle::vkGetPhysicalDeviceMemoryProperties, vk_bundle::vkGetPhysicalDeviceProperties, vk_bundle::vkGetPhysicalDeviceQueueFamilyProperties, vk_bundle::vkGetPhysicalDeviceSurfaceCapabilitiesKHR, vk_bundle::vkGetPhysicalDeviceSurfaceFormatsKHR, vk_bundle::vkGetPhysicalDeviceSurfacePresentModesKHR, vk_bundle::vkGetPhysicalDeviceSurfaceSupportKHR, vk_bundle::vkGetRandROutputDisplayEXT, and vk_bundle::vkReleaseDisplayEXT.
Referenced by vk_init_from_given().
VkResult vk_get_loader_functions | ( | struct vk_bundle * | vk, |
PFN_vkGetInstanceProcAddr | g | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References GET_PROC, vk_bundle::vkCreateInstance, and vk_bundle::vkGetInstanceProcAddr.
bool vk_get_memory_type | ( | struct vk_bundle * | vk, |
uint32_t | type_bits, | ||
VkMemoryPropertyFlags | memory_props, | ||
uint32_t * | out_type_id | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::device_memory_props, and VK_DEBUG.
Referenced by vk_alloc_and_bind_image_memory().
VkResult vk_init_cmd_buffer | ( | struct vk_bundle * | vk, |
VkCommandBuffer * | out_cmd_buffer | ||
) |
VkResult vk_init_cmd_pool | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::cmd_pool, vk_bundle::device, vk_bundle::queue_family_index, VK_ERROR, vk_result_string(), and vk_bundle::vkCreateCommandPool.
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 | ||
) |
#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.
References vk_bundle::device, vk_bundle::device_memory_props, GET_PROC, vk_bundle::instance, vk_bundle::physical_device, vk_bundle::queue_family_index, vk_bundle::queue_index, U_ZERO, vk_get_instance_functions(), vk_bundle::vkCreateInstance, vk_bundle::vkGetInstanceProcAddr, vkGetInstanceProcAddr(), and vk_bundle::vkGetPhysicalDeviceMemoryProperties.
void vk_init_validation_callback | ( | struct vk_bundle * | vk | ) |
#include <auxiliary/vk/vk_helpers.h>
VkResult vk_set_image_layout | ( | 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>
References vk_bundle::vkCmdPipelineBarrier.
VkResult vk_submit_cmd_buffer | ( | struct vk_bundle * | vk, |
VkCommandBuffer | cmd_buffer | ||
) |
#include <auxiliary/vk/vk_helpers.h>
References vk_bundle::cmd_pool, vk_bundle::device, vk_bundle::queue_family_index, VK_ERROR, vk_result_string(), vk_bundle::vkCreateFence, vk_bundle::vkDestroyFence, vk_bundle::vkEndCommandBuffer, vk_bundle::vkFreeCommandBuffers, vk_bundle::vkGetDeviceQueue, vk_bundle::vkQueueSubmit, and vk_bundle::vkWaitForFences.