From 2965bdde04eaa0012b29695aa015c354deb30bed Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Mon, 28 Oct 2024 15:52:52 -0500 Subject: render: move get_vkerr_str into vkassert.h Move get_vkerr_str into vkassert.h and use its output in the vkassert function. This reduces the need for an error message argument when calling vkassert and makes error messages in logs consistent across the entire Vulkan renderer. Signed-off-by: Danny Holman --- render/vulkan/vkassert.h | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'render/vulkan/vkassert.h') diff --git a/render/vulkan/vkassert.h b/render/vulkan/vkassert.h index 393e2de..4d4f99b 100644 --- a/render/vulkan/vkassert.h +++ b/render/vulkan/vkassert.h @@ -4,10 +4,42 @@ #include #include #include +#include -static inline void vkassert(VkResult value, const char *str) { +static char* get_vkerr_str(VkResult res) { + char *ret; + switch (res) { + case VK_SUCCESS: + ret = "SUCCESS"; + break; + case VK_ERROR_OUT_OF_HOST_MEMORY: + ret = "OUT OF HOST MEMORY"; + break; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + ret = "OUT OF DEVICE MEMORY"; + break; + case VK_ERROR_INITIALIZATION_FAILED: + ret = "INITIALIZATION FAILED"; + break; + case VK_ERROR_LAYER_NOT_PRESENT: + ret = "VALIDATION LAYER NOT PRESENT"; + break; + case VK_ERROR_EXTENSION_NOT_PRESENT: + ret = "EXTENSION NOT PRESENT"; + break; + case VK_ERROR_INCOMPATIBLE_DRIVER: + ret = "INCOMPATIBLE DRIVER"; + break; + default: + ret = "UNKNOWN RESULT"; + break; + } + return strdup(ret); +} + +static inline void vkassert(VkResult value) { if (value != VK_SUCCESS) { - log_output(LOG_ERROR, "Vulkan assertion failed: %s", str); + log_output(LOG_FATAL, "Vulkan error: %s", get_vkerr_str(value)); rune_abort(); } } -- cgit v1.2.3