From 9ead62940aecb7793b3d82c9c8eb73bc9eb4f60f Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 19 May 2024 04:06:41 +0300 Subject: aait --- src/vkutil.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/vkutil.h (limited to 'src/vkutil.h') diff --git a/src/vkutil.h b/src/vkutil.h new file mode 100644 index 0000000..7ab19a0 --- /dev/null +++ b/src/vkutil.h @@ -0,0 +1,58 @@ +#ifndef _VKUTIL_H +#define _VKUTIL_H + +/** + * vkutil.h -- helper functions and macros for working with vulkan in C + */ + +#include +#include + +#include +#include // for string_VkResult + +#define VK_ARRAY_LEN(arr) sizeof((arr))/sizeof((arr)[0]) + +#define VK_CHECK(x) \ +do { \ + VkResult err = x; \ + if (err) { \ + fprintf(stderr, "%s:%d:0: vulkan error: %s \n", \ + __FILE__+3, __LINE__, string_VkResult(err)); \ + abort(); \ + } \ +} while (0) + +typedef enum { + VK_INFO = 0, + VK_WARN, + VK_ERROR, +} log_type; + +void +vk_log(log_type t, const char * f, ...) +{ +#ifdef VKDEBUG + va_list args; + va_start(args, f); + switch (t) { + case VK_INFO: + printf("INFO: "); + vprintf(f, args); + break; + case VK_WARN: + fprintf(stderr, "WARN: "); + vfprintf(stderr, f, args); + break; + case VK_ERROR: + fprintf(stderr, "ERROR: "); + vfprintf(stderr, f, args); + break; + } + va_end(args); +#else + return; +#endif +} + +#endif /* _VKUTIL_H */ -- cgit v1.2.3