Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 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 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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 |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 12 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 14 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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. |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 23 | #ifndef VKICD_H |
| 24 | #define VKICD_H |
| 25 | |
Jon Ashburn | c7d3e73 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 26 | #include "vulkan.h" |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 27 | |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 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 | #define CURRENT_LOADER_ICD_INTERFACE_VERSION 4 |
Jon Ashburn | 17b4c86 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 38 | #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 39 | #define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4 |
Jon Ashburn | 17b4c86 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 40 | typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion); |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 41 | |
| 42 | // This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this |
| 43 | // flie directly, it won't be found. |
| 44 | #ifndef PFN_GetPhysicalDeviceProcAddr |
| 45 | typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); |
| 46 | #endif |
| 47 | |
Jon Ashburn | 17b4c86 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 48 | /* |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 49 | * The ICD must reserve space for a pointer for the loader's dispatch |
| 50 | * table, at the start of <each object>. |
| 51 | * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. |
| 52 | */ |
| 53 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 54 | #define ICD_LOADER_MAGIC 0x01CDC0DE |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 55 | |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 56 | typedef union { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 57 | uintptr_t loaderMagic; |
| 58 | void *loaderData; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 59 | } VK_LOADER_DATA; |
| 60 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 61 | static inline void set_loader_magic_value(void *pNewObject) { |
| 62 | VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 63 | loader_info->loaderMagic = ICD_LOADER_MAGIC; |
| 64 | } |
| 65 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 66 | static inline bool valid_loader_magic_value(void *pNewObject) { |
| 67 | const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 2e991f8 | 2015-07-24 10:18:40 -0600 | [diff] [blame] | 68 | return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 69 | } |
| 70 | |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 71 | /* |
| 72 | * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that |
| 73 | * contains the platform-specific connection and surface information. |
| 74 | */ |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 75 | typedef enum { |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 76 | VK_ICD_WSI_PLATFORM_MIR, |
| 77 | VK_ICD_WSI_PLATFORM_WAYLAND, |
| 78 | VK_ICD_WSI_PLATFORM_WIN32, |
| 79 | VK_ICD_WSI_PLATFORM_XCB, |
| 80 | VK_ICD_WSI_PLATFORM_XLIB, |
Jon Ashburn | c7d3e73 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 81 | VK_ICD_WSI_PLATFORM_DISPLAY |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 82 | } VkIcdWsiPlatform; |
| 83 | |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 84 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 85 | VkIcdWsiPlatform platform; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 86 | } VkIcdSurfaceBase; |
| 87 | |
| 88 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 89 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 90 | VkIcdSurfaceBase base; |
| 91 | MirConnection *connection; |
| 92 | MirSurface *mirSurface; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 93 | } VkIcdSurfaceMir; |
| 94 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 95 | |
| 96 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 97 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 98 | VkIcdSurfaceBase base; |
| 99 | struct wl_display *display; |
| 100 | struct wl_surface *surface; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 101 | } VkIcdSurfaceWayland; |
| 102 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 103 | |
| 104 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 105 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 106 | VkIcdSurfaceBase base; |
| 107 | HINSTANCE hinstance; |
| 108 | HWND hwnd; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 109 | } VkIcdSurfaceWin32; |
| 110 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 111 | |
| 112 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 113 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 114 | VkIcdSurfaceBase base; |
| 115 | xcb_connection_t *connection; |
| 116 | xcb_window_t window; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 117 | } VkIcdSurfaceXcb; |
| 118 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 119 | |
| 120 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 121 | typedef struct { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 122 | VkIcdSurfaceBase base; |
| 123 | Display *dpy; |
| 124 | Window window; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 125 | } VkIcdSurfaceXlib; |
| 126 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 127 | |
Cody Northrop | fa2f36c | 2016-09-22 14:39:16 -0600 | [diff] [blame] | 128 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 129 | typedef struct { |
| 130 | ANativeWindow* window; |
| 131 | } VkIcdSurfaceAndroid; |
| 132 | #endif //VK_USE_PLATFORM_ANDROID_KHR |
| 133 | |
Mark Lobodzinski | 2b46a9d | 2016-05-19 17:17:58 -0600 | [diff] [blame] | 134 | typedef struct { |
Jon Ashburn | c7d3e73 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 135 | VkIcdSurfaceBase base; |
| 136 | VkDisplayModeKHR displayMode; |
| 137 | uint32_t planeIndex; |
| 138 | uint32_t planeStackIndex; |
| 139 | VkSurfaceTransformFlagBitsKHR transform; |
| 140 | float globalAlpha; |
| 141 | VkDisplayPlaneAlphaFlagBitsKHR alphaMode; |
| 142 | VkExtent2D imageExtent; |
| 143 | } VkIcdSurfaceDisplay; |
Mark Young | 16573c7 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 144 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 145 | #endif // VKICD_H |