HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vk_icd.h
Go to the documentation of this file.
1 //
2 // File: vk_icd.h
3 //
4 /*
5  * Copyright (c) 2015-2016, 2022 The Khronos Group Inc.
6  * Copyright (c) 2015-2016, 2022 Valve Corporation
7  * Copyright (c) 2015-2016, 2022 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 querying 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 // Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices.
45 // Version 7 - If an ICD supports any of the following functions, they must be
46 // queryable with vk_icdGetInstanceProcAddr:
47 // vk_icdNegotiateLoaderICDInterfaceVersion
48 // vk_icdGetPhysicalDeviceProcAddr
49 // vk_icdEnumerateAdapterPhysicalDevices (Windows only)
50 // In addition, these functions no longer need to be exported directly.
51 // This version allows drivers provided through the extension
52 // VK_LUNARG_direct_driver_loading be able to support the entire
53 // Driver-Loader interface.
54 
55 #define CURRENT_LOADER_ICD_INTERFACE_VERSION 7
56 #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0
57 #define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4
58 
59 // Old typedefs that don't follow a proper naming convention but are preserved for compatibility
61 // This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this
62 // file directly, it won't be found.
63 #ifndef PFN_GetPhysicalDeviceProcAddr
64 typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName);
65 #endif
66 
67 // Typedefs for loader/ICD interface
69 typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName);
70 typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
71 #if defined(VK_USE_PLATFORM_WIN32_KHR)
72 typedef VkResult (VKAPI_PTR *PFN_vk_icdEnumerateAdapterPhysicalDevices)(VkInstance instance, LUID adapterLUID,
73  uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
74 #endif
75 
76 // Prototypes for loader/ICD interface
77 #if !defined(VK_NO_PROTOTYPES)
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
82  VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName);
83  VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName);
84 #if defined(VK_USE_PLATFORM_WIN32_KHR)
85  VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID,
86  uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
87 #endif
88 #ifdef __cplusplus
89 }
90 #endif
91 #endif
92 
93 /*
94  * The ICD must reserve space for a pointer for the loader's dispatch
95  * table, at the start of <each object>.
96  * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro.
97  */
98 
99 #define ICD_LOADER_MAGIC 0x01CDC0DE
100 
101 typedef union {
103  void *loaderData;
105 
106 static inline void set_loader_magic_value(void *pNewObject) {
107  VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
108  loader_info->loaderMagic = ICD_LOADER_MAGIC;
109 }
110 
111 static inline bool valid_loader_magic_value(void *pNewObject) {
112  const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject;
113  return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC;
114 }
115 
116 /*
117  * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that
118  * contains the platform-specific connection and surface information.
119  */
120 typedef enum {
138 
139 typedef struct {
142 
143 #ifdef VK_USE_PLATFORM_MIR_KHR
144 typedef struct {
145  VkIcdSurfaceBase base;
146  MirConnection *connection;
147  MirSurface *mirSurface;
148 } VkIcdSurfaceMir;
149 #endif // VK_USE_PLATFORM_MIR_KHR
150 
151 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
152 typedef struct {
153  VkIcdSurfaceBase base;
154  struct wl_display *display;
155  struct wl_surface *surface;
156 } VkIcdSurfaceWayland;
157 #endif // VK_USE_PLATFORM_WAYLAND_KHR
158 
159 #ifdef VK_USE_PLATFORM_WIN32_KHR
160 typedef struct {
161  VkIcdSurfaceBase base;
162  HINSTANCE hinstance;
163  HWND hwnd;
164 } VkIcdSurfaceWin32;
165 #endif // VK_USE_PLATFORM_WIN32_KHR
166 
167 #ifdef VK_USE_PLATFORM_XCB_KHR
168 typedef struct {
169  VkIcdSurfaceBase base;
170  xcb_connection_t *connection;
171  xcb_window_t window;
172 } VkIcdSurfaceXcb;
173 #endif // VK_USE_PLATFORM_XCB_KHR
174 
175 #ifdef VK_USE_PLATFORM_XLIB_KHR
176 typedef struct {
177  VkIcdSurfaceBase base;
178  Display *dpy;
179  Window window;
180 } VkIcdSurfaceXlib;
181 #endif // VK_USE_PLATFORM_XLIB_KHR
182 
183 #ifdef VK_USE_PLATFORM_DIRECTFB_EXT
184 typedef struct {
185  VkIcdSurfaceBase base;
186  IDirectFB *dfb;
187  IDirectFBSurface *surface;
188 } VkIcdSurfaceDirectFB;
189 #endif // VK_USE_PLATFORM_DIRECTFB_EXT
190 
191 #ifdef VK_USE_PLATFORM_ANDROID_KHR
192 typedef struct {
193  VkIcdSurfaceBase base;
194  struct ANativeWindow *window;
195 } VkIcdSurfaceAndroid;
196 #endif // VK_USE_PLATFORM_ANDROID_KHR
197 
198 #ifdef VK_USE_PLATFORM_MACOS_MVK
199 typedef struct {
200  VkIcdSurfaceBase base;
201  const void *pView;
202 } VkIcdSurfaceMacOS;
203 #endif // VK_USE_PLATFORM_MACOS_MVK
204 
205 #ifdef VK_USE_PLATFORM_IOS_MVK
206 typedef struct {
207  VkIcdSurfaceBase base;
208  const void *pView;
209 } VkIcdSurfaceIOS;
210 #endif // VK_USE_PLATFORM_IOS_MVK
211 
212 #ifdef VK_USE_PLATFORM_GGP
213 typedef struct {
214  VkIcdSurfaceBase base;
215  GgpStreamDescriptor streamDescriptor;
216 } VkIcdSurfaceGgp;
217 #endif // VK_USE_PLATFORM_GGP
218 
219 typedef struct {
221  VkDisplayModeKHR displayMode;
222  uint32_t planeIndex;
223  uint32_t planeStackIndex;
225  float globalAlpha;
229 
230 typedef struct {
233 
234 #ifdef VK_USE_PLATFORM_METAL_EXT
235 typedef struct {
236  VkIcdSurfaceBase base;
237  const CAMetalLayer *pLayer;
238 } VkIcdSurfaceMetal;
239 #endif // VK_USE_PLATFORM_METAL_EXT
240 
241 #ifdef VK_USE_PLATFORM_VI_NN
242 typedef struct {
243  VkIcdSurfaceBase base;
244  void *window;
245 } VkIcdSurfaceVi;
246 #endif // VK_USE_PLATFORM_VI_NN
247 
248 #ifdef VK_USE_PLATFORM_SCREEN_QNX
249 typedef struct {
250  VkIcdSurfaceBase base;
251  struct _screen_context *context;
252  struct _screen_window *window;
253 } VkIcdSurfaceScreen;
254 #endif // VK_USE_PLATFORM_SCREEN_QNX
255 
256 #ifdef VK_USE_PLATFORM_FUCHSIA
257 typedef struct {
258  VkIcdSurfaceBase base;
259 } VkIcdSurfaceImagePipe;
260 #endif // VK_USE_PLATFORM_FUCHSIA
261 
262 #endif // VKICD_H
Definition: oidn.hpp:598
VkResult
Definition: vulkan_core.h:139
#define VKAPI_CALL
Definition: vk_platform.h:57
VkResult(VKAPI_PTR * PFN_vk_icdNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion)
Definition: vk_icd.h:68
VkExtent2D imageExtent
Definition: vk_icd.h:227
VkSurfaceTransformFlagBitsKHR transform
Definition: vk_icd.h:224
fallback_uintptr uintptr_t
Definition: format.h:295
VkIcdSurfaceBase base
Definition: vk_icd.h:220
VkDisplayPlaneAlphaFlagBitsKHR alphaMode
Definition: vk_icd.h:226
#define VKAPI_PTR
Definition: vk_platform.h:58
#define VKAPI_ATTR
Definition: vk_platform.h:56
VkIcdWsiPlatform platform
Definition: vk_icd.h:140
uint32_t planeStackIndex
Definition: vk_icd.h:223
void(VKAPI_PTR * PFN_vkVoidFunction)(void)
Definition: vulkan_core.h:2918
VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pVersion)
uintptr_t loaderMagic
Definition: vk_icd.h:102
VkResult(VKAPI_PTR * PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion)
Definition: vk_icd.h:60
VkDisplayModeKHR displayMode
Definition: vk_icd.h:221
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char *pName)
#define ICD_LOADER_MAGIC
Definition: vk_icd.h:99
uint32_t planeIndex
Definition: vk_icd.h:222
VkDisplayPlaneAlphaFlagBitsKHR
Definition: vulkan_core.h:7792
PFN_vkVoidFunction(VKAPI_PTR * PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName)
Definition: vk_icd.h:64
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
VkIcdWsiPlatform
Definition: vk_icd.h:120
PFN_vkVoidFunction(VKAPI_PTR * PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName)
Definition: vk_icd.h:70
void * loaderData
Definition: vk_icd.h:103
void CAMetalLayer
Definition: vulkan_metal.h:26
VkIcdSurfaceBase base
Definition: vk_icd.h:231
VkSurfaceTransformFlagBitsKHR
Definition: vulkan_core.h:7549
PFN_vkVoidFunction(VKAPI_PTR * PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char *pName)
Definition: vk_icd.h:69