diff --git a/volk.h b/volk.h index 165b630..1833248 100644 --- a/volk.h +++ b/volk.h @@ -22,31 +22,107 @@ # define VK_NO_PROTOTYPES #endif + +/* When VK_USE_PLATFORM_XYZ is defined, instead of including vulkan.h directly, we include individual parts of the SDK + * This is necessary to avoid including platform-specific headers which may be very heavy - + * it takes 200ms to parse windows.h without WIN32_LEAN_AND_MEAN and 100ms to parse with it. + * The WSI only needs a few symbols that are straightforward to redefine ourselves. + * Currently supported platforms: + * VK_USE_PLATFORM_FUCHSIA + * VK_USE_PLATFORM_WIN32_KHR + * VK_USE_PLATFORM_XLIB_KHR + * VK_USE_PLATFORM_XCB_KHR + * VK_USE_PLATFORM_DIRECTFB_EXT + * VK_USE_PLATFORM_XLIB_XRANDR_EXT + * VK_USE_PLATFORM_GGP + * VK_USE_PLATFORM_SCREEN_QNX + * + * Nothing needs to be done for the following platforms as they don't depend on platform-specific headers: + * VK_USE_PLATFORM_MACOS_MVK + * VK_USE_PLATFORM_METAL_EXT + * VK_USE_PLATFORM_VI_NN + * VK_USE_PLATFORM_WAYLAND_KHR + */ + #ifndef VULKAN_H_ +# include + # ifdef VOLK_VULKAN_H_PATH # include VOLK_VULKAN_H_PATH -# elif defined(VK_USE_PLATFORM_WIN32_KHR) -# include -# include +# else +# if defined(VK_USE_PLATFORM_FUCHSIA) + // If someone knows what the include guard for is, please add a guard arround this + typedef uint32_t zx_handle_t; - /* When VK_USE_PLATFORM_WIN32_KHR is defined, instead of including vulkan.h directly, we include individual parts of the SDK - * This is necessary to avoid including which is very heavy - it takes 200ms to parse without WIN32_LEAN_AND_MEAN - * and 100ms to parse with it. vulkan_win32.h only needs a few symbols that are easy to redefine ourselves. - */ - typedef unsigned long DWORD; - typedef const wchar_t* LPCWSTR; - typedef void* HANDLE; - typedef struct HINSTANCE__* HINSTANCE; - typedef struct HWND__* HWND; - typedef struct HMONITOR__* HMONITOR; - typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; +# include +# undef VK_USE_PLATFORM_FUCHSIA +# endif +# if defined(VK_USE_PLATFORM_WIN32_KHR) +# if !defined(WINDOWS_H) + typedef unsigned long DWORD; + typedef const wchar_t* LPCWSTR; + typedef void* HANDLE; + typedef struct HINSTANCE__* HINSTANCE; + typedef struct HWND__* HWND; + typedef struct HMONITOR__* HMONITOR; + typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; +# endif -# include +# include +# undef VK_USE_PLATFORM_WIN32_KHR +# endif +# if defined(VK_USE_PLATFORM_XLIB_KHR) + // This is not 1:1 what Xlib uses, but it's close enough for most purposes. +# if !defined(X_H) + // This is an include guard for the XLIB_XRANDR platform. +# define VOLK_VULKAN_H_DEFINE_XLIB_STRUCTURES + typedef struct Display Display; + typedef uint32_t Window; + typedef uint32_t VisualID; +# endif -# ifdef VK_ENABLE_BETA_EXTENSIONS -# include +# include +# undef VK_USE_PLATFORM_XLIB_KHR +# endif +# if defined(VK_USE_PLATFORM_XCB_KHR) +# if !defined(__XCB_H__) + typedef struct xcb_connection_t xcb_connection_t; + typedef uint32_t xcb_window_t; + typedef uint32_t xcb_visualid_t; +# endif + +# include +# undef VK_USE_PLATFORM_XCB_KHR +# endif +# if defined(VK_USE_PLATFORM_DIRECTFB_EXT) + typedef struct IDirectFB IDirectFB; + typedef struct IDirectFBSurface IDirectFBSurface; + +# include +# undef VK_USE_PLATFORM_DIRECTFB_EXT +# endif +# if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) +# if !defined(X_H) && !defined(VOLK_VULKAN_H_DEFINE_XLIB_STRUCTURES) + typedef struct Display Display; +# endif +# if !defined(_RANDRSTR_H_) + typedef uint32_t RROutput; +# endif + +# include +# undef VK_USE_PLATFORM_XLIB_XRANDR_EXT +# endif +# if defined(VK_USE_PLATFORM_GGP) + typedef uint32_t GgpStreamDescriptor; + typedef uint64_t GgpFrameToken; + +# include +# undef VK_USE_PLATFORM_GGP +# endif +# if defined(VK_USE_PLATFORM_SCREEN_QNX) +# include +# undef VK_USE_PLATFORM_SCREEN_QNX # endif -# else # include # endif #endif