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