a/vk: Annotate some must-check-return functions

This commit is contained in:
Ryan Pavlik 2022-07-13 12:28:51 -05:00
parent b0405023b7
commit f69b6d6320
5 changed files with 41 additions and 40 deletions

View file

@ -826,7 +826,7 @@ filter_device_features(struct vk_bundle *vk,
*
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_create_device(struct vk_bundle *vk,
int forced_index,
bool only_compute,
@ -992,7 +992,7 @@ vk_deinit_mutex(struct vk_bundle *vk)
return VK_SUCCESS;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_init_cmd_pool(struct vk_bundle *vk)
{
VkCommandPoolCreateInfo cmd_pool_info = {
@ -1017,7 +1017,7 @@ vk_init_cmd_pool(struct vk_bundle *vk)
*
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_init_from_given(struct vk_bundle *vk,
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
VkInstance instance,

View file

@ -38,7 +38,7 @@
#define ENUM_TO_STR(r) \
case r: return #r
const char *
XRT_CHECK_RESULT const char *
vk_result_string(VkResult code)
{
switch (code) {
@ -72,7 +72,7 @@ vk_result_string(VkResult code)
}
}
const char *
XRT_CHECK_RESULT const char *
vk_format_string(VkFormat code)
{
switch (code) {
@ -331,7 +331,7 @@ vk_format_string(VkFormat code)
}
}
const char *
XRT_CHECK_RESULT const char *
vk_format_feature_string(VkFormatFeatureFlagBits code)
{
switch (code) {
@ -345,7 +345,7 @@ vk_format_feature_string(VkFormatFeatureFlagBits code)
}
}
const char *
XRT_CHECK_RESULT const char *
xrt_swapchain_usage_string(enum xrt_swapchain_usage_bits code)
{
switch (code) {
@ -361,7 +361,7 @@ xrt_swapchain_usage_string(enum xrt_swapchain_usage_bits code)
}
}
const char *
XRT_CHECK_RESULT const char *
vk_present_mode_string(VkPresentModeKHR code)
{
switch (code) {
@ -375,7 +375,7 @@ vk_present_mode_string(VkPresentModeKHR code)
}
}
const char *
XRT_CHECK_RESULT const char *
vk_power_state_string(VkDisplayPowerStateEXT code)
{
switch (code) {
@ -386,7 +386,7 @@ vk_power_state_string(VkDisplayPowerStateEXT code)
}
}
const char *
XRT_CHECK_RESULT const char *
vk_color_space_string(VkColorSpaceKHR code)
{
switch (code) {
@ -395,7 +395,7 @@ vk_color_space_string(VkColorSpaceKHR code)
}
}
bool
XRT_CHECK_RESULT bool
vk_has_error(VkResult res, const char *fun, const char *file, int line)
{
if (res != VK_SUCCESS) {
@ -446,7 +446,7 @@ vk_get_memory_type(struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFla
return false;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_alloc_and_bind_image_memory(struct vk_bundle *vk,
VkImage image,
size_t max_size,
@ -657,7 +657,7 @@ err_image:
return ret;
}
VkResult
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,
@ -896,7 +896,7 @@ get_device_memory_handle(struct vk_bundle *vk, VkDeviceMemory device_memory, xrt
#error "Needs port"
#endif
VkResult
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)
@ -1175,7 +1175,7 @@ err_buffer:
return ret;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
{
VkResult ret = VK_SUCCESS;
@ -1231,7 +1231,7 @@ out:
return ret;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_locked_submit(struct vk_bundle *vk, VkQueue queue, uint32_t count, const VkSubmitInfo *infos, VkFence fence)
{
VkResult ret;

View file

@ -19,6 +19,7 @@
#pragma once
#include "xrt/xrt_compiler.h"
#include "xrt/xrt_compositor.h"
#include "xrt/xrt_vulkan_includes.h"
#include "xrt/xrt_handles.h"
@ -384,25 +385,25 @@ struct vk_buffer
*
*/
const char *
XRT_CHECK_RESULT const char *
vk_result_string(VkResult code);
const char *
XRT_CHECK_RESULT const char *
vk_format_string(VkFormat code);
const char *
XRT_CHECK_RESULT const char *
vk_present_mode_string(VkPresentModeKHR code);
const char *
XRT_CHECK_RESULT const char *
vk_power_state_string(VkDisplayPowerStateEXT code);
const char *
XRT_CHECK_RESULT const char *
vk_color_space_string(VkColorSpaceKHR code);
const char *
XRT_CHECK_RESULT const char *
vk_format_feature_string(VkFormatFeatureFlagBits code);
const char *
XRT_CHECK_RESULT const char *
xrt_swapchain_usage_string(enum xrt_swapchain_usage_bits code);
@ -430,7 +431,7 @@ xrt_swapchain_usage_string(enum xrt_swapchain_usage_bits code);
*
* @ingroup aux_vk
*/
bool
XRT_CHECK_RESULT bool
vk_has_error(VkResult res, const char *fun, const char *file, int line);
/*!
@ -587,7 +588,7 @@ struct vk_device_features
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_create_device(struct vk_bundle *vk,
int forced_index,
bool only_compute,
@ -619,7 +620,7 @@ vk_deinit_mutex(struct vk_bundle *vk);
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_init_cmd_pool(struct vk_bundle *vk);
/*!
@ -628,7 +629,7 @@ vk_init_cmd_pool(struct vk_bundle *vk);
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_init_from_given(struct vk_bundle *vk,
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
VkInstance instance,
@ -690,7 +691,7 @@ vk_get_memory_type(struct vk_bundle *vk, uint32_t type_bits, VkMemoryPropertyFla
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_alloc_and_bind_image_memory(struct vk_bundle *vk,
VkImage image,
size_t max_size,
@ -720,7 +721,7 @@ vk_alloc_and_bind_image_memory(struct vk_bundle *vk,
*
* @ingroup aux_vk
*/
VkResult
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,
@ -740,7 +741,7 @@ vk_create_image_from_native(struct vk_bundle *vk,
*
* @ingroup aux_vk
*/
VkResult
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);
@ -863,7 +864,7 @@ vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer);
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer);
/*!
@ -873,7 +874,7 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer);
*
* @ingroup aux_vk
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_locked_submit(struct vk_bundle *vk, VkQueue queue, uint32_t count, const VkSubmitInfo *infos, VkFence fence);
/*!

View file

@ -73,7 +73,7 @@ vk_get_timeline_semaphore_handle_type(struct vk_bundle *vk)
*
*/
bool
XRT_CHECK_RESULT bool
vk_can_import_and_export_timeline_semaphore(struct vk_bundle *vk)
{
#ifdef VK_KHR_timeline_semaphore
@ -101,7 +101,7 @@ vk_can_import_and_export_timeline_semaphore(struct vk_bundle *vk)
*
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_create_and_submit_fence_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t *out_native)
{
xrt_graphics_sync_handle_t native = XRT_GRAPHICS_SYNC_HANDLE_INVALID;
@ -276,7 +276,7 @@ create_semaphore_and_native(struct vk_bundle *vk,
return VK_SUCCESS;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_create_semaphore_and_native(struct vk_bundle *vk, VkSemaphore *out_sem, xrt_graphics_sync_handle_t *out_native)
{
VkExternalSemaphoreHandleTypeFlagBits handle_type = 0;
@ -296,7 +296,7 @@ vk_create_semaphore_and_native(struct vk_bundle *vk, VkSemaphore *out_sem, xrt_g
}
#ifdef VK_KHR_timeline_semaphore
VkResult
XRT_CHECK_RESULT VkResult
vk_create_timeline_semaphore_and_native(struct vk_bundle *vk,
VkSemaphore *out_sem,
xrt_graphics_sync_handle_t *out_native)
@ -332,7 +332,7 @@ vk_create_timeline_semaphore_and_native(struct vk_bundle *vk,
*
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_create_fence_sync_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkFence *out_fence)
{
VkFence fence = VK_NULL_HANDLE;
@ -450,7 +450,7 @@ create_semaphore_from_native(struct vk_bundle *vk,
return VK_SUCCESS;
}
VkResult
XRT_CHECK_RESULT VkResult
vk_create_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkSemaphore *out_sem)
{
VkExternalSemaphoreHandleTypeFlagBits handle_type = 0;
@ -472,7 +472,7 @@ vk_create_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t
}
#ifdef VK_KHR_timeline_semaphore
VkResult
XRT_CHECK_RESULT VkResult
vk_create_timeline_semaphore_from_native(struct vk_bundle *vk, xrt_graphics_sync_handle_t native, VkSemaphore *out_sem)
{
VkExternalSemaphoreHandleTypeFlagBits handle_type = 0;

View file

@ -54,7 +54,7 @@ from_host_ticks_to_host_ns(uint64_t ticks)
*
*/
VkResult
XRT_CHECK_RESULT VkResult
vk_convert_timestamps_to_host_ns(struct vk_bundle *vk, uint32_t count, uint64_t *in_out_timestamps)
{
VkResult ret;