aux/vk: Add vk_check_error macro.

This commit is contained in:
Lubosz Sarnecki 2020-05-06 12:19:49 +02:00 committed by Jakob Bornecrantz
parent 6aa1b4e571
commit 06ce79272d
2 changed files with 17 additions and 0 deletions
src/xrt/auxiliary/vk

View file

@ -115,6 +115,16 @@ vk_color_space_string(VkColorSpaceKHR code)
}
}
bool
vk_has_error(VkResult res, const char *fun, const char *file, int line)
{
if (res != VK_SUCCESS) {
fprintf(stderr, "ERROR: %s failed with %s in %s:%d\n", fun,
vk_result_string(res), file, line);
return true;
}
return false;
}
/*
*

View file

@ -224,6 +224,13 @@ vk_color_space_string(VkColorSpaceKHR code);
fprintf(stderr, "\n"); \
} while (false)
bool
vk_has_error(VkResult res, const char *fun, const char *file, int line);
#define vk_check_error(fun, res, ret) \
if (vk_has_error(res, fun, __FILE__, __LINE__)) \
return ret
/*!
* @ingroup aux_vk
*/