1#pragma once
2
3#include "taichi/rhi/impl_support.h"
4
5#ifdef _WIN64
6#define VK_USE_PLATFORM_WIN32_KHR 1
7#endif
8
9#ifdef ANDROID
10#define VK_USE_PLATFORM_ANDROID_KHR
11#endif
12
13#include <volk.h>
14#ifndef VK_NO_PROTOTYPES
15#define VK_NO_PROTOTYPES 1
16#endif // VK_NO_PROTOTYPES
17
18#include <vulkan/vulkan.h>
19#include <vulkan/vulkan_core.h>
20
21#include <cstdio>
22
23namespace taichi::lang {
24namespace vulkan {
25
26#define BAIL_ON_VK_BAD_RESULT_NO_RETURN(result, msg) \
27 { \
28 if ((result) != VK_SUCCESS) { \
29 char vk_msg_buf[512]; \
30 std::snprintf(vk_msg_buf, sizeof(vk_msg_buf), "(%d) %s", result, msg); \
31 RHI_LOG_ERROR(vk_msg_buf); \
32 RHI_ASSERT(false && "Error without return code"); \
33 }; \
34 }
35
36#define BAIL_ON_VK_BAD_RESULT(result, msg, retcode, retval) \
37 { \
38 if ((result) != VK_SUCCESS) { \
39 char vk_msg_buf[512]; \
40 std::snprintf(vk_msg_buf, sizeof(vk_msg_buf), "(%d) %s", result, msg); \
41 RHI_LOG_ERROR(vk_msg_buf); \
42 return {retcode, retval}; \
43 }; \
44 }
45
46inline constexpr VkAllocationCallbacks *kNoVkAllocCallbacks = nullptr;
47
48} // namespace vulkan
49} // namespace taichi::lang
50