RetroArch
vk_icd.h
Go to the documentation of this file.
1 /* File: vk_icd.h */
2 
3 /*
4  * Copyright (c) 2015-2016 The Khronos Group Inc.
5  * Copyright (c) 2015-2016 Valve Corporation
6  * Copyright (c) 2015-2016 LunarG, Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef VKICD_H
23 #define VKICD_H
24 
25 #include "vulkan.h"
26 #include <stdbool.h>
27 
28 /* Loader-ICD version negotiation API. Versions add the following features:
29  * Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr
30  * or vk_icdNegotiateLoaderICDInterfaceVersion.
31  * Version 1 - Add support for vk_icdGetInstanceProcAddr.
32  * Version 2 - Add Loader/ICD Interface version negotiation
33  * via vk_icdNegotiateLoaderICDInterfaceVersion.
34  * Version 3 - Add ICD creation/destruction of KHR_surface objects.
35  * Version 4 - Add unknown physical device extension qyering via
36  * vk_icdGetPhysicalDeviceProcAddr.
37  * Version 5 - Tells ICDs that the loader is now paying attention to the
38  * application version of Vulkan passed into the ApplicationInfo
39  * structure during vkCreateInstance. This will tell the ICD
40  * that if the loader is older, it should automatically fail a
41  * call for any API version > 1.0. Otherwise, the loader will
42  * manually determine if it can support the expected version.
43  */
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
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 {
65  void *loaderData;
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 {
93 
94 typedef struct {
97 
98 #ifdef VK_USE_PLATFORM_MIR_KHR
99 typedef struct {
100  VkIcdSurfaceBase base;
101  MirConnection *connection;
102  MirSurface *mirSurface;
103 } VkIcdSurfaceMir;
104 #endif /* VK_USE_PLATFORM_MIR_KHR */
105 
106 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
107 typedef struct {
108  VkIcdSurfaceBase base;
109  struct wl_display *display;
110  struct wl_surface *surface;
111 } VkIcdSurfaceWayland;
112 #endif /* VK_USE_PLATFORM_WAYLAND_KHR */
113 
114 #ifdef VK_USE_PLATFORM_WIN32_KHR
115 typedef struct {
116  VkIcdSurfaceBase base;
117  HINSTANCE hinstance;
118  HWND hwnd;
119 } VkIcdSurfaceWin32;
120 #endif /* VK_USE_PLATFORM_WIN32_KHR */
121 
122 #ifdef VK_USE_PLATFORM_XCB_KHR
123 typedef struct {
124  VkIcdSurfaceBase base;
125  xcb_connection_t *connection;
126  xcb_window_t window;
127 } VkIcdSurfaceXcb;
128 #endif /* VK_USE_PLATFORM_XCB_KHR */
129 
130 #ifdef VK_USE_PLATFORM_XLIB_KHR
131 typedef struct {
132  VkIcdSurfaceBase base;
133  Display *dpy;
134  Window window;
135 } VkIcdSurfaceXlib;
136 #endif /* VK_USE_PLATFORM_XLIB_KHR */
137 
138 #ifdef VK_USE_PLATFORM_ANDROID_KHR
139 typedef struct {
140  VkIcdSurfaceBase base;
141  ANativeWindow *window;
142 } VkIcdSurfaceAndroid;
143 #endif /* VK_USE_PLATFORM_ANDROID_KHR */
144 
145 #ifdef VK_USE_PLATFORM_MACOS_MVK
146 typedef struct {
147  VkIcdSurfaceBase base;
148  const void *pView;
149 } VkIcdSurfaceMacOS;
150 #endif /* VK_USE_PLATFORM_MACOS_MVK */
151 
152 #ifdef VK_USE_PLATFORM_IOS_MVK
153 typedef struct {
154  VkIcdSurfaceBase base;
155  const void *pView;
156 } VkIcdSurfaceIOS;
157 #endif /* VK_USE_PLATFORM_IOS_MVK */
158 
159 typedef struct {
161  VkDisplayModeKHR displayMode;
165  float globalAlpha;
169 
170 #endif /* VKICD_H */
uintptr_t loaderMagic
Definition: vk_icd.h:64
_W64 unsigned int uintptr_t
Definition: stdint.h:165
Definition: vk_icd.h:91
Definition: vk_icd.h:94
Definition: vk_icd.h:84
VkSurfaceTransformFlagBitsKHR
Definition: vulkan_core.h:4577
#define ICD_LOADER_MAGIC
Definition: vk_icd.h:61
uint32_t planeIndex
Definition: vk_icd.h:162
#define VKAPI_PTR
Definition: vk_platform.h:68
static bool valid_loader_magic_value(void *pNewObject)
Definition: vk_icd.h:73
Definition: vk_icd.h:85
PFN_vkVoidFunction(VKAPI_PTR * PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName)
Definition: vk_icd.h:52
VkSurfaceTransformFlagBitsKHR transform
Definition: vk_icd.h:164
VkIcdWsiPlatform
Definition: vk_icd.h:82
VkResult(VKAPI_PTR * PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion)
Definition: vk_icd.h:47
Definition: vk_icd.h:63
Definition: vk_icd.h:89
Definition: vk_icd.h:88
Definition: vk_icd.h:159
static void set_loader_magic_value(void *pNewObject)
Definition: vk_icd.h:68
VkIcdWsiPlatform platform
Definition: vk_icd.h:95
VkDisplayPlaneAlphaFlagBitsKHR alphaMode
Definition: vk_icd.h:166
void(VKAPI_PTR * PFN_vkVoidFunction)(void)
Definition: vulkan_core.h:1905
VkResult
Definition: vulkan_core.h:124
Definition: vulkan_core.h:2240
Definition: nk_menu.h:45
VkDisplayPlaneAlphaFlagBitsKHR
Definition: vulkan_core.h:4824
float globalAlpha
Definition: vk_icd.h:165
VkExtent2D imageExtent
Definition: vk_icd.h:167
VkIcdSurfaceBase base
Definition: vk_icd.h:160
Definition: vk_icd.h:90
uint32_t planeStackIndex
Definition: vk_icd.h:163
Definition: vk_icd.h:86
Definition: vk_icd.h:83
VkDisplayModeKHR displayMode
Definition: vk_icd.h:161
void * loaderData
Definition: vk_icd.h:65
unsigned int uint32_t
Definition: stdint.h:126
Definition: vk_icd.h:87