|
25 | 25 | #ifndef VULKAN_H_
|
26 | 26 | # ifdef VOLK_VULKAN_H_PATH
|
27 | 27 | # include VOLK_VULKAN_H_PATH
|
28 |
| -# elif defined(VK_USE_PLATFORM_WIN32_KHR) |
| 28 | +# else /* Platform headers included below */ |
29 | 29 | # include <vulkan/vk_platform.h>
|
30 | 30 | # include <vulkan/vulkan_core.h>
|
31 |
| - |
32 |
| - /* When VK_USE_PLATFORM_WIN32_KHR is defined, instead of including vulkan.h directly, we include individual parts of the SDK |
33 |
| - * This is necessary to avoid including <windows.h> which is very heavy - it takes 200ms to parse without WIN32_LEAN_AND_MEAN |
34 |
| - * and 100ms to parse with it. vulkan_win32.h only needs a few symbols that are easy to redefine ourselves. |
35 |
| - */ |
36 |
| - typedef unsigned long DWORD; |
37 |
| - typedef const wchar_t* LPCWSTR; |
38 |
| - typedef void* HANDLE; |
39 |
| - typedef struct HINSTANCE__* HINSTANCE; |
40 |
| - typedef struct HWND__* HWND; |
41 |
| - typedef struct HMONITOR__* HMONITOR; |
42 |
| - typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; |
43 |
| - |
44 |
| -# include <vulkan/vulkan_win32.h> |
45 |
| - |
46 |
| -# ifdef VK_ENABLE_BETA_EXTENSIONS |
47 |
| -# include <vulkan/vulkan_beta.h> |
48 |
| -# endif |
49 |
| -# else |
50 |
| -# include <vulkan/vulkan.h> |
51 | 31 | # endif
|
52 | 32 | #endif
|
53 | 33 |
|
@@ -124,6 +104,104 @@ VkDevice volkGetLoadedDevice(void);
|
124 | 104 | */
|
125 | 105 | void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device);
|
126 | 106 |
|
| 107 | +#ifdef __cplusplus |
| 108 | +} |
| 109 | +#endif |
| 110 | + |
| 111 | +/* Instead of directly including vulkan.h, we include platform-specific parts of the SDK manually |
| 112 | + * This is necessary to avoid including platform headers in some cases (which vulkan.h does unconditionally) |
| 113 | + * and replace them with forward declarations, which makes build times faster and avoids macro conflicts. |
| 114 | + * |
| 115 | + * Note that we only replace platform-specific headers when the headers are known to be problematic: very large |
| 116 | + * or slow to compile (Windows), or introducing unprefixed macros which can cause conflicts (Windows, Xlib). |
| 117 | + */ |
| 118 | +#if !defined(VULKAN_H_) && !defined(VOLK_VULKAN_H_PATH) |
| 119 | + |
| 120 | +#ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 121 | +#include <vulkan/vulkan_android.h> |
| 122 | +#endif |
| 123 | + |
| 124 | +#ifdef VK_USE_PLATFORM_FUCHSIA |
| 125 | +#include <zircon/types.h> |
| 126 | +#include <vulkan/vulkan_fuchsia.h> |
| 127 | +#endif |
| 128 | + |
| 129 | +#ifdef VK_USE_PLATFORM_IOS_MVK |
| 130 | +#include <vulkan/vulkan_ios.h> |
| 131 | +#endif |
| 132 | + |
| 133 | +#ifdef VK_USE_PLATFORM_MACOS_MVK |
| 134 | +#include <vulkan/vulkan_macos.h> |
| 135 | +#endif |
| 136 | + |
| 137 | +#ifdef VK_USE_PLATFORM_METAL_EXT |
| 138 | +#include <vulkan/vulkan_metal.h> |
| 139 | +#endif |
| 140 | + |
| 141 | +#ifdef VK_USE_PLATFORM_VI_NN |
| 142 | +#include <vulkan/vulkan_vi.h> |
| 143 | +#endif |
| 144 | + |
| 145 | +#ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 146 | +#include <vulkan/vulkan_wayland.h> |
| 147 | +#endif |
| 148 | + |
| 149 | +#ifdef VK_USE_PLATFORM_WIN32_KHR |
| 150 | +typedef unsigned long DWORD; |
| 151 | +typedef const wchar_t* LPCWSTR; |
| 152 | +typedef void* HANDLE; |
| 153 | +typedef struct HINSTANCE__* HINSTANCE; |
| 154 | +typedef struct HWND__* HWND; |
| 155 | +typedef struct HMONITOR__* HMONITOR; |
| 156 | +typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; |
| 157 | +#include <vulkan/vulkan_win32.h> |
| 158 | +#endif |
| 159 | + |
| 160 | +#ifdef VK_USE_PLATFORM_XCB_KHR |
| 161 | +#include <xcb/xcb.h> |
| 162 | +#include <vulkan/vulkan_xcb.h> |
| 163 | +#endif |
| 164 | + |
| 165 | +#ifdef VK_USE_PLATFORM_XLIB_KHR |
| 166 | +typedef struct _XDisplay Display; |
| 167 | +typedef unsigned long Window; |
| 168 | +typedef unsigned long VisualID; |
| 169 | +#include <vulkan/vulkan_xlib.h> |
| 170 | +#endif |
| 171 | + |
| 172 | +#ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 173 | +#include <directfb.h> |
| 174 | +#include <vulkan/vulkan_directfb.h> |
| 175 | +#endif |
| 176 | + |
| 177 | +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT |
| 178 | +typedef struct _XDisplay Display; |
| 179 | +typedef unsigned long RROutput; |
| 180 | +#include <vulkan/vulkan_xlib_xrandr.h> |
| 181 | +#endif |
| 182 | + |
| 183 | +#ifdef VK_USE_PLATFORM_GGP |
| 184 | +#include <ggp_c/vulkan_types.h> |
| 185 | +#include <vulkan/vulkan_ggp.h> |
| 186 | +#endif |
| 187 | + |
| 188 | +#ifdef VK_USE_PLATFORM_SCREEN_QNX |
| 189 | +#include <screen/screen.h> |
| 190 | +#include <vulkan/vulkan_screen.h> |
| 191 | +#endif |
| 192 | + |
| 193 | +#ifdef VK_USE_PLATFORM_SCI |
| 194 | +#include <nvscisync.h> |
| 195 | +#include <nvscibuf.h> |
| 196 | +#include <vulkan/vulkan_sci.h> |
| 197 | +#endif |
| 198 | + |
| 199 | +#ifdef VK_ENABLE_BETA_EXTENSIONS |
| 200 | +#include <vulkan/vulkan_beta.h> |
| 201 | +#endif |
| 202 | + |
| 203 | +#endif |
| 204 | + |
127 | 205 | /**
|
128 | 206 | * Device-specific function pointer table
|
129 | 207 | */
|
@@ -1055,6 +1133,10 @@ struct VolkDeviceTable
|
1055 | 1133 | /* VOLK_GENERATE_DEVICE_TABLE */
|
1056 | 1134 | };
|
1057 | 1135 |
|
| 1136 | +#ifdef __cplusplus |
| 1137 | +extern "C" { |
| 1138 | +#endif |
| 1139 | + |
1058 | 1140 | /* VOLK_GENERATE_PROTOTYPES_H */
|
1059 | 1141 | #if defined(VK_VERSION_1_0)
|
1060 | 1142 | extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
|
|
0 commit comments