• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //% gcc -c -Wall -I. -I../include htest.c
2 
3 // Copyright 2019-2021 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 // Sanity 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     const VkInstanceCreateInfo instance_info = {
53         .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
54         .pNext = NULL,
55         .flags = 0,
56         .pApplicationInfo = NULL,
57         .enabledLayerCount = 0,
58         .ppEnabledLayerNames = NULL,
59         .enabledExtensionCount = 0,
60         .ppEnabledExtensionNames = NULL,
61     };
62     VkInstance instance;
63     vkCreateInstance(&instance_info, NULL, &instance);
64     vkDestroyInstance(instance, NULL);
65 
66     // Test XLIB_XRANDR_EXT platform, which does not define a new type
67     VkResult xrandr_result = vkAcquireXlibDisplayEXT((VkPhysicalDevice)0, (Display *)NULL, (VkDisplayKHR)0);
68 
69     (void)xrandr_result;
70     return 0;
71 }
72