vulkan: Update the XML and headers to 1.1.124
[mesa.git] / include / vulkan / vk_icd.h
1 //
2 // File: vk_icd.h
3 //
4 /*
5 * Copyright (c) 2015-2016 The Khronos Group Inc.
6 * Copyright (c) 2015-2016 Valve Corporation
7 * Copyright (c) 2015-2016 LunarG, Inc.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 */
22
23 #ifndef VKICD_H
24 #define VKICD_H
25
26 #include "vulkan.h"
27 #include <stdbool.h>
28
29 // Loader-ICD version negotiation API. Versions add the following features:
30 // Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
31 // or vk_icdNegotiateLoaderICDInterfaceVersion.
32 // Version 1 - Add support for vk_icdGetInstanceProcAddr.
33 // Version 2 - Add Loader/ICD Interface version negotiation
34 // via vk_icdNegotiateLoaderICDInterfaceVersion.
35 // Version 3 - Add ICD creation/destruction of KHR_surface objects.
36 // Version 4 - Add unknown physical device extension qyering via
37 // vk_icdGetPhysicalDeviceProcAddr.
38 // Version 5 - Tells ICDs that the loader is now paying attention to the
39 // application version of Vulkan passed into the ApplicationInfo
40 // structure during vkCreateInstance. This will tell the ICD
41 // that if the loader is older, it should automatically fail a
42 // call for any API version > 1.0. Otherwise, the loader will
43 // manually determine if it can support the expected version.
44 #define CURRENT_LOADER_ICD_INTERFACE_VERSION 5
45 #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
46 #define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
47 typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion);
48
49 // This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
50 // file directly, it won't be found.
51 #ifndef PFN_GetPhysicalDeviceProcAddr
52 typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
53 #endif
54
55 /*
56 * The ICD must reserve space for a pointer for the loader's dispatch
57 * table, at the start of <each object>.
58 * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
59 */
60
61 #define ICD_LOADER_MAGIC 0x01CDC0DE
62
63 typedef union {
64 uintptr_t loaderMagic;
65 void *loaderData;
66 } VK_LOADER_DATA;
67
68 static inline void set_loader_magic_value(void *pNewObject) {
69 VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
70 loader_info->loaderMagic = ICD_LOADER_MAGIC;
71 }
72
73 static inline bool valid_loader_magic_value(void *pNewObject) {
74 const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
75 return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
76 }
77
78 /*
79 * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
80 * contains the platform-specific connection and surface information.
81 */
82 typedef enum {
83 VK_ICD_WSI_PLATFORM_MIR,
84 VK_ICD_WSI_PLATFORM_WAYLAND,
85 VK_ICD_WSI_PLATFORM_WIN32,
86 VK_ICD_WSI_PLATFORM_XCB,
87 VK_ICD_WSI_PLATFORM_XLIB,
88 VK_ICD_WSI_PLATFORM_ANDROID,
89 VK_ICD_WSI_PLATFORM_MACOS,
90 VK_ICD_WSI_PLATFORM_IOS,
91 VK_ICD_WSI_PLATFORM_DISPLAY,
92 VK_ICD_WSI_PLATFORM_HEADLESS,
93 VK_ICD_WSI_PLATFORM_METAL,
94 } VkIcdWsiPlatform;
95
96 typedef struct {
97 VkIcdWsiPlatform platform;
98 } VkIcdSurfaceBase;
99
100 #ifdef VK_USE_PLATFORM_MIR_KHR
101 typedef struct {
102 VkIcdSurfaceBase base;
103 MirConnection *connection;
104 MirSurface *mirSurface;
105 } VkIcdSurfaceMir;
106 #endif // VK_USE_PLATFORM_MIR_KHR
107
108 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
109 typedef struct {
110 VkIcdSurfaceBase base;
111 struct wl_display *display;
112 struct wl_surface *surface;
113 } VkIcdSurfaceWayland;
114 #endif // VK_USE_PLATFORM_WAYLAND_KHR
115
116 #ifdef VK_USE_PLATFORM_WIN32_KHR
117 typedef struct {
118 VkIcdSurfaceBase base;
119 HINSTANCE hinstance;
120 HWND hwnd;
121 } VkIcdSurfaceWin32;
122 #endif // VK_USE_PLATFORM_WIN32_KHR
123
124 #ifdef VK_USE_PLATFORM_XCB_KHR
125 typedef struct {
126 VkIcdSurfaceBase base;
127 xcb_connection_t *connection;
128 xcb_window_t window;
129 } VkIcdSurfaceXcb;
130 #endif // VK_USE_PLATFORM_XCB_KHR
131
132 #ifdef VK_USE_PLATFORM_XLIB_KHR
133 typedef struct {
134 VkIcdSurfaceBase base;
135 Display *dpy;
136 Window window;
137 } VkIcdSurfaceXlib;
138 #endif // VK_USE_PLATFORM_XLIB_KHR
139
140 #ifdef VK_USE_PLATFORM_ANDROID_KHR
141 typedef struct {
142 VkIcdSurfaceBase base;
143 struct ANativeWindow *window;
144 } VkIcdSurfaceAndroid;
145 #endif // VK_USE_PLATFORM_ANDROID_KHR
146
147 #ifdef VK_USE_PLATFORM_MACOS_MVK
148 typedef struct {
149 VkIcdSurfaceBase base;
150 const void *pView;
151 } VkIcdSurfaceMacOS;
152 #endif // VK_USE_PLATFORM_MACOS_MVK
153
154 #ifdef VK_USE_PLATFORM_IOS_MVK
155 typedef struct {
156 VkIcdSurfaceBase base;
157 const void *pView;
158 } VkIcdSurfaceIOS;
159 #endif // VK_USE_PLATFORM_IOS_MVK
160
161 typedef struct {
162 VkIcdSurfaceBase base;
163 VkDisplayModeKHR displayMode;
164 uint32_t planeIndex;
165 uint32_t planeStackIndex;
166 VkSurfaceTransformFlagBitsKHR transform;
167 float globalAlpha;
168 VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
169 VkExtent2D imageExtent;
170 } VkIcdSurfaceDisplay;
171
172 typedef struct {
173 VkIcdSurfaceBase base;
174 } VkIcdSurfaceHeadless;
175
176 #ifdef VK_USE_PLATFORM_METAL_EXT
177 typedef struct {
178 VkIcdSurfaceBase base;
179 const CAMetalLayer *pLayer;
180 } VkIcdSurfaceMetal;
181 #endif // VK_USE_PLATFORM_METAL_EXT
182
183 #endif // VKICD_H