htest.c
1 //% gcc -c -Wall -I. -I../include htest.c 2 3 // Simple compilation test for Vulkan headers, including all platform 4 // headers. 5 // To allow compilation in environments without one or more platforms, fake 6 // headers for different platforms are supplied. They provide just the types 7 // Vulkan platforms require. 8 // When a new Vulkan platform is defined, the corresponding USE_PLATFORM 9 // header definition, and any supporting fake platform headers, should be 10 // defined here, along with a trivial compilation test using a Vulkan type 11 // or function specific to that platform. 12 13 // Enable each platform when vulkan.h is included 14 15 #define VK_USE_PLATFORM_ANDROID_KHR // No headers needed 16 #define VK_USE_PLATFORM_FUCHSIA // <zircon/types.h> 17 #define VK_USE_PLATFORM_GGP // <ggp_c/vulkan_types.h> 18 #define VK_USE_PLATFORM_IOS_MVK // No headers needed 19 #define VK_USE_PLATFORM_MACOS_MVK // No headers needed 20 #define VK_USE_PLATFORM_METAL_EXT // No headers needed 21 #define VK_USE_PLATFORM_VI_NN // No headers needed 22 #define VK_USE_PLATFORM_WAYLAND_KHR // <wayland-client.h> 23 #define VK_USE_PLATFORM_WIN32_KHR // <windows.h> 24 #define VK_USE_PLATFORM_XCB_KHR // <xcb/xcb.h> 25 #define VK_USE_PLATFORM_XLIB_KHR // <X11/Xlib.h> 26 #define VK_USE_PLATFORM_XLIB_XRANDR_EXT // <X11/extensions/Xrandr.h> 27 28 #include <vulkan/vulkan.h> 29 30 // Sanity check with a type or function from each platform header in turn 31 32 VkAndroidSurfaceCreateFlagsKHR android_flags; 33 VkImagePipeSurfaceCreateFlagsFUCHSIA fuchsia_flags; 34 VkStreamDescriptorSurfaceCreateFlagsGGP ggp_flags; 35 VkIOSSurfaceCreateFlagsMVK ios_flags; 36 VkMacOSSurfaceCreateFlagsMVK macos_flags; 37 VkMetalSurfaceCreateFlagsEXT metal_flags; 38 VkViSurfaceCreateFlagsNN vi_flags; 39 VkWaylandSurfaceCreateFlagsKHR wayland_flags; 40 VkWin32SurfaceCreateFlagsKHR win32_flags; 41 VkXcbSurfaceCreateFlagsKHR xcb_flags; 42 VkXlibSurfaceCreateFlagsKHR xlib_flags; 43 44 int main(void) { 45 const VkInstanceCreateInfo instance_info = { 46 .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, 47 .pNext = NULL, 48 .flags = 0, 49 .pApplicationInfo = NULL, 50 .enabledLayerCount = 0, 51 .ppEnabledLayerNames = NULL, 52 .enabledExtensionCount = 0, 53 .ppEnabledExtensionNames = NULL, 54 }; 55 VkInstance instance; 56 vkCreateInstance(&instance_info, NULL, &instance); 57 vkDestroyInstance(instance, NULL); 58 59 // Test XLIB_XRANDR_EXT platform, which doesn't define a new type 60 VkResult xrandr_result = vkAcquireXlibDisplayEXT((VkPhysicalDevice)0, (Display *)NULL, (VkDisplayKHR)0); 61 62 (void)xrandr_result; 63 return 0; 64 }