1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef _VKUTIL_H
#define _VKUTIL_H
/**
* vkutil.h -- helper functions and macros for working with vulkan in C
*/
#include <stdio.h>
#include <stdarg.h>
#include <vulkan/vulkan.h>
#include <vulkan/vk_enum_string_helper.h> // 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__, __LINE__, string_VkResult(err)); \
abort(); \
} \
} while (0)
typedef enum {
VK_INFO = 0,
VK_WARN,
VK_ERROR,
} log_type;
static inline 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 */
|