summaryrefslogtreecommitdiff
path: root/render/vulkan/context.c
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-10-28 15:52:52 -0500
committerDanny Holman <dholman@gymli.org>2024-10-28 15:55:49 -0500
commit2965bdde04eaa0012b29695aa015c354deb30bed (patch)
tree27a74440014ec67c35695dd355fdb1995937cef9 /render/vulkan/context.c
parent075efbc3c4603246a9fb6c0e2e8ede051d444cd6 (diff)
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 <dholman@gymli.org>
Diffstat (limited to 'render/vulkan/context.c')
-rw-r--r--render/vulkan/context.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/render/vulkan/context.c b/render/vulkan/context.c
index afa1648..eaf4cf3 100644
--- a/render/vulkan/context.c
+++ b/render/vulkan/context.c
@@ -1,40 +1,10 @@
#include "context.h"
+#include "vkassert.h"
#include <rune/core/logging.h>
#include <rune/core/alloc.h>
#include <stdlib.h>
#include <string.h>
-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);
-}
-
VKAPI_ATTR VkBool32 VKAPI_CALL _vulkan_db_callback(
VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
VkDebugUtilsMessageTypeFlagsEXT message_types,
@@ -79,7 +49,7 @@ int _init_vkdebugger(struct vkcontext *context) {
VkResult res;
res = func(context->instance, &dbinfo, NULL, &context->db_messenger);
if (res != VK_SUCCESS) {
- char *err_str = _get_vkerr_str(res);
+ char *err_str = get_vkerr_str(res);
log_output(LOG_ERROR, "Cannot create a Vulkan debug session: %s", err_str);
free(err_str);
return -1;
@@ -107,7 +77,7 @@ struct vkcontext* create_vkcontext(struct vklayer_container *vklayers, struct ex
VkResult res;
res = vkCreateInstance(&cinfo, NULL, &ret->instance);
if (res != VK_SUCCESS) {
- char *err_str = _get_vkerr_str(res);
+ char *err_str = get_vkerr_str(res);
log_output(LOG_FATAL, "Cannot create a Vulkan instance: %s", err_str);
free(err_str);
rune_free(ret);