From 6316bf39a952e5120512a7d2443213c717f57025 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 30 Sep 2023 12:19:43 +0100 Subject: [PATCH] a/vk: Add vk_print_result helper --- src/xrt/auxiliary/vk/vk_helpers.h | 9 +++++++++ src/xrt/auxiliary/vk/vk_print.c | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/xrt/auxiliary/vk/vk_helpers.h b/src/xrt/auxiliary/vk/vk_helpers.h index b49e0427b..0b2359791 100644 --- a/src/xrt/auxiliary/vk/vk_helpers.h +++ b/src/xrt/auxiliary/vk/vk_helpers.h @@ -624,6 +624,15 @@ vk_name_object(struct vk_bundle *vk, VkDebugReportObjectTypeEXT object_type, uin * */ +/*! + * Print the result of a function, info level if ret == `VK_SUCCESS` and error + * level otherwise. Also prints file and line. + * + * @ingroup aux_vk + */ +void +vk_print_result(struct vk_bundle *vk, VkResult ret, const char *fun, const char *file, int line); + /*! * Print device information to the logger at the given logging level, * if the vk_bundle has that level enabled. diff --git a/src/xrt/auxiliary/vk/vk_print.c b/src/xrt/auxiliary/vk/vk_print.c index 76cbd4447..48841edbb 100644 --- a/src/xrt/auxiliary/vk/vk_print.c +++ b/src/xrt/auxiliary/vk/vk_print.c @@ -45,6 +45,16 @@ * */ +void +vk_print_result(struct vk_bundle *vk, VkResult ret, const char *fun, const char *file, int line) +{ + if (ret == VK_SUCCESS) { + VK_INFO(vk, "%s: %s [%s:%d]", fun, vk_result_string(ret), file, line); + } else { + VK_ERROR(vk, "%s failed: %s [%s:%d]", fun, vk_result_string(ret), file, line); + } +} + void vk_print_device_info(struct vk_bundle *vk, enum u_logging_level log_level,