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 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | * of this software and/or associated documentation files (the "Materials"), to |
| 11 | * deal in the Materials without restriction, including without limitation the |
| 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 13 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 14 | * furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice(s) and this permission notice shall be included in |
| 17 | * all copies or substantial portions of the Materials. |
| 18 | * |
| 19 | * The Materials are Confidential Information as defined by the Khronos |
| 20 | * Membership Agreement until designated non-confidential by Khronos, at which |
| 21 | * point this condition clause shall be removed. |
| 22 | * |
| 23 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 26 | * |
| 27 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 28 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 29 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 30 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
| 31 | * |
| 32 | */ |
| 33 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 34 | #ifndef VKICD_H |
| 35 | #define VKICD_H |
| 36 | |
Courtney Goeltzenleuchter | b0cedb8 | 2015-04-09 11:52:55 -0600 | [diff] [blame] | 37 | #include "vk_platform.h" |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * The ICD must reserve space for a pointer for the loader's dispatch |
| 41 | * table, at the start of <each object>. |
| 42 | * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. |
| 43 | */ |
| 44 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 45 | #define ICD_LOADER_MAGIC 0x01CDC0DE |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 46 | |
| 47 | typedef union _VK_LOADER_DATA { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 48 | uintptr_t loaderMagic; |
| 49 | void *loaderData; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 50 | } VK_LOADER_DATA; |
| 51 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 52 | static inline void set_loader_magic_value(void *pNewObject) { |
| 53 | VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 54 | loader_info->loaderMagic = ICD_LOADER_MAGIC; |
| 55 | } |
| 56 | |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 57 | static inline bool valid_loader_magic_value(void *pNewObject) { |
| 58 | const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; |
Courtney Goeltzenleuchter | 2e991f8 | 2015-07-24 10:18:40 -0600 | [diff] [blame] | 59 | return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 60 | } |
| 61 | |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 62 | /* |
| 63 | * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that |
| 64 | * contains the platform-specific connection and surface information. |
| 65 | */ |
| 66 | typedef enum _VkIcdWsiPlatform { |
| 67 | VK_ICD_WSI_PLATFORM_MIR, |
| 68 | VK_ICD_WSI_PLATFORM_WAYLAND, |
| 69 | VK_ICD_WSI_PLATFORM_WIN32, |
| 70 | VK_ICD_WSI_PLATFORM_XCB, |
| 71 | VK_ICD_WSI_PLATFORM_XLIB, |
| 72 | } VkIcdWsiPlatform; |
| 73 | |
| 74 | typedef struct _VkIcdSurfaceBase { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 75 | VkIcdWsiPlatform platform; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 76 | } VkIcdSurfaceBase; |
| 77 | |
| 78 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 79 | typedef struct _VkIcdSurfaceMir { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 80 | VkIcdSurfaceBase base; |
| 81 | MirConnection *connection; |
| 82 | MirSurface *mirSurface; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 83 | } VkIcdSurfaceMir; |
| 84 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 85 | |
| 86 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 87 | typedef struct _VkIcdSurfaceWayland { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 88 | VkIcdSurfaceBase base; |
| 89 | struct wl_display *display; |
| 90 | struct wl_surface *surface; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 91 | } VkIcdSurfaceWayland; |
| 92 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 93 | |
| 94 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 95 | typedef struct _VkIcdSurfaceWin32 { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 96 | VkIcdSurfaceBase base; |
| 97 | HINSTANCE hinstance; |
| 98 | HWND hwnd; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 99 | } VkIcdSurfaceWin32; |
| 100 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 101 | |
| 102 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 103 | typedef struct _VkIcdSurfaceXcb { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 104 | VkIcdSurfaceBase base; |
| 105 | xcb_connection_t *connection; |
| 106 | xcb_window_t window; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 107 | } VkIcdSurfaceXcb; |
| 108 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 109 | |
| 110 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 111 | typedef struct _VkIcdSurfaceXlib { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame^] | 112 | VkIcdSurfaceBase base; |
| 113 | Display *dpy; |
| 114 | Window window; |
Ian Elliott | 4d52054 | 2015-11-18 12:19:12 -0700 | [diff] [blame] | 115 | } VkIcdSurfaceXlib; |
| 116 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 117 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 118 | #endif // VKICD_H |